diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/MessageInfoLogic.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/MessageInfoLogic.cs index f158cef..3ddb42b 100644 --- a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/MessageInfoLogic.cs +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/MessageInfoLogic.cs @@ -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; + } - - - } + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs index f3d64c7..8d33d6e 100644 --- a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/OrderLogic.cs @@ -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,15 +19,19 @@ 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 logger, IOrderStorage orderStorage, IShopStorage shopStorage, IWorkStorage workStorage, IShopLogic shopLogic) + public OrderLogic(ILogger 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,14 +56,20 @@ 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; } - return true; + var orderView = _orderStorage.GetElement(new() { Id = result.Id }); + var clientView = _clientStorage.GetElement(new() { Id = orderView!.ClientId }); + + SendEmail(clientView, orderView); + return true; } public bool DeliveryOrder(OrderBindingModel model) @@ -132,9 +143,49 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics } _orderStorage.Update(model); - return true; + 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; + } - private void CheckModel(OrderBindingModel model, bool withParams = 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); } } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/BindingModels/MessageInfoBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/MessageInfoBindingModel.cs index bcc5cfb..a59c4ea 100644 --- a/PlumbingRepair/PlumbingRepairContracts/BindingModels/MessageInfoBindingModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/MessageInfoBindingModel.cs @@ -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; + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IMessageInfoLogic.cs b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IMessageInfoLogic.cs index 20ff0f2..7029bdd 100644 --- a/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IMessageInfoLogic.cs +++ b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IMessageInfoLogic.cs @@ -8,5 +8,7 @@ namespace PlumbingRepairContracts.BusinessLogicsContracts { List? ReadList(MessageInfoSearchModel? model); bool Create(MessageInfoBindingModel model); - } + MessageInfoViewModel? ReadElement(MessageInfoSearchModel? model); + bool Update(MessageInfoBindingModel model); + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/SearchModels/ImplementerSearchModel - Копировать.cs b/PlumbingRepair/PlumbingRepairContracts/SearchModels/MessageInfoStorage.cs similarity index 71% rename from PlumbingRepair/PlumbingRepairContracts/SearchModels/ImplementerSearchModel - Копировать.cs rename to PlumbingRepair/PlumbingRepairContracts/SearchModels/MessageInfoStorage.cs index 99817dc..116d7c7 100644 --- a/PlumbingRepair/PlumbingRepairContracts/SearchModels/ImplementerSearchModel - Копировать.cs +++ b/PlumbingRepair/PlumbingRepairContracts/SearchModels/MessageInfoStorage.cs @@ -5,5 +5,7 @@ public int? ClientId { get; set; } public string? MessageId { get; set; } - } + public int? Page { get; set; } + public int? PageSize { get; set; } + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IMessageInfoStorage.cs b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IMessageInfoStorage.cs index 53e679d..0bbead6 100644 --- a/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IMessageInfoStorage.cs +++ b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IMessageInfoStorage.cs @@ -10,5 +10,6 @@ namespace PlumbingRepairContracts.StoragesContracts List GetFilteredList(MessageInfoSearchModel model); MessageInfoViewModel? GetElement(MessageInfoSearchModel model); MessageInfoViewModel? Insert(MessageInfoBindingModel model); - } + MessageInfoViewModel? Update(MessageInfoBindingModel model); + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/MessageInfoViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/MessageInfoViewModel.cs index 1f2a35c..61d3380 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/MessageInfoViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/MessageInfoViewModel.cs @@ -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; } + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairDataModels/Models/IMessageInfoModel.cs b/PlumbingRepair/PlumbingRepairDataModels/Models/IMessageInfoModel.cs index 2c512f1..b5bde4b 100644 --- a/PlumbingRepair/PlumbingRepairDataModels/Models/IMessageInfoModel.cs +++ b/PlumbingRepair/PlumbingRepairDataModels/Models/IMessageInfoModel.cs @@ -9,5 +9,7 @@ namespace PlumbingRepairDataModels.Models DateTime DateDelivery { get; } string Subject { get; } string Body { get; } - } + bool IsRead { get; } + string? ReplyText { get; } + } } diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/MessageInfoStorage.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/MessageInfoStorage.cs index 83f07f9..72921c6 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/MessageInfoStorage.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/MessageInfoStorage.cs @@ -19,11 +19,25 @@ namespace PlumbingRepairDatabaseImplement.Implements public List GetFilteredList(MessageInfoSearchModel model) { using var context = new PlumbingRepairDatabase(); - return context.Messages - .Where(x => x.ClientId.HasValue && x.ClientId == model.ClientId) - .Select(x => x.GetViewModel) - .ToList(); - } + if (model.ClientId.HasValue && model.Page.HasValue && model.PageSize.HasValue) + { + return context.Messages + .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; + } + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs index a5193ad..ceca058 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Implements/OrderStorage.cs @@ -55,47 +55,13 @@ 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) { return context.Orders - .Include(x => x.Work) - .Include(x => x.Implementer) - .Include(x => x.Client) + .Include(x => x.Work) + .Include(x => x.Implementer) + .Include(x => x.Client) .Where(x => x.Id == model.Id) .Select(x => AttachNames(x.GetViewModel)).ToList(); } @@ -139,6 +105,9 @@ namespace PlumbingRepairDatabaseImplement.Implements } return new(); + + + } public List GetFullList() diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.cs deleted file mode 100644 index 1921f94..0000000 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.cs +++ /dev/null @@ -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(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Clients", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Components", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ComponentName = table.Column(type: "nvarchar(max)", nullable: false), - Cost = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Components", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Implementers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false), - WorkExperience = table.Column(type: "int", nullable: false), - Qualification = table.Column(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(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ShopName = table.Column(type: "nvarchar(max)", nullable: false), - Address = table.Column(type: "nvarchar(max)", nullable: false), - DateOpening = table.Column(type: "datetime2", nullable: false), - maxCountWorks = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Shops", x => x.Id); -======== - name: "Messages", - columns: table => new - { - MessageId = table.Column(type: "nvarchar(450)", nullable: false), - ClientId = table.Column(type: "int", nullable: true), - SenderName = table.Column(type: "nvarchar(max)", nullable: false), - DateDelivery = table.Column(type: "datetime2", nullable: false), - Subject = table.Column(type: "nvarchar(max)", nullable: false), - Body = table.Column(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(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - WorkName = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Works", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - WorkId = table.Column(type: "int", nullable: false), - ClientId = table.Column(type: "int", nullable: false), - ImplementerId = table.Column(type: "int", nullable: true), - Count = table.Column(type: "int", nullable: false), - Sum = table.Column(type: "float", nullable: false), - Status = table.Column(type: "int", nullable: false), - DateCreate = table.Column(type: "datetime2", nullable: false), - DateImplement = table.Column(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(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - WorkId = table.Column(type: "int", nullable: false), - ShopId = table.Column(type: "int", nullable: false), - Count = table.Column(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(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - WorkId = table.Column(type: "int", nullable: false), - ComponentId = table.Column(type: "int", nullable: false), - Count = table.Column(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"); - } - } -} diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.Designer.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.Designer.cs deleted file mode 100644 index db03220..0000000 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.Designer.cs +++ /dev/null @@ -1,366 +0,0 @@ -// -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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ImplementerFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Qualification") - .HasColumnType("int"); - - b.Property("WorkExperience") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Implementers"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.MessageInfo", b => - { - b.Property("MessageId") - .HasColumnType("nvarchar(450)"); - - b.Property("Body") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateDelivery") - .HasColumnType("datetime2"); - - b.Property("SenderName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Subject") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("MessageId"); - - b.ToTable("Messages"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("ImplementerId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("DateOpening") - .HasColumnType("datetime2"); - - b.Property("ShopName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("maxCountWorks") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Shops"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.ShopWork", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("ShopId") - .HasColumnType("int"); - - b.Property("WorkId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ShopId"); - - b.HasIndex("WorkId"); - - b.ToTable("ShopWorks"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("WorkName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Works"); - }); - - modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("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 - } - } -} diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.Designer.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240515153909_InitCreate.Designer.cs similarity index 97% rename from PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.Designer.cs rename to PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240515153909_InitCreate.Designer.cs index db03220..701adcf 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.Designer.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240515153909_InitCreate.Designer.cs @@ -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("DateDelivery") .HasColumnType("datetime2"); + b.Property("IsRead") + .HasColumnType("bit"); + + b.Property("ReplyText") + .HasColumnType("nvarchar(max)"); + b.Property("SenderName") .IsRequired() .HasColumnType("nvarchar(max)"); diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240515153909_InitCreate.cs similarity index 97% rename from PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.cs rename to PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240515153909_InitCreate.cs index 1921f94..0037ed3 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503121400_initCreate.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240515153909_InitCreate.cs @@ -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(type: "nvarchar(450)", nullable: false), + ClientId = table.Column(type: "int", nullable: true), + SenderName = table.Column(type: "nvarchar(max)", nullable: false), + DateDelivery = table.Column(type: "datetime2", nullable: false), + Subject = table.Column(type: "nvarchar(max)", nullable: false), + Body = table.Column(type: "nvarchar(max)", nullable: false), + IsRead = table.Column(type: "bit", nullable: false), + ReplyText = table.Column(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(type: "nvarchar(450)", nullable: false), - ClientId = table.Column(type: "int", nullable: true), - SenderName = table.Column(type: "nvarchar(max)", nullable: false), - DateDelivery = table.Column(type: "datetime2", nullable: false), - Subject = table.Column(type: "nvarchar(max)", nullable: false), - Body = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Messages", x => x.MessageId); ->>>>>>>> lab_7:PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/20240503110424_InitCreate.cs }); migrationBuilder.CreateTable( diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs index 5c1c592..122b902 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Migrations/PlumbingRepairDatabaseModelSnapshot.cs @@ -109,6 +109,12 @@ namespace PlumbingRepairDatabaseImplement.Migrations b.Property("DateDelivery") .HasColumnType("datetime2"); + b.Property("IsRead") + .HasColumnType("bit"); + + b.Property("ReplyText") + .HasColumnType("nvarchar(max)"); + b.Property("SenderName") .IsRequired() .HasColumnType("nvarchar(max)"); diff --git a/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/MessageInfo.cs b/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/MessageInfo.cs index b4d86cd..599abbe 100644 --- a/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/MessageInfo.cs +++ b/PlumbingRepair/PlumbingRepairDatabaseImplement/Models/MessageInfo.cs @@ -19,8 +19,11 @@ 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) + public static MessageInfo? Create(MessageInfoBindingModel model) { if (model == null) { @@ -36,7 +39,12 @@ namespace PlumbingRepairDatabaseImplement.Models Body = model.Body }; } - public MessageInfoViewModel GetViewModel => new() + public void Update(MessageInfoBindingModel model) + { + IsRead = model.IsRead; + ReplyText = model.ReplyText; + } + public MessageInfoViewModel GetViewModel => new() { Body = Body, Subject = Subject, @@ -44,6 +52,8 @@ namespace PlumbingRepairDatabaseImplement.Models MessageId = MessageId, SenderName = SenderName, DateDelivery = DateDelivery, - }; + IsRead = IsRead, + ReplyText = ReplyText + }; } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Implements/MessageInfo.cs b/PlumbingRepair/PlumbingRepairFileImplement/Implements/MessageInfoStorage.cs similarity index 75% rename from PlumbingRepair/PlumbingRepairFileImplement/Implements/MessageInfo.cs rename to PlumbingRepair/PlumbingRepairFileImplement/Implements/MessageInfoStorage.cs index e424866..f8aabed 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Implements/MessageInfo.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Implements/MessageInfoStorage.cs @@ -24,11 +24,16 @@ namespace PlumbingRepairFileImplement.Implements public List 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; + } + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Models/MessageInfo.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/MessageInfo.cs index 0a2e934..39c34ef 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Models/MessageInfo.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/MessageInfo.cs @@ -18,8 +18,10 @@ 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) + public static MessageInfo? Create(MessageInfoBindingModel model) { if (model == null) { @@ -53,9 +55,13 @@ namespace PlumbingRepairFileImplement.Models }; } + public void Update(MessageInfoBindingModel model) + { + IsRead = model.IsRead; + ReplyText = model.ReplyText; + } - - public MessageInfoViewModel GetViewModel => new() + public MessageInfoViewModel GetViewModel => new() { Body = Body, Subject = Subject, @@ -63,7 +69,9 @@ namespace PlumbingRepairFileImplement.Models MessageId = MessageId, SenderName = SenderName, DateDelivery = DateDelivery, - }; + IsRead = IsRead, + ReplyText = ReplyText + }; public XElement GetXElement => new("MessageInfo", new XAttribute("Body", Body), @@ -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) ); } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairListImplement/Implements/MessageInfoStorage.cs b/PlumbingRepair/PlumbingRepairListImplement/Implements/MessageInfoStorage.cs index 531fc0a..36e1486 100644 --- a/PlumbingRepair/PlumbingRepairListImplement/Implements/MessageInfoStorage.cs +++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/MessageInfoStorage.cs @@ -37,8 +37,21 @@ namespace PlumbingRepairListImplement.Implements } } - return result; - } + if (!(model.Page.HasValue && model.PageSize.HasValue)) + { + return result; + } + if (model.Page * model.PageSize >= result.Count) + { + return null; + } + List 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 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; + } + } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairListImplement/Models/MessageInfo.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/MessageInfo.cs index f4129c9..31c55c7 100644 --- a/PlumbingRepair/PlumbingRepairListImplement/Models/MessageInfo.cs +++ b/PlumbingRepair/PlumbingRepairListImplement/Models/MessageInfo.cs @@ -17,8 +17,10 @@ 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) + public static MessageInfo? Create(MessageInfoBindingModel model) { if (model == null) { @@ -35,8 +37,12 @@ namespace PlumbingRepairListImplement.Models DateDelivery = model.DateDelivery, }; } - - public MessageInfoViewModel GetViewModel => new() + public void Update(MessageInfoBindingModel model) + { + IsRead = model.IsRead; + ReplyText = model.ReplyText; + } + public MessageInfoViewModel GetViewModel => new() { Body = Body, Subject = Subject, @@ -44,6 +50,8 @@ namespace PlumbingRepairListImplement.Models MessageId = MessageId, SenderName = SenderName, DateDelivery = DateDelivery, - }; + IsRead = IsRead, + ReplyText = ReplyText + }; } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairRestApi/Controllers/ClientController.cs b/PlumbingRepair/PlumbingRepairRestApi/Controllers/ClientController.cs index e1b84f2..0804bd1 100644 --- a/PlumbingRepair/PlumbingRepairRestApi/Controllers/ClientController.cs +++ b/PlumbingRepair/PlumbingRepairRestApi/Controllers/ClientController.cs @@ -67,14 +67,16 @@ namespace AbstractShopRestApi.Controllers } } [HttpGet] - public List? GetMessages(int clientId) + public List? GetMessages(int clientId, int page) { try { return _mailLogic.ReadList(new MessageInfoSearchModel { - ClientId = clientId - }); + ClientId = clientId, + Page = page, + PageSize = 5 + }); } catch (Exception ex) { diff --git a/PlumbingRepair/PlumbingRepairRestApi/Program.cs b/PlumbingRepair/PlumbingRepairRestApi/Program.cs index 469267f..fb62258 100644 --- a/PlumbingRepair/PlumbingRepairRestApi/Program.cs +++ b/PlumbingRepair/PlumbingRepairRestApi/Program.cs @@ -26,7 +26,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddTransient(); +builder.Services.AddSingleton(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/PlumbingRepair/PlumbingRepairView/FormMail.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormMail.Designer.cs new file mode 100644 index 0000000..63fe023 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormMail.Designer.cs @@ -0,0 +1,152 @@ +namespace PlumbingRepairView +{ + partial class FormMail + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormMail.cs b/PlumbingRepair/PlumbingRepairView/FormMail.cs new file mode 100644 index 0000000..208c10d --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormMail.cs @@ -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 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); + } + } + } + } +} diff --git a/PlumbingRepair/PlumbingRepairView/FormMail.resx b/PlumbingRepair/PlumbingRepairView/FormMail.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PlumbingRepair/PlumbingRepairView/FormMail.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormMails.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormMails.Designer.cs index 8f03fc3..4fd309e 100644 --- a/PlumbingRepair/PlumbingRepairView/FormMails.Designer.cs +++ b/PlumbingRepair/PlumbingRepairView/FormMails.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormMails.cs b/PlumbingRepair/PlumbingRepairView/FormMails.cs index 719feec..fc4eb9b 100644 --- a/PlumbingRepair/PlumbingRepairView/FormMails.cs +++ b/PlumbingRepair/PlumbingRepairView/FormMails.cs @@ -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 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) + { + + } } } diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs index 4ff5737..6813d9d 100644 --- a/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs +++ b/PlumbingRepair/PlumbingRepairView/FormMain.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairView/FormMain.cs b/PlumbingRepair/PlumbingRepairView/FormMain.cs index 87f4145..78f57d7 100644 --- a/PlumbingRepair/PlumbingRepairView/FormMain.cs +++ b/PlumbingRepair/PlumbingRepairView/FormMain.cs @@ -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(); } diff --git a/PlumbingRepair/PlumbingRepairView/Program.cs b/PlumbingRepair/PlumbingRepairView/Program.cs index d8e04ef..5171eee 100644 --- a/PlumbingRepair/PlumbingRepairView/Program.cs +++ b/PlumbingRepair/PlumbingRepairView/Program.cs @@ -105,6 +105,7 @@ namespace PlumbingRepairView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file