усложненная работа 7 коммит 2
This commit is contained in:
parent
aeab1fb1bf
commit
9abbd88d55
@ -41,8 +41,31 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public MessageInfoViewModel? ReadElement(MessageInfoSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. MessageId:{MessageId}", model.MessageId);
|
||||
var element = _messageStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. MessageId:{Id}", element.MessageId);
|
||||
return element;
|
||||
}
|
||||
public bool Update(MessageInfoBindingModel model)
|
||||
{
|
||||
if (_messageStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -6,7 +6,8 @@ using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Xml.Linq;
|
||||
|
||||
using Org.BouncyCastle.Math.EC;
|
||||
using PlumbingRepairBusinessLogic.MailWorker;
|
||||
|
||||
namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -18,14 +19,18 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly IWorkStorage _workStorage;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly IClientStorage _clientStorage;
|
||||
static readonly object _locker = new object();
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage, IWorkStorage workStorage, IShopLogic shopLogic)
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage, IWorkStorage workStorage, IShopLogic shopLogic, AbstractMailWorker mailWorker, IClientStorage clientStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopStorage = shopStorage;
|
||||
_workStorage = workStorage;
|
||||
_shopLogic = shopLogic;
|
||||
_clientStorage = clientStorage;
|
||||
_mailWorker = mailWorker;
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
@ -51,13 +56,19 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
{
|
||||
_logger.LogWarning("Invalid order status");
|
||||
return false;
|
||||
|
||||
}
|
||||
model.Status = OrderStatus.Принят;
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
var result = _orderStorage.Insert(model);
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
var orderView = _orderStorage.GetElement(new() { Id = result.Id });
|
||||
var clientView = _clientStorage.GetElement(new() { Id = orderView!.ClientId });
|
||||
|
||||
SendEmail(clientView, orderView);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -132,8 +143,48 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
|
||||
}
|
||||
_orderStorage.Update(model);
|
||||
model.Status = newStatus;
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
model.DateImplement = DateTime.Now;
|
||||
var orderView = _orderStorage.GetElement(new() { Id = model.Id });
|
||||
var clientView = _clientStorage.GetElement(new() { Id = orderView!.ClientId });
|
||||
|
||||
SendEmail(clientView, orderView);
|
||||
return true;
|
||||
|
||||
}
|
||||
public void SendEmail(ClientViewModel clientModel, OrderViewModel orderModel)
|
||||
{
|
||||
if (clientModel == null && orderModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MailSendInfoBindingModel mailModel;
|
||||
|
||||
if (orderModel.Status == OrderStatus.Принят)
|
||||
{
|
||||
mailModel = new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = clientModel.Email,
|
||||
Subject = $"Заказ №{orderModel.Id}",
|
||||
Text = $"Ваш заказ №{orderModel.Id} в {orderModel.DateCreate} на сумму {orderModel.Sum} был принят!"
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
mailModel = new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = clientModel.Email,
|
||||
Subject = $"Заказ №{orderModel.Id}",
|
||||
Text = $"Заказ №{orderModel.Id} статус изменен в {orderModel.Status}"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
_mailWorker.MailSendAsync(mailModel);
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
@ -150,7 +201,10 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор работы", nameof(model.WorkId));
|
||||
}
|
||||
|
||||
if (model.ClientId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор клиента", nameof(model.ClientId));
|
||||
}
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество работ в заказе должно быть больше 0", nameof(model.Count));
|
||||
@ -161,7 +215,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Order. OrderId:{Id}. Sum:{Sum}. WorkId: {WorkId}", model.Id, model.Sum, model.WorkId);
|
||||
_logger.LogInformation("Order. OrderId:{Id}. Sum:{Sum}. WorkId: {WorkId}. ClientId: {ClientId}", model.Id, model.Sum, model.WorkId, model.ClientId);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,5 +14,7 @@ namespace PlumbingRepairContracts.BindingModels
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
public string Body { get; set; } = string.Empty;
|
||||
public bool IsRead { get; set; } = false;
|
||||
public string? ReplyText { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -8,5 +8,7 @@ namespace PlumbingRepairContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||
bool Create(MessageInfoBindingModel model);
|
||||
MessageInfoViewModel? ReadElement(MessageInfoSearchModel? model);
|
||||
bool Update(MessageInfoBindingModel model);
|
||||
}
|
||||
}
|
@ -5,5 +5,7 @@
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
public string? MessageId { get; set; }
|
||||
public int? Page { get; set; }
|
||||
public int? PageSize { get; set; }
|
||||
}
|
||||
}
|
@ -10,5 +10,6 @@ namespace PlumbingRepairContracts.StoragesContracts
|
||||
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||
MessageInfoViewModel? Update(MessageInfoBindingModel model);
|
||||
}
|
||||
}
|
@ -16,5 +16,9 @@ namespace PlumbingRepairContracts.ViewModels
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
[DisplayName("Текст")]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
[DisplayName("Прочитано")]
|
||||
public bool IsRead { get; set; } = false;
|
||||
[DisplayName("Ответ")]
|
||||
public string? ReplyText { get; set; }
|
||||
}
|
||||
}
|
@ -9,5 +9,7 @@ namespace PlumbingRepairDataModels.Models
|
||||
DateTime DateDelivery { get; }
|
||||
string Subject { get; }
|
||||
string Body { get; }
|
||||
bool IsRead { get; }
|
||||
string? ReplyText { get; }
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,25 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||
{
|
||||
using var context = new PlumbingRepairDatabase();
|
||||
if (model.ClientId.HasValue && model.Page.HasValue && model.PageSize.HasValue)
|
||||
{
|
||||
return context.Messages
|
||||
.Where(x => x.ClientId.HasValue && x.ClientId == model.ClientId)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Skip(model.PageSize.Value * model.Page.Value)
|
||||
.Take(model.PageSize.Value)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.Page.HasValue && model.PageSize.HasValue)
|
||||
{
|
||||
return context.Messages
|
||||
.Skip(model.PageSize.Value * model.Page.Value)
|
||||
.Take(model.PageSize.Value)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||
{
|
||||
@ -51,5 +65,18 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return newMessageInfo.GetViewModel;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
using var context = new PlumbingRepairDatabase();
|
||||
var message = context.Messages.FirstOrDefault(x => x.MessageId == model.MessageId);
|
||||
if (message == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
message.Update(model);
|
||||
context.SaveChanges();
|
||||
return message.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -55,40 +55,6 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => AttachNames(x.GetViewModel)).ToList();
|
||||
}
|
||||
if (model.Status.HasValue)
|
||||
{
|
||||
return context.Orders.
|
||||
Include(x => x.Work)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Where(x => x.Status.Equals(model.Status))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.ClientId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Client).
|
||||
Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x =>AttachNames(x.GetViewModel)).ToList();
|
||||
}
|
||||
if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return context.Orders.
|
||||
Include(x => x.Work)
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Select(x => AttachNames(x.GetViewModel)).ToList();
|
||||
}
|
||||
return new();
|
||||
=======
|
||||
>>>>>>> lab_7
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
@ -139,6 +105,9 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
||||
|
||||
}
|
||||
return new();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
|
@ -1,260 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class initCreate : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cost = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.cs
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateOpening = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
maxCountWorks = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
========
|
||||
name: "Messages",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true),
|
||||
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||
>>>>>>>> lab_7:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.cs
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Works",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Works", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkId = table.Column<int>(type: "int", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
ImplementerId = table.Column<int>(type: "int", nullable: true),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
column: x => x.ImplementerId,
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Works_WorkId",
|
||||
column: x => x.WorkId,
|
||||
principalTable: "Works",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopWorks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkId = table.Column<int>(type: "int", nullable: false),
|
||||
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShopWorks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopWorks_Shops_ShopId",
|
||||
column: x => x.ShopId,
|
||||
principalTable: "Shops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopWorks_Works_WorkId",
|
||||
column: x => x.WorkId,
|
||||
principalTable: "Works",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "WorkComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkId = table.Column<int>(type: "int", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_WorkComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_WorkComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_WorkComponents_Works_WorkId",
|
||||
column: x => x.WorkId,
|
||||
principalTable: "Works",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_WorkId",
|
||||
table: "Orders",
|
||||
column: "WorkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopWorks_ShopId",
|
||||
table: "ShopWorks",
|
||||
column: "ShopId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopWorks_WorkId",
|
||||
table: "ShopWorks",
|
||||
column: "WorkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_WorkComponents_ComponentId",
|
||||
table: "WorkComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_WorkComponents_WorkId",
|
||||
table: "WorkComponents",
|
||||
column: "WorkId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Messages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopWorks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "WorkComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shops");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Works");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,366 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using PlumbingRepairDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PlumbingRepairDatabase))]
|
||||
<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.Designer.cs
|
||||
[Migration("20240503121400_initCreate")]
|
||||
partial class initCreate
|
||||
========
|
||||
[Migration("20240503110424_InitCreate")]
|
||||
partial class InitCreate
|
||||
>>>>>>>> lab_7:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.Designer.cs
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.27")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.Property<string>("MessageId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("MessageId");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpening")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("maxCountWorks")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
b.ToTable("ShopWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WorkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Works");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
b.ToTable("WorkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Works")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany()
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Shop");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("WorkComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("WorkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Works");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -12,13 +12,8 @@ using PlumbingRepairDatabaseImplement;
|
||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PlumbingRepairDatabase))]
|
||||
<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.Designer.cs
|
||||
[Migration("20240503121400_initCreate")]
|
||||
partial class initCreate
|
||||
========
|
||||
[Migration("20240503110424_InitCreate")]
|
||||
[Migration("20240515153909_InitCreate")]
|
||||
partial class InitCreate
|
||||
>>>>>>>> lab_7:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.Designer.cs
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -116,6 +111,12 @@ namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsRead")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("ReplyText")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class initCreate : Migration
|
||||
public partial class InitCreate : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
@ -55,7 +55,24 @@ namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
<<<<<<<< HEAD:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.cs
|
||||
name: "Messages",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true),
|
||||
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
IsRead = table.Column<bool>(type: "bit", nullable: false),
|
||||
ReplyText = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
@ -69,21 +86,6 @@ namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
========
|
||||
name: "Messages",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true),
|
||||
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||
>>>>>>>> lab_7:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.cs
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
@ -109,6 +109,12 @@ namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsRead")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("ReplyText")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
@ -19,6 +19,9 @@ namespace PlumbingRepairDatabaseImplement.Models
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public bool IsRead { get; private set; } = false;
|
||||
public string? ReplyText { get; private set; }
|
||||
|
||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
@ -35,6 +38,11 @@ namespace PlumbingRepairDatabaseImplement.Models
|
||||
Subject = model.Subject,
|
||||
Body = model.Body
|
||||
};
|
||||
}
|
||||
public void Update(MessageInfoBindingModel model)
|
||||
{
|
||||
IsRead = model.IsRead;
|
||||
ReplyText = model.ReplyText;
|
||||
}
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
@ -44,6 +52,8 @@ namespace PlumbingRepairDatabaseImplement.Models
|
||||
MessageId = MessageId,
|
||||
SenderName = SenderName,
|
||||
DateDelivery = DateDelivery,
|
||||
IsRead = IsRead,
|
||||
ReplyText = ReplyText
|
||||
};
|
||||
}
|
||||
}
|
@ -24,10 +24,15 @@ namespace PlumbingRepairFileImplement.Implements
|
||||
|
||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||
{
|
||||
return source.Messages
|
||||
var res = source.Messages
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (!(model.Page.HasValue && model.PageSize.HasValue))
|
||||
{
|
||||
return res.ToList();
|
||||
}
|
||||
return res.Skip(model.PageSize.Value * model.Page.Value).Take(model.PageSize.Value).ToList();
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||
@ -52,5 +57,16 @@ namespace PlumbingRepairFileImplement.Implements
|
||||
source.SaveMessages();
|
||||
return newMessageInfo.GetViewModel;
|
||||
}
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
var message = source.Messages.FirstOrDefault(x => x.MessageId == model.MessageId);
|
||||
if (message == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
message.Update(model);
|
||||
source.SaveMessages();
|
||||
return message.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,8 @@ namespace PlumbingRepairFileImplement.Models
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
public bool IsRead { get; private set; } = false;
|
||||
public string? ReplyText { get; private set; }
|
||||
|
||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
@ -53,7 +55,11 @@ namespace PlumbingRepairFileImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void Update(MessageInfoBindingModel model)
|
||||
{
|
||||
IsRead = model.IsRead;
|
||||
ReplyText = model.ReplyText;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
@ -63,6 +69,8 @@ namespace PlumbingRepairFileImplement.Models
|
||||
MessageId = MessageId,
|
||||
SenderName = SenderName,
|
||||
DateDelivery = DateDelivery,
|
||||
IsRead = IsRead,
|
||||
ReplyText = ReplyText
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("MessageInfo",
|
||||
@ -71,8 +79,9 @@ namespace PlumbingRepairFileImplement.Models
|
||||
new XAttribute("ClientId", ClientId),
|
||||
new XAttribute("MessageId", MessageId),
|
||||
new XAttribute("SenderName", SenderName),
|
||||
new XAttribute("DateDelivery", DateDelivery)
|
||||
|
||||
new XAttribute("DateDelivery", DateDelivery),
|
||||
new XElement("IsRead", IsRead),
|
||||
new XElement("ReplyText", ReplyText)
|
||||
);
|
||||
}
|
||||
}
|
@ -37,8 +37,21 @@ namespace PlumbingRepairListImplement.Implements
|
||||
}
|
||||
}
|
||||
|
||||
if (!(model.Page.HasValue && model.PageSize.HasValue))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (model.Page * model.PageSize >= result.Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<MessageInfoViewModel> filteredResult = new();
|
||||
for (var i = model.PageSize.Value * model.Page.Value; i < model.Page.Value * model.PageSize.Value; i++)
|
||||
{
|
||||
filteredResult.Add(result[i]);
|
||||
}
|
||||
return filteredResult;
|
||||
}
|
||||
|
||||
public List<MessageInfoViewModel> GetFullList()
|
||||
{
|
||||
@ -64,5 +77,17 @@ namespace PlumbingRepairListImplement.Implements
|
||||
|
||||
return newMessage.GetViewModel;
|
||||
}
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
foreach (var message in _source.Messages)
|
||||
{
|
||||
if (message.MessageId == model.MessageId)
|
||||
{
|
||||
message.Update(model);
|
||||
return message.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ namespace PlumbingRepairListImplement.Models
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
public bool IsRead { get; private set; } = false;
|
||||
public string? ReplyText { get; private set; }
|
||||
|
||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
@ -35,7 +37,11 @@ namespace PlumbingRepairListImplement.Models
|
||||
DateDelivery = model.DateDelivery,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(MessageInfoBindingModel model)
|
||||
{
|
||||
IsRead = model.IsRead;
|
||||
ReplyText = model.ReplyText;
|
||||
}
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
Body = Body,
|
||||
@ -44,6 +50,8 @@ namespace PlumbingRepairListImplement.Models
|
||||
MessageId = MessageId,
|
||||
SenderName = SenderName,
|
||||
DateDelivery = DateDelivery,
|
||||
IsRead = IsRead,
|
||||
ReplyText = ReplyText
|
||||
};
|
||||
}
|
||||
}
|
@ -67,13 +67,15 @@ namespace AbstractShopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<MessageInfoViewModel>? GetMessages(int clientId)
|
||||
public List<MessageInfoViewModel>? GetMessages(int clientId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _mailLogic.ReadList(new MessageInfoSearchModel
|
||||
{
|
||||
ClientId = clientId
|
||||
ClientId = clientId,
|
||||
Page = page,
|
||||
PageSize = 5
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -26,7 +26,7 @@ builder.Services.AddTransient<IShopLogic, ShopLogic>();
|
||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
|
||||
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>();
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
152
PlumbingRepair/PlumbingRepairView/FormMail.Designer.cs
generated
Normal file
152
PlumbingRepair/PlumbingRepairView/FormMail.Designer.cs
generated
Normal file
@ -0,0 +1,152 @@
|
||||
namespace PlumbingRepairView
|
||||
{
|
||||
partial class FormMail
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonSend = new System.Windows.Forms.Button();
|
||||
this.labelReply = new System.Windows.Forms.Label();
|
||||
this.textBoxReply = new System.Windows.Forms.TextBox();
|
||||
this.textBoxBody = new System.Windows.Forms.TextBox();
|
||||
this.labelBody = new System.Windows.Forms.Label();
|
||||
this.textBoxSubject = new System.Windows.Forms.TextBox();
|
||||
this.labelSubject = new System.Windows.Forms.Label();
|
||||
this.textBoxSender = new System.Windows.Forms.TextBox();
|
||||
this.labelSender = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonSend
|
||||
//
|
||||
this.buttonSend.Location = new System.Drawing.Point(423, 409);
|
||||
this.buttonSend.Name = "buttonSend";
|
||||
this.buttonSend.Size = new System.Drawing.Size(358, 34);
|
||||
this.buttonSend.TabIndex = 17;
|
||||
this.buttonSend.Text = "Отправить";
|
||||
this.buttonSend.UseVisualStyleBackColor = true;
|
||||
this.buttonSend.Click += new System.EventHandler(this.ButtonSend_Click);
|
||||
//
|
||||
// labelReply
|
||||
//
|
||||
this.labelReply.AutoSize = true;
|
||||
this.labelReply.Location = new System.Drawing.Point(423, 14);
|
||||
this.labelReply.Name = "labelReply";
|
||||
this.labelReply.Size = new System.Drawing.Size(112, 25);
|
||||
this.labelReply.TabIndex = 16;
|
||||
this.labelReply.Text = "Текст ответа";
|
||||
//
|
||||
// textBoxReply
|
||||
//
|
||||
this.textBoxReply.Location = new System.Drawing.Point(423, 42);
|
||||
this.textBoxReply.Multiline = true;
|
||||
this.textBoxReply.Name = "textBoxReply";
|
||||
this.textBoxReply.Size = new System.Drawing.Size(358, 361);
|
||||
this.textBoxReply.TabIndex = 15;
|
||||
//
|
||||
// textBoxBody
|
||||
//
|
||||
this.textBoxBody.Location = new System.Drawing.Point(5, 200);
|
||||
this.textBoxBody.Multiline = true;
|
||||
this.textBoxBody.Name = "textBoxBody";
|
||||
this.textBoxBody.Size = new System.Drawing.Size(347, 243);
|
||||
this.textBoxBody.TabIndex = 14;
|
||||
//
|
||||
// labelBody
|
||||
//
|
||||
this.labelBody.AutoSize = true;
|
||||
this.labelBody.Location = new System.Drawing.Point(5, 172);
|
||||
this.labelBody.Name = "labelBody";
|
||||
this.labelBody.Size = new System.Drawing.Size(152, 25);
|
||||
this.labelBody.TabIndex = 13;
|
||||
this.labelBody.Text = "Текст сообщения";
|
||||
//
|
||||
// textBoxSubject
|
||||
//
|
||||
this.textBoxSubject.Location = new System.Drawing.Point(5, 119);
|
||||
this.textBoxSubject.Name = "textBoxSubject";
|
||||
this.textBoxSubject.Size = new System.Drawing.Size(347, 31);
|
||||
this.textBoxSubject.TabIndex = 12;
|
||||
//
|
||||
// labelSubject
|
||||
//
|
||||
this.labelSubject.AutoSize = true;
|
||||
this.labelSubject.Location = new System.Drawing.Point(5, 91);
|
||||
this.labelSubject.Name = "labelSubject";
|
||||
this.labelSubject.Size = new System.Drawing.Size(99, 25);
|
||||
this.labelSubject.TabIndex = 11;
|
||||
this.labelSubject.Text = "Заголовок";
|
||||
//
|
||||
// textBoxSender
|
||||
//
|
||||
this.textBoxSender.Location = new System.Drawing.Point(5, 42);
|
||||
this.textBoxSender.Name = "textBoxSender";
|
||||
this.textBoxSender.Size = new System.Drawing.Size(347, 31);
|
||||
this.textBoxSender.TabIndex = 10;
|
||||
//
|
||||
// labelSender
|
||||
//
|
||||
this.labelSender.AutoSize = true;
|
||||
this.labelSender.Location = new System.Drawing.Point(5, 14);
|
||||
this.labelSender.Name = "labelSender";
|
||||
this.labelSender.Size = new System.Drawing.Size(117, 25);
|
||||
this.labelSender.TabIndex = 9;
|
||||
this.labelSender.Text = "Отправитель";
|
||||
//
|
||||
// FormMail
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(785, 455);
|
||||
this.Controls.Add(this.buttonSend);
|
||||
this.Controls.Add(this.labelReply);
|
||||
this.Controls.Add(this.textBoxReply);
|
||||
this.Controls.Add(this.textBoxBody);
|
||||
this.Controls.Add(this.labelBody);
|
||||
this.Controls.Add(this.textBoxSubject);
|
||||
this.Controls.Add(this.labelSubject);
|
||||
this.Controls.Add(this.textBoxSender);
|
||||
this.Controls.Add(this.labelSender);
|
||||
this.Name = "FormMail";
|
||||
this.Text = "Письмо";
|
||||
this.Load += new System.EventHandler(this.FormMessage_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSend;
|
||||
private Label labelReply;
|
||||
private TextBox textBoxReply;
|
||||
private TextBox textBoxBody;
|
||||
private Label labelBody;
|
||||
private TextBox textBoxSubject;
|
||||
private Label labelSubject;
|
||||
private TextBox textBoxSender;
|
||||
private Label labelSender;
|
||||
}
|
||||
}
|
113
PlumbingRepair/PlumbingRepairView/FormMail.cs
Normal file
113
PlumbingRepair/PlumbingRepairView/FormMail.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairBusinessLogic.MailWorker;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using PlumbingRepairContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PlumbingRepairView
|
||||
{
|
||||
public partial class FormMail : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
private string? _id;
|
||||
public string Id { set { _id = value; } }
|
||||
public FormMail(ILogger<FormMail> logger, IMessageInfoLogic messageInfoLogic, AbstractMailWorker abstractMailWorker, IClientLogic clientLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = messageInfoLogic;
|
||||
_clientLogic = clientLogic;
|
||||
_mailWorker = abstractMailWorker;
|
||||
}
|
||||
private void ButtonSend_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxBody.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните содержимое письма", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Отправка ответа");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new() { MessageId = _id });
|
||||
if (view != null)
|
||||
{
|
||||
var operationResult = _logic.Update(new()
|
||||
{
|
||||
MessageId = view.MessageId,
|
||||
IsRead = view.IsRead,
|
||||
ReplyText = textBoxReply.Text
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_mailWorker.MailSendAsync(new()
|
||||
{
|
||||
MailAddress = _clientLogic.ReadElement(new ClientSearchModel { Id = view.ClientId })!.Email,
|
||||
Subject = textBoxSubject.Text,
|
||||
Text = textBoxReply.Text,
|
||||
});
|
||||
MessageBox.Show("Сохранение и отправление прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void FormMessage_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_id))
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение письма");
|
||||
var view = _logic.ReadElement(new MessageInfoSearchModel
|
||||
{
|
||||
MessageId = _id
|
||||
});
|
||||
if (view == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
textBoxSender.Text = view.SenderName;
|
||||
textBoxSubject.Text = view.Subject;
|
||||
textBoxBody.Text = view.Body;
|
||||
if (!view.IsRead)
|
||||
{
|
||||
var updateResult = _logic.Update(new()
|
||||
{
|
||||
MessageId = _id,
|
||||
ReplyText = view.ReplyText,
|
||||
IsRead = true,
|
||||
});
|
||||
if (!updateResult)
|
||||
{
|
||||
throw new Exception("Ошибка при обновлении");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения письма");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
PlumbingRepair/PlumbingRepairView/FormMail.resx
Normal file
60
PlumbingRepair/PlumbingRepairView/FormMail.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -29,7 +29,12 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.panel = new System.Windows.Forms.Panel();
|
||||
this.buttonOpen = new System.Windows.Forms.Button();
|
||||
this.buttonForward = new System.Windows.Forms.Button();
|
||||
this.buttonBack = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.panel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
@ -47,19 +52,65 @@
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.RowHeadersWidth = 62;
|
||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dataGridView.Size = new System.Drawing.Size(956, 450);
|
||||
this.dataGridView.Size = new System.Drawing.Size(956, 455);
|
||||
this.dataGridView.TabIndex = 7;
|
||||
this.dataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellContentClick);
|
||||
//
|
||||
// panel
|
||||
//
|
||||
this.panel.Controls.Add(this.buttonForward);
|
||||
this.panel.Controls.Add(this.buttonBack);
|
||||
this.panel.Controls.Add(this.buttonOpen);
|
||||
this.panel.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.panel.Location = new System.Drawing.Point(773, 0);
|
||||
this.panel.Name = "panel";
|
||||
this.panel.Size = new System.Drawing.Size(183, 455);
|
||||
this.panel.TabIndex = 8;
|
||||
//
|
||||
// buttonOpen
|
||||
//
|
||||
this.buttonOpen.Location = new System.Drawing.Point(14, 12);
|
||||
this.buttonOpen.Name = "buttonOpen";
|
||||
this.buttonOpen.Size = new System.Drawing.Size(157, 34);
|
||||
this.buttonOpen.TabIndex = 0;
|
||||
this.buttonOpen.Text = "Открыть";
|
||||
this.buttonOpen.UseVisualStyleBackColor = true;
|
||||
this.buttonOpen.Click += new System.EventHandler(this.ButtonOpen_Click);
|
||||
//
|
||||
// buttonForward
|
||||
//
|
||||
this.buttonForward.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonForward.Location = new System.Drawing.Point(106, 409);
|
||||
this.buttonForward.Name = "buttonForward";
|
||||
this.buttonForward.Size = new System.Drawing.Size(65, 34);
|
||||
this.buttonForward.TabIndex = 4;
|
||||
this.buttonForward.Text = ">";
|
||||
this.buttonForward.UseVisualStyleBackColor = true;
|
||||
this.buttonForward.Click += new System.EventHandler(this.ButtonForward_Click);
|
||||
//
|
||||
// buttonBack
|
||||
//
|
||||
this.buttonBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonBack.Location = new System.Drawing.Point(14, 409);
|
||||
this.buttonBack.Name = "buttonBack";
|
||||
this.buttonBack.Size = new System.Drawing.Size(65, 34);
|
||||
this.buttonBack.TabIndex = 3;
|
||||
this.buttonBack.Text = "<";
|
||||
this.buttonBack.UseVisualStyleBackColor = true;
|
||||
this.buttonBack.Click += new System.EventHandler(this.ButtonBack_Click);
|
||||
//
|
||||
// FormMails
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(956, 450);
|
||||
this.ClientSize = new System.Drawing.Size(956, 455);
|
||||
this.Controls.Add(this.panel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormMails";
|
||||
this.Text = "Письма";
|
||||
this.Load += new System.EventHandler(this.FormMails_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.panel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -67,5 +118,9 @@
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel panel;
|
||||
private Button buttonForward;
|
||||
private Button buttonBack;
|
||||
private Button buttonOpen;
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ namespace PlumbingRepairView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private readonly int pageSize = 5;
|
||||
private int pageNumber = 0;
|
||||
public FormMails(ILogger<FormMails> logger, IMessageInfoLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -14,26 +16,59 @@ namespace PlumbingRepairView
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormMails_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData(0);
|
||||
}
|
||||
private void LoadData(int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
var list = _logic.ReadList(new() { Page = page, PageSize = pageSize });
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["MessageId"].Visible = false;
|
||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Loading mails");
|
||||
_logger.LogInformation("Загрузка сообщений");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error during loading mails");
|
||||
_logger.LogError(ex, "Ошибка загрузки сообщений");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonBack_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (pageNumber != 0)
|
||||
{
|
||||
pageNumber--;
|
||||
}
|
||||
LoadData(pageNumber);
|
||||
}
|
||||
private void ButtonForward_Click(object sender, EventArgs e)
|
||||
{
|
||||
pageNumber++;
|
||||
LoadData(pageNumber);
|
||||
}
|
||||
private void ButtonOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMail));
|
||||
if (service is FormMail form)
|
||||
{
|
||||
form.Id = dataGridView.SelectedRows[0].Cells["MessageId"].Value.ToString();
|
||||
form.ShowDialog();
|
||||
LoadData(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
121
PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
generated
121
PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs
generated
@ -36,29 +36,21 @@
|
||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.РаботыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
<<<<<<< HEAD
|
||||
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.пToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.продажаРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
=======
|
||||
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
>>>>>>> lab_7
|
||||
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.компонентыПоРаботамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
<<<<<<< HEAD
|
||||
this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.работыПоМагазинамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.выполнениеРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.списокВсехЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.выполнениеРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
=======
|
||||
this.выполнениеРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
>>>>>>> lab_7
|
||||
this.письмаToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -66,11 +58,7 @@
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
<<<<<<< HEAD
|
||||
this.buttonRef.Location = new System.Drawing.Point(1113, 227);
|
||||
=======
|
||||
this.buttonRef.Location = new System.Drawing.Point(1284, 219);
|
||||
>>>>>>> lab_7
|
||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(249, 45);
|
||||
@ -82,11 +70,7 @@
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
this.buttonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
<<<<<<< HEAD
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(1113, 151);
|
||||
=======
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(1284, 143);
|
||||
>>>>>>> lab_7
|
||||
this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(249, 45);
|
||||
@ -98,11 +82,7 @@
|
||||
// buttonCreateOrder
|
||||
//
|
||||
this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
<<<<<<< HEAD
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(1113, 83);
|
||||
=======
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(1284, 83);
|
||||
>>>>>>> lab_7
|
||||
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
this.buttonCreateOrder.Size = new System.Drawing.Size(249, 45);
|
||||
@ -128,11 +108,7 @@
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.RowHeadersWidth = 62;
|
||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
<<<<<<< HEAD
|
||||
this.dataGridView.Size = new System.Drawing.Size(1055, 533);
|
||||
=======
|
||||
this.dataGridView.Size = new System.Drawing.Size(1226, 533);
|
||||
>>>>>>> lab_7
|
||||
this.dataGridView.TabIndex = 6;
|
||||
//
|
||||
// menuStrip1
|
||||
@ -141,18 +117,11 @@
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.справочникиToolStripMenuItem,
|
||||
this.отчетыToolStripMenuItem,
|
||||
<<<<<<< HEAD
|
||||
this.выполнениеРаботToolStripMenuItem});
|
||||
this.выполнениеРаботToolStripMenuItem,
|
||||
this.письмаToolStripMenuItem1});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(1377, 33);
|
||||
=======
|
||||
this.выполнениеРаботToolStripMenuItem,
|
||||
this.письмаToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(1548, 33);
|
||||
>>>>>>> lab_7
|
||||
this.menuStrip1.TabIndex = 12;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
@ -173,18 +142,13 @@
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
<<<<<<< HEAD
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(296, 34);
|
||||
=======
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
>>>>>>> lab_7
|
||||
this.компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||
//
|
||||
// РаботыToolStripMenuItem
|
||||
//
|
||||
this.РаботыToolStripMenuItem.Name = "РаботыToolStripMenuItem";
|
||||
<<<<<<< HEAD
|
||||
this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(296, 34);
|
||||
this.РаботыToolStripMenuItem.Text = "Работы";
|
||||
this.РаботыToolStripMenuItem.Click += new System.EventHandler(this.РаботыToolStripMenuItem_Click);
|
||||
@ -217,39 +181,21 @@
|
||||
this.клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
|
||||
//
|
||||
=======
|
||||
this.РаботыToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.РаботыToolStripMenuItem.Text = "Работы";
|
||||
this.РаботыToolStripMenuItem.Click += new System.EventHandler(this.РаботыToolStripMenuItem_Click);
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
|
||||
//
|
||||
// исполнителиToolStripMenuItem
|
||||
//
|
||||
this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(296, 34);
|
||||
this.исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click);
|
||||
//
|
||||
>>>>>>> lab_7
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.списокКомпонентовToolStripMenuItem,
|
||||
this.компонентыПоРаботамToolStripMenuItem,
|
||||
<<<<<<< HEAD
|
||||
this.списокЗаказовToolStripMenuItem,
|
||||
this.списокМагазиновToolStripMenuItem,
|
||||
this.работыПоМагазинамToolStripMenuItem,
|
||||
this.списокВсехЗаказовToolStripMenuItem});
|
||||
=======
|
||||
this.списокЗаказовToolStripMenuItem});
|
||||
>>>>>>> lab_7
|
||||
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(88, 29);
|
||||
this.отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
@ -259,28 +205,14 @@
|
||||
this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
|
||||
this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(319, 34);
|
||||
this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
|
||||
<<<<<<< HEAD
|
||||
this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.списокКомпонентовToolStripMenuItem_Click);
|
||||
=======
|
||||
this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||
>>>>>>> lab_7
|
||||
//
|
||||
// компонентыПоРаботамToolStripMenuItem
|
||||
//
|
||||
this.компонентыПоРаботамToolStripMenuItem.Name = "компонентыПоРаботамToolStripMenuItem";
|
||||
this.компонентыПоРаботамToolStripMenuItem.Size = new System.Drawing.Size(319, 34);
|
||||
this.компонентыПоРаботамToolStripMenuItem.Text = "Компоненты по работам";
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
this.компонентыПоРаботамToolStripMenuItem.Click += new System.EventHandler(this.ComponentWorksToolStripMenuItem_Click);
|
||||
>>>>>>> lab_7
|
||||
//
|
||||
// списокЗаказовToolStripMenuItem
|
||||
//
|
||||
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
||||
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(319, 34);
|
||||
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
<<<<<<< HEAD
|
||||
//
|
||||
// списокМагазиновToolStripMenuItem
|
||||
//
|
||||
@ -296,32 +228,26 @@
|
||||
this.работыПоМагазинамToolStripMenuItem.Text = "Работы по магазинам";
|
||||
this.работыПоМагазинамToolStripMenuItem.Click += new System.EventHandler(this.ShopWorksToolStripMenuItem_Click);
|
||||
//
|
||||
// списокВсехЗаказовToolStripMenuItem
|
||||
// списокЗаказовToolStripMenuItem
|
||||
//
|
||||
this.списокВсехЗаказовToolStripMenuItem.Name = "списокВсехЗаказовToolStripMenuItem";
|
||||
this.списокВсехЗаказовToolStripMenuItem.Size = new System.Drawing.Size(319, 34);
|
||||
this.списокВсехЗаказовToolStripMenuItem.Text = "Список всех заказов";
|
||||
this.списокВсехЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersByDateToolStripMenuItem_Click);
|
||||
=======
|
||||
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
||||
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(319, 34);
|
||||
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
|
||||
>>>>>>> lab_7
|
||||
//
|
||||
// выполнениеРаботToolStripMenuItem
|
||||
//
|
||||
this.выполнениеРаботToolStripMenuItem.Name = "выполнениеРаботToolStripMenuItem";
|
||||
this.выполнениеРаботToolStripMenuItem.Size = new System.Drawing.Size(136, 29);
|
||||
this.выполнениеРаботToolStripMenuItem.Text = "Запуск работ";
|
||||
<<<<<<< HEAD
|
||||
this.выполнениеРаботToolStripMenuItem.Click += new System.EventHandler(this.выполнениеРаботToolStripMenuItem_Click);
|
||||
//
|
||||
// исполнителиToolStripMenuItem
|
||||
// списокВсехЗаказовToolStripMenuItem
|
||||
//
|
||||
this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(296, 34);
|
||||
this.исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click);
|
||||
=======
|
||||
this.выполнениеРаботToolStripMenuItem.Click += new System.EventHandler(this.ЗапускРаботToolStripMenuItem_Click);
|
||||
this.списокВсехЗаказовToolStripMenuItem.Name = "списокВсехЗаказовToolStripMenuItem";
|
||||
this.списокВсехЗаказовToolStripMenuItem.Size = new System.Drawing.Size(319, 34);
|
||||
this.списокВсехЗаказовToolStripMenuItem.Text = "Список всех заказов";
|
||||
this.списокВсехЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersByDateToolStripMenuItem_Click);
|
||||
//
|
||||
// письмаToolStripMenuItem
|
||||
//
|
||||
@ -329,17 +255,19 @@
|
||||
this.письмаToolStripMenuItem.Size = new System.Drawing.Size(90, 29);
|
||||
this.письмаToolStripMenuItem.Text = "Письма";
|
||||
this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click);
|
||||
>>>>>>> lab_7
|
||||
//
|
||||
// письмаToolStripMenuItem1
|
||||
//
|
||||
this.письмаToolStripMenuItem1.Name = "письмаToolStripMenuItem1";
|
||||
this.письмаToolStripMenuItem1.Size = new System.Drawing.Size(90, 29);
|
||||
this.письмаToolStripMenuItem1.Text = "Письма";
|
||||
this.письмаToolStripMenuItem1.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
<<<<<<< HEAD
|
||||
this.ClientSize = new System.Drawing.Size(1377, 602);
|
||||
=======
|
||||
this.ClientSize = new System.Drawing.Size(1548, 602);
|
||||
>>>>>>> lab_7
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonIssuedOrder);
|
||||
this.Controls.Add(this.buttonCreateOrder);
|
||||
@ -379,11 +307,8 @@
|
||||
private ToolStripMenuItem списокВсехЗаказовToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem выполнениеРаботToolStripMenuItem;
|
||||
<<<<<<< HEAD
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
=======
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripMenuItem письмаToolStripMenuItem;
|
||||
>>>>>>> lab_7
|
||||
private ToolStripMenuItem письмаToolStripMenuItem1;
|
||||
}
|
||||
}
|
@ -216,18 +216,19 @@ namespace PlumbingRepairView
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
if (service is FormImplementers form)
|
||||
=======
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
|
||||
if (service is FormMails form)
|
||||
>>>>>>> lab_7
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ namespace PlumbingRepairView
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormMails>();
|
||||
services.AddTransient<FormMail>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user