diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.Designer.cs new file mode 100644 index 0000000..762ca6d --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.Designer.cs @@ -0,0 +1,140 @@ +namespace BlacksmithWorkshop +{ + partial class FormAnswerMail + { + /// + /// 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() + { + buttonSave = new Button(); + buttonCancel = new Button(); + textBoxHead = new TextBox(); + textBoxBody = new TextBox(); + labelHead = new Label(); + labelBody = new Label(); + labelAnswer = new Label(); + textBoxAnswer = new TextBox(); + SuspendLayout(); + // + // buttonSave + // + buttonSave.Location = new Point(203, 227); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(125, 29); + buttonSave.TabIndex = 0; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(350, 227); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(123, 29); + buttonCancel.TabIndex = 1; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // textBoxHead + // + textBoxHead.Location = new Point(151, 34); + textBoxHead.Name = "textBoxHead"; + textBoxHead.Size = new Size(322, 27); + textBoxHead.TabIndex = 2; + // + // textBoxBody + // + textBoxBody.Location = new Point(151, 98); + textBoxBody.Name = "textBoxBody"; + textBoxBody.Size = new Size(322, 27); + textBoxBody.TabIndex = 3; + // + // labelHead + // + labelHead.AutoSize = true; + labelHead.Location = new Point(30, 37); + labelHead.Name = "labelHead"; + labelHead.Size = new Size(84, 20); + labelHead.TabIndex = 4; + labelHead.Text = "Заголовок:"; + // + // labelBody + // + labelBody.AutoSize = true; + labelBody.Location = new Point(30, 101); + labelBody.Name = "labelBody"; + labelBody.Size = new Size(94, 20); + labelBody.TabIndex = 5; + labelBody.Text = "Сообщение:"; + // + // labelAnswer + // + labelAnswer.AutoSize = true; + labelAnswer.Location = new Point(30, 163); + labelAnswer.Name = "labelAnswer"; + labelAnswer.Size = new Size(51, 20); + labelAnswer.TabIndex = 6; + labelAnswer.Text = "Ответ:"; + // + // textBoxAnswer + // + textBoxAnswer.Location = new Point(151, 160); + textBoxAnswer.Name = "textBoxAnswer"; + textBoxAnswer.Size = new Size(322, 27); + textBoxAnswer.TabIndex = 7; + // + // FormAnswerMail + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(512, 284); + Controls.Add(textBoxAnswer); + Controls.Add(labelAnswer); + Controls.Add(labelBody); + Controls.Add(labelHead); + Controls.Add(textBoxBody); + Controls.Add(textBoxHead); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Name = "FormAnswerMail"; + Text = "Просмотр письма"; + Load += FormAnswerMail_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonSave; + private Button buttonCancel; + private TextBox textBoxHead; + private TextBox textBoxBody; + private Label labelHead; + private Label labelBody; + private Label labelAnswer; + private TextBox textBoxAnswer; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.cs new file mode 100644 index 0000000..354e1fd --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.cs @@ -0,0 +1,98 @@ +using BlacksmithWorkshopBusinessLogic.MailWorker; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using Microsoft.Extensions.Logging; +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 BlacksmithWorkshop +{ + public partial class FormAnswerMail : Form + { + private readonly ILogger _logger; + + private readonly IMessageInfoLogic _logic; + + private readonly AbstractMailWorker _mailWorker; + + private MessageInfoViewModel _message; + + public string MessageId { get; set; } = string.Empty; + + public FormAnswerMail(ILogger logger, AbstractMailWorker mailWorker, IMessageInfoLogic logic) + { + InitializeComponent(); + + _logger = logger; + _mailWorker = mailWorker; + _logic = logic; + } + + private void FormAnswerMail_Load(object sender, EventArgs e) + { + try + { + _logger.LogInformation("Получение письма"); + + _message = _logic.ReadElement(new MessageInfoSearchModel { MessageId = MessageId }); + + if (_message != null) + { + Text += $"для {_message.SenderName}"; + + textBoxHead.Text = _message.Subject; + + textBoxBody.Text = _message.Body; + } + + if (_message.IsRead is false) + { + _logic.Update(new() { MessageId = MessageId, IsRead = true, Answer = _message.Answer }); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения письма"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + //отправка письма с ответом + _mailWorker.MailSendAsync(new() + { + MailAddress = _message.SenderName, + Subject = _message.Subject, + Text = textBoxAnswer.Text, + }); + + _logic.Update(new() + { + MessageId = MessageId, + Answer = textBoxAnswer.Text, + IsRead = true, + }); + + MessageBox.Show("Успешная отправка письма", "Отправка письма", MessageBoxButtons.OK); + + DialogResult = DialogResult.OK; + Close(); + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormAnswerMail.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/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.Designer.cs index 222453c..0d13cf6 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.Designer.cs @@ -31,23 +31,23 @@ dataGridView = new DataGridView(); buttonForward = new Button(); buttonBack = new Button(); + buttonAnswer = new Button(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Top; - dataGridView.Location = new Point(0, 0); + dataGridView.Location = new Point(12, 12); dataGridView.Name = "dataGridView"; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(800, 393); + dataGridView.Size = new Size(781, 393); dataGridView.TabIndex = 0; // // buttonForward // - buttonForward.Location = new Point(156, 409); + buttonForward.Location = new Point(155, 416); buttonForward.Name = "buttonForward"; buttonForward.Size = new Size(175, 29); buttonForward.TabIndex = 1; @@ -57,7 +57,7 @@ // // buttonBack // - buttonBack.Location = new Point(466, 409); + buttonBack.Location = new Point(468, 416); buttonBack.Name = "buttonBack"; buttonBack.Size = new Size(173, 29); buttonBack.TabIndex = 2; @@ -65,11 +65,22 @@ buttonBack.UseVisualStyleBackColor = true; buttonBack.Click += ButtonBack_Click; // + // buttonAnswer + // + buttonAnswer.Location = new Point(806, 34); + buttonAnswer.Name = "buttonAnswer"; + buttonAnswer.Size = new Size(136, 29); + buttonAnswer.TabIndex = 3; + buttonAnswer.Text = "Ответить"; + buttonAnswer.UseVisualStyleBackColor = true; + buttonAnswer.Click += ButtonAnswer_Click; + // // FormMails // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(963, 457); + Controls.Add(buttonAnswer); Controls.Add(buttonBack); Controls.Add(buttonForward); Controls.Add(dataGridView); @@ -85,5 +96,6 @@ private DataGridView dataGridView; private Button buttonForward; private Button buttonBack; + private Button buttonAnswer; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.cs index 5032b9f..b549e2a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.cs @@ -78,19 +78,40 @@ namespace BlacksmithWorkshop private void ButtonForward_Click(object sender, EventArgs e) { - numberPaginationPage += 1; + if (dataGridView.Rows.Count == paginationSize) + { + numberPaginationPage += 1; + } LoadData(); } private void ButtonBack_Click(object sender, EventArgs e) { - if(numberPaginationPage > 1) + if (numberPaginationPage > 1) { numberPaginationPage -= 1; } LoadData(); } + + private void ButtonAnswer_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormAnswerMail)); + + if (service is FormAnswerMail form) + { + form.MessageId = dataGridView.SelectedRows[0].Cells["MessageId"].Value.ToString(); + + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index d7d49d5..3c8bc08 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -109,6 +109,7 @@ namespace BlacksmithWorkshop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck(); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/MessageInfoLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/MessageInfoLogic.cs index ddbc554..6754c09 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/MessageInfoLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/MessageInfoLogic.cs @@ -42,7 +42,30 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic return list.OrderByDescending(x => x.DateDelivery).ToList(); } - public bool Create(MessageInfoBindingModel model) + MessageInfoViewModel? IMessageInfoLogic.ReadElement(MessageInfoSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadList. ClientId:{ClientId}. MessageId:{MessageId}", model.ClientId, model?.MessageId); + + var element = _messageInfoStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.MessageId); + + return element; + } + + public bool Create(MessageInfoBindingModel model) { if (_messageInfoStorage.Insert(model) == null) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IMessageInfoLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IMessageInfoLogic.cs index ada2410..68fdd7e 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IMessageInfoLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IMessageInfoLogic.cs @@ -13,7 +13,9 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts { List? ReadList(MessageInfoSearchModel? model); - bool Create(MessageInfoBindingModel model); + MessageInfoViewModel? ReadElement(MessageInfoSearchModel model); + + bool Create(MessageInfoBindingModel model); bool Update(MessageInfoBindingModel model); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs index b463461..600c7e9 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs @@ -14,8 +14,6 @@ namespace BlacksmithWorkshopContracts.ViewModels public int? ClientId { get; set; } - public bool IsRead { get; set; } = false; - [DisplayName("Отправитель")] public string SenderName { get; set; } = string.Empty; @@ -29,7 +27,7 @@ namespace BlacksmithWorkshopContracts.ViewModels public string Body { get; set; } = string.Empty; [DisplayName("Прочитано")] - public string statusChecking { get; set; } = string.Empty; + public bool IsRead { get; set; } = false; [DisplayName("Ответ")] public string? Answer { get; set; } = string.Empty; diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230430151520_LabWork07Hard.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230430151520_LabWork07Hard.Designer.cs new file mode 100644 index 0000000..266e24c --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230430151520_LabWork07Hard.Designer.cs @@ -0,0 +1,383 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230430151520_LabWork07Hard")] + partial class LabWork07Hard + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + 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("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + 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("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b => + { + b.Property("MessageId") + .HasColumnType("nvarchar(450)"); + + b.Property("Answer") + .HasColumnType("nvarchar(max)"); + + b.Property("Body") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("DateDelivery") + .HasColumnType("datetime2"); + + b.Property("IsRead") + .HasColumnType("bit"); + + b.Property("SenderName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MessageId"); + + b.HasIndex("ClientId"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + 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("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("MaxCountManufactures") + .HasColumnType("int"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopManufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("MessageInfos") + .HasForeignKey("ClientId"); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Shops") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Manufactures") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("Shop"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("MessageInfos"); + + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("Shops"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230430151520_LabWork07Hard.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230430151520_LabWork07Hard.cs new file mode 100644 index 0000000..2dd7fcc --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230430151520_LabWork07Hard.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class LabWork07Hard : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Answer", + table: "Messages", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "IsRead", + table: "Messages", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Answer", + table: "Messages"); + + migrationBuilder.DropColumn( + name: "IsRead", + table: "Messages"); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs index 2383c0d..09d7a82 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs @@ -125,6 +125,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Property("MessageId") .HasColumnType("nvarchar(450)"); + b.Property("Answer") + .HasColumnType("nvarchar(max)"); + b.Property("Body") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -135,6 +138,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Property("DateDelivery") .HasColumnType("datetime2"); + b.Property("IsRead") + .HasColumnType("bit"); + b.Property("SenderName") .IsRequired() .HasColumnType("nvarchar(max)"); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/MessageInfo.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/MessageInfo.cs index 91105fb..ea6d532 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/MessageInfo.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/MessageInfo.cs @@ -63,11 +63,6 @@ namespace BlacksmithWorkshopDatabaseImplement.Models } MessageId = model.MessageId; - ClientId = model.ClientId; - SenderName = model.SenderName; - Body = model.Body; - DateDelivery = model.DateDelivery; - Subject = model.Subject; IsRead = model.IsRead; Answer = model.Answer; }