diff --git a/Shipyard/Shipyard/FormMail.Designer.cs b/Shipyard/Shipyard/FormMail.Designer.cs new file mode 100644 index 0000000..108a673 --- /dev/null +++ b/Shipyard/Shipyard/FormMail.Designer.cs @@ -0,0 +1,152 @@ +namespace ShipyardView +{ + 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.textBoxSender = new System.Windows.Forms.TextBox(); + this.textBoxSubject = new System.Windows.Forms.TextBox(); + this.textBoxBody = new System.Windows.Forms.TextBox(); + this.labelSenderName = new System.Windows.Forms.Label(); + this.labelSubject = new System.Windows.Forms.Label(); + this.labelBody = new System.Windows.Forms.Label(); + this.textBoxAnswer = new System.Windows.Forms.TextBox(); + this.labelAnswer = new System.Windows.Forms.Label(); + this.buttonSend = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBoxSender + // + this.textBoxSender.Location = new System.Drawing.Point(12, 36); + this.textBoxSender.Name = "textBoxSender"; + this.textBoxSender.Size = new System.Drawing.Size(193, 27); + this.textBoxSender.TabIndex = 0; + // + // textBoxSubject + // + this.textBoxSubject.Location = new System.Drawing.Point(12, 88); + this.textBoxSubject.Name = "textBoxSubject"; + this.textBoxSubject.Size = new System.Drawing.Size(193, 27); + this.textBoxSubject.TabIndex = 1; + // + // textBoxBody + // + this.textBoxBody.Location = new System.Drawing.Point(12, 141); + this.textBoxBody.Multiline = true; + this.textBoxBody.Name = "textBoxBody"; + this.textBoxBody.Size = new System.Drawing.Size(193, 104); + this.textBoxBody.TabIndex = 2; + // + // labelSenderName + // + this.labelSenderName.AutoSize = true; + this.labelSenderName.Location = new System.Drawing.Point(12, 9); + this.labelSenderName.Name = "labelSenderName"; + this.labelSenderName.Size = new System.Drawing.Size(99, 20); + this.labelSenderName.TabIndex = 3; + this.labelSenderName.Text = "Отправитель"; + // + // labelSubject + // + this.labelSubject.AutoSize = true; + this.labelSubject.Location = new System.Drawing.Point(12, 66); + this.labelSubject.Name = "labelSubject"; + this.labelSubject.Size = new System.Drawing.Size(81, 20); + this.labelSubject.TabIndex = 4; + this.labelSubject.Text = "Заголовок"; + // + // labelBody + // + this.labelBody.AutoSize = true; + this.labelBody.Location = new System.Drawing.Point(12, 118); + this.labelBody.Name = "labelBody"; + this.labelBody.Size = new System.Drawing.Size(100, 20); + this.labelBody.TabIndex = 5; + this.labelBody.Text = "Содержимое"; + // + // textBoxAnswer + // + this.textBoxAnswer.Location = new System.Drawing.Point(367, 36); + this.textBoxAnswer.Multiline = true; + this.textBoxAnswer.Name = "textBoxAnswer"; + this.textBoxAnswer.Size = new System.Drawing.Size(273, 79); + this.textBoxAnswer.TabIndex = 6; + // + // labelAnswer + // + this.labelAnswer.AutoSize = true; + this.labelAnswer.Location = new System.Drawing.Point(367, 9); + this.labelAnswer.Name = "labelAnswer"; + this.labelAnswer.Size = new System.Drawing.Size(48, 20); + this.labelAnswer.TabIndex = 7; + this.labelAnswer.Text = "Ответ"; + // + // buttonSend + // + this.buttonSend.Location = new System.Drawing.Point(367, 140); + this.buttonSend.Name = "buttonSend"; + this.buttonSend.Size = new System.Drawing.Size(273, 29); + this.buttonSend.TabIndex = 8; + this.buttonSend.Text = "Отослать"; + this.buttonSend.UseVisualStyleBackColor = true; + this.buttonSend.Click += new System.EventHandler(this.ButtonSend_Click); + // + // FormMail + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(655, 274); + this.Controls.Add(this.buttonSend); + this.Controls.Add(this.labelAnswer); + this.Controls.Add(this.textBoxAnswer); + this.Controls.Add(this.labelBody); + this.Controls.Add(this.labelSubject); + this.Controls.Add(this.labelSenderName); + this.Controls.Add(this.textBoxBody); + this.Controls.Add(this.textBoxSubject); + this.Controls.Add(this.textBoxSender); + this.Name = "FormMail"; + this.Text = "Письмо"; + this.Load += new System.EventHandler(this.FormMail_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxSender; + private TextBox textBoxSubject; + private TextBox textBoxBody; + private Label labelSenderName; + private Label labelSubject; + private Label labelBody; + private TextBox textBoxAnswer; + private Label labelAnswer; + private Button buttonSend; + } +} \ No newline at end of file diff --git a/Shipyard/Shipyard/FormMail.cs b/Shipyard/Shipyard/FormMail.cs new file mode 100644 index 0000000..6f48d9a --- /dev/null +++ b/Shipyard/Shipyard/FormMail.cs @@ -0,0 +1,112 @@ +using Microsoft.Extensions.Logging; +using ShipyardBusinessLogic.MailWorker; +using ShipyardContracts.BusinessLogicsContracts; +using ShipyardContracts.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 ShipyardView +{ + 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, + AnswerText = textBoxAnswer.Text + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _mailWorker.MailSendAsync(new() + { + MailAddress = _clientLogic.ReadElement(new ClientSearchModel { Id = view.ClientId })!.Email, + Subject = textBoxSubject.Text, + Text = textBoxAnswer.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 FormMail_Load(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(_id)) + { + try + { + _logger.LogInformation("Получение письма"); + var view = _logic.ReadElement(new MessageInfoSearchModel + { + MessageId= _id + }); + if (view != null) + { + textBoxSender.Text = view.SenderName; + textBoxSubject.Text = view.Subject; + textBoxBody.Text = view.Body; + } + if (!view.IsRead) + { + var updateResult = _logic.Update(new() + { + MessageId = _id, + AnswerText=view.AnswerText, + IsRead = true, + }); + if (!updateResult) + { + throw new Exception("Ошибка при обновлении"); + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения письма"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + } +} diff --git a/Shipyard/Shipyard/FormMail.resx b/Shipyard/Shipyard/FormMail.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Shipyard/Shipyard/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/Shipyard/Shipyard/FormMails.Designer.cs b/Shipyard/Shipyard/FormMails.Designer.cs index d84a447..97d697a 100644 --- a/Shipyard/Shipyard/FormMails.Designer.cs +++ b/Shipyard/Shipyard/FormMails.Designer.cs @@ -74,6 +74,7 @@ this.buttonOpen.TabIndex = 3; this.buttonOpen.Text = "Открыть"; this.buttonOpen.UseVisualStyleBackColor = true; + this.buttonOpen.Click += new System.EventHandler(this.ButtonOpen_Click); // // FormMails // diff --git a/Shipyard/Shipyard/FormMails.cs b/Shipyard/Shipyard/FormMails.cs index e9a98b3..d9bbe64 100644 --- a/Shipyard/Shipyard/FormMails.cs +++ b/Shipyard/Shipyard/FormMails.cs @@ -36,7 +36,6 @@ namespace ShipyardView dataGridView.DataSource = list; dataGridView.Columns["MessageId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false; - dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка писем"); } @@ -66,7 +65,18 @@ namespace ShipyardView 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(); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(0); + } + } + } } } } diff --git a/Shipyard/Shipyard/Program.cs b/Shipyard/Shipyard/Program.cs index 483a504..c634bc5 100644 --- a/Shipyard/Shipyard/Program.cs +++ b/Shipyard/Shipyard/Program.cs @@ -96,6 +96,7 @@ namespace ShipyardView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/Shipyard/ShipyardBusinessLogic/BusinessLogics/MessageInfoLogic.cs b/Shipyard/ShipyardBusinessLogic/BusinessLogics/MessageInfoLogic.cs index 2a7e8d1..491b4ea 100644 --- a/Shipyard/ShipyardBusinessLogic/BusinessLogics/MessageInfoLogic.cs +++ b/Shipyard/ShipyardBusinessLogic/BusinessLogics/MessageInfoLogic.cs @@ -31,6 +31,23 @@ namespace ShipyardBusinessLogic.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 = _messageInfoStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. MessageId:{Id}", element.MessageId); + return element; + } + public List? ReadList(MessageInfoSearchModel? model) { _logger.LogInformation("ReadList. ClientId:{ClientId}. MessageId:{MessageId}", model?.ClientId, model?.MessageId); @@ -43,5 +60,15 @@ namespace ShipyardBusinessLogic.BusinessLogics _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } + + public bool Update(MessageInfoBindingModel model) + { + if (_messageInfoStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } } } diff --git a/Shipyard/ShipyardContracts/BindingModels/MessageInfoBindingModel.cs b/Shipyard/ShipyardContracts/BindingModels/MessageInfoBindingModel.cs index e97840c..3e0a655 100644 --- a/Shipyard/ShipyardContracts/BindingModels/MessageInfoBindingModel.cs +++ b/Shipyard/ShipyardContracts/BindingModels/MessageInfoBindingModel.cs @@ -20,7 +20,7 @@ namespace ShipyardContracts.BindingModels public string Body { get; set; } = string.Empty; public DateTime DateDelivery { get; set; } - public bool IsRead { get; private set; } = false; - public string? AnswerText { get; private set; } + public bool IsRead { get; set; } = false; + public string? AnswerText { get; set; } } } diff --git a/Shipyard/ShipyardContracts/BusinessLogicsContracts/IMessageInfoLogic.cs b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IMessageInfoLogic.cs index 2832358..78be033 100644 --- a/Shipyard/ShipyardContracts/BusinessLogicsContracts/IMessageInfoLogic.cs +++ b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IMessageInfoLogic.cs @@ -14,5 +14,8 @@ namespace ShipyardContracts.BusinessLogicsContracts List? ReadList(MessageInfoSearchModel? model); bool Create(MessageInfoBindingModel model); + + MessageInfoViewModel? ReadElement(MessageInfoSearchModel? model); + bool Update(MessageInfoBindingModel model); } } diff --git a/Shipyard/ShipyardDataBaseImplement/Migrations/20230430162924_MessageFix.Designer.cs b/Shipyard/ShipyardDataBaseImplement/Migrations/20230430162924_MessageFix.Designer.cs new file mode 100644 index 0000000..025f94c --- /dev/null +++ b/Shipyard/ShipyardDataBaseImplement/Migrations/20230430162924_MessageFix.Designer.cs @@ -0,0 +1,383 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using ShipyardDataBaseImplement; + +#nullable disable + +namespace ShipyardDataBaseImplement.Migrations +{ + [DbContext(typeof(ShipyardDataBase))] + [Migration("20230430162924_MessageFix")] + partial class MessageFix + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("ShipyardDataBaseImplement.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("ShipyardDataBaseImplement.Models.Detail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("DetailName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Details"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.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("ShipyardDataBaseImplement.Models.Message", b => + { + b.Property("MessageId") + .HasColumnType("nvarchar(450)"); + + b.Property("AnswerText") + .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("ShipyardDataBaseImplement.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("ShipId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ShipId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("ShipName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Ships"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShipDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DetailId") + .HasColumnType("int"); + + b.Property("ShipId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DetailId"); + + b.HasIndex("ShipId"); + + b.ToTable("ShipDetails"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShopShip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ShipId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ShipId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopShips"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Message", b => + { + b.HasOne("ShipyardDataBaseImplement.Models.Client", "Client") + .WithMany("Messages") + .HasForeignKey("ClientId"); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Order", b => + { + b.HasOne("ShipyardDataBaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ShipyardDataBaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship") + .WithMany("Orders") + .HasForeignKey("ShipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Ship"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShipDetail", b => + { + b.HasOne("ShipyardDataBaseImplement.Models.Detail", "Detail") + .WithMany("ShipDetails") + .HasForeignKey("DetailId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship") + .WithMany("Details") + .HasForeignKey("ShipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Detail"); + + b.Navigation("Ship"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShopShip", b => + { + b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship") + .WithMany("Shops") + .HasForeignKey("ShipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ShipyardDataBaseImplement.Models.Shop", "Shop") + .WithMany("Ships") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ship"); + + b.Navigation("Shop"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Client", b => + { + b.Navigation("Messages"); + + b.Navigation("Orders"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Detail", b => + { + b.Navigation("ShipDetails"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b => + { + b.Navigation("Details"); + + b.Navigation("Orders"); + + b.Navigation("Shops"); + }); + + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Shop", b => + { + b.Navigation("Ships"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Shipyard/ShipyardDataBaseImplement/Migrations/20230430162924_MessageFix.cs b/Shipyard/ShipyardDataBaseImplement/Migrations/20230430162924_MessageFix.cs new file mode 100644 index 0000000..392e510 --- /dev/null +++ b/Shipyard/ShipyardDataBaseImplement/Migrations/20230430162924_MessageFix.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ShipyardDataBaseImplement.Migrations +{ + /// + public partial class MessageFix : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "AnswerText", + 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: "AnswerText", + table: "Messages"); + + migrationBuilder.DropColumn( + name: "IsRead", + table: "Messages"); + } + } +} diff --git a/Shipyard/ShipyardDataBaseImplement/Migrations/ShipyardDataBaseModelSnapshot.cs b/Shipyard/ShipyardDataBaseImplement/Migrations/ShipyardDataBaseModelSnapshot.cs index 72a0d7b..27f350c 100644 --- a/Shipyard/ShipyardDataBaseImplement/Migrations/ShipyardDataBaseModelSnapshot.cs +++ b/Shipyard/ShipyardDataBaseImplement/Migrations/ShipyardDataBaseModelSnapshot.cs @@ -99,6 +99,9 @@ namespace ShipyardDataBaseImplement.Migrations b.Property("MessageId") .HasColumnType("nvarchar(450)"); + b.Property("AnswerText") + .HasColumnType("nvarchar(max)"); + b.Property("Body") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -109,6 +112,9 @@ namespace ShipyardDataBaseImplement.Migrations b.Property("DateDelivery") .HasColumnType("datetime2"); + b.Property("IsRead") + .HasColumnType("bit"); + b.Property("SenderName") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -213,15 +219,6 @@ namespace ShipyardDataBaseImplement.Migrations b.ToTable("ShipDetails"); }); - modelBuilder.Entity("ShipyardDataBaseImplement.Models.Message", b => - { - b.HasOne("ShipyardDataBaseImplement.Models.Client", "Client") - .WithMany("Messages") - .HasForeignKey("ClientId"); - - b.Navigation("Client"); - }); - modelBuilder.Entity("ShipyardDataBaseImplement.Models.Shop", b => { b.Property("Id") @@ -275,6 +272,15 @@ namespace ShipyardDataBaseImplement.Migrations b.ToTable("ShopShips"); }); + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Message", b => + { + b.HasOne("ShipyardDataBaseImplement.Models.Client", "Client") + .WithMany("Messages") + .HasForeignKey("ClientId"); + + b.Navigation("Client"); + }); + modelBuilder.Entity("ShipyardDataBaseImplement.Models.Order", b => { b.HasOne("ShipyardDataBaseImplement.Models.Client", "Client")