diff --git a/ConfectionaryBusinessLogic/ClientLogic.cs b/ConfectionaryBusinessLogic/ClientLogic.cs
index 28f5ef6..576fb6d 100644
--- a/ConfectionaryBusinessLogic/ClientLogic.cs
+++ b/ConfectionaryBusinessLogic/ClientLogic.cs
@@ -6,7 +6,6 @@ using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.StoragesContract;
using ConfectioneryContracts.ViewModels;
using Microsoft.Extensions.Logging;
-// ReSharper disable All
namespace ConfectioneryBusinessLogic
{
diff --git a/ConfectionaryBusinessLogic/MessageInfoLogic.cs b/ConfectionaryBusinessLogic/MessageInfoLogic.cs
index a4febc1..ab6fa16 100644
--- a/ConfectionaryBusinessLogic/MessageInfoLogic.cs
+++ b/ConfectionaryBusinessLogic/MessageInfoLogic.cs
@@ -33,6 +33,17 @@ namespace ConfectioneryBusinessLogic
return true;
}
+ public MessageInfoViewModel? ReadElement(MessageInfoSearchModel model)
+ {
+ var res = _messageInfoStorage.GetElement(model);
+ if (res == null)
+ {
+ _logger.LogWarning("Read element operation failed");
+ return null;
+ }
+ return res;
+ }
+
public bool Update(MessageInfoBindingModel model)
{
if (_messageInfoStorage.Update(model) == null)
diff --git a/Confectionery/FormReplyMail.Designer.cs b/Confectionery/FormReplyMail.Designer.cs
new file mode 100644
index 0000000..21e2af9
--- /dev/null
+++ b/Confectionery/FormReplyMail.Designer.cs
@@ -0,0 +1,149 @@
+namespace ConfectioneryView
+{
+ partial class FormReplyMail
+ {
+ ///
+ /// 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();
+ label1 = new Label();
+ label2 = new Label();
+ label3 = new Label();
+ textBoxHead = new TextBox();
+ textBoxMail = new TextBox();
+ textBoxReply = new TextBox();
+ SuspendLayout();
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(460, 291);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(117, 30);
+ buttonSave.TabIndex = 0;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(337, 291);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(117, 30);
+ buttonCancel.TabIndex = 1;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // label1
+ //
+ label1.Location = new Point(12, 9);
+ label1.Name = "label1";
+ label1.Size = new Size(117, 23);
+ label1.TabIndex = 2;
+ label1.Text = "Заголовок письма:";
+ label1.TextAlign = ContentAlignment.TopRight;
+ //
+ // label2
+ //
+ label2.Location = new Point(12, 38);
+ label2.Name = "label2";
+ label2.Size = new Size(117, 23);
+ label2.TabIndex = 3;
+ label2.Text = "Текст письма:";
+ label2.TextAlign = ContentAlignment.TopRight;
+ //
+ // label3
+ //
+ label3.Location = new Point(12, 117);
+ label3.Name = "label3";
+ label3.Size = new Size(117, 31);
+ label3.TabIndex = 4;
+ label3.Text = "Ответ на письмо:";
+ label3.TextAlign = ContentAlignment.TopRight;
+ //
+ // textBoxHead
+ //
+ textBoxHead.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ textBoxHead.Location = new Point(135, 5);
+ textBoxHead.Name = "textBoxHead";
+ textBoxHead.ReadOnly = true;
+ textBoxHead.Size = new Size(442, 23);
+ textBoxHead.TabIndex = 5;
+ //
+ // textBoxMail
+ //
+ textBoxMail.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ textBoxMail.Location = new Point(135, 35);
+ textBoxMail.Multiline = true;
+ textBoxMail.Name = "textBoxMail";
+ textBoxMail.ReadOnly = true;
+ textBoxMail.Size = new Size(442, 76);
+ textBoxMail.TabIndex = 6;
+ //
+ // textBoxReply
+ //
+ textBoxReply.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ textBoxReply.Location = new Point(135, 117);
+ textBoxReply.Multiline = true;
+ textBoxReply.Name = "textBoxReply";
+ textBoxReply.Size = new Size(442, 168);
+ textBoxReply.TabIndex = 7;
+ //
+ // FormReplyMail
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(589, 333);
+ Controls.Add(textBoxReply);
+ Controls.Add(textBoxMail);
+ Controls.Add(textBoxHead);
+ Controls.Add(label3);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Name = "FormReplyMail";
+ Text = "Ответ на письмо";
+ Load += FormReplyMail_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label label1;
+ private Label label2;
+ private Label label3;
+ private TextBox textBoxHead;
+ private TextBox textBoxMail;
+ private TextBox textBoxReply;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/FormReplyMail.cs b/Confectionery/FormReplyMail.cs
new file mode 100644
index 0000000..8247d8e
--- /dev/null
+++ b/Confectionery/FormReplyMail.cs
@@ -0,0 +1,80 @@
+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;
+using ConfectioneryBusinessLogic.MailWorker;
+using ConfectioneryContracts.BusinessLogicsContracts;
+using ConfectioneryContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using MimeKit;
+
+namespace ConfectioneryView
+{
+ public partial class FormReplyMail : Form
+ {
+ private readonly ILogger _logger;
+ private readonly AbstractMailWorker _mailWorker;
+ private readonly IMessageInfoLogic _logic;
+ private MessageInfoViewModel _message;
+
+ public string MessageId { get; set; }
+
+ public FormReplyMail(ILogger logger, AbstractMailWorker mailWorker, IMessageInfoLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _mailWorker = mailWorker;
+ _logic = logic;
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ _mailWorker.MailSendAsync(new()
+ {
+ MailAddress = _message.SenderName,
+ Subject = _message.Subject,
+ Text = textBoxReply.Text,
+ });
+ _logic.Update(new()
+ {
+ MessageId = MessageId,
+ Reply = textBoxReply.Text,
+ HasRead = true,
+ });
+ MessageBox.Show("Успешно отправлено письмо", "Отправка письма", MessageBoxButtons.OK);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+
+ private void FormReplyMail_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ _message = _logic.ReadElement(new() { MessageId = MessageId });
+ if (_message == null)
+ throw new ArgumentNullException("Письма с таким id не существует");
+ Text += $"для {_message.SenderName}";
+ textBoxHead.Text = _message.Subject;
+ textBoxMail.Text = _message.Body;
+ _logic.Update(new() { MessageId = MessageId, HasRead = true });
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения собщения");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/Confectionery/FormReplyMail.resx b/Confectionery/FormReplyMail.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/FormReplyMail.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/Confectionery/FormViewMail.Designer.cs b/Confectionery/FormViewMail.Designer.cs
index 22af24b..6a47acf 100644
--- a/Confectionery/FormViewMail.Designer.cs
+++ b/Confectionery/FormViewMail.Designer.cs
@@ -1,103 +1,104 @@
namespace ConfectioneryView
{
- partial class FormViewMail
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
+ partial class FormViewMail
+ {
+ ///
+ /// 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);
- }
+ ///
+ /// 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
+ #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()
- {
- dataGridView = new DataGridView();
- buttonPrevPage = new Button();
- buttonNextPage = new Button();
- labelInfoPages = new Label();
- ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
- SuspendLayout();
- //
- // dataGridView
- //
- dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
- dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- dataGridView.Location = new Point(0, 0);
- dataGridView.Name = "dataGridView";
- dataGridView.RowTemplate.Height = 25;
- dataGridView.Size = new Size(730, 454);
- dataGridView.TabIndex = 0;
- //
- // buttonPrevPage
- //
- buttonPrevPage.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonPrevPage.Location = new Point(12, 460);
- buttonPrevPage.Name = "buttonPrevPage";
- buttonPrevPage.Size = new Size(75, 23);
- buttonPrevPage.TabIndex = 1;
- buttonPrevPage.Text = "<<<";
- buttonPrevPage.UseVisualStyleBackColor = true;
- buttonPrevPage.Click += ButtonPrevPage_Click;
- //
- // buttonNextPage
- //
- buttonNextPage.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonNextPage.Location = new Point(203, 460);
- buttonNextPage.Name = "buttonNextPage";
- buttonNextPage.Size = new Size(75, 23);
- buttonNextPage.TabIndex = 2;
- buttonNextPage.Text = ">>>";
- buttonNextPage.UseVisualStyleBackColor = true;
- buttonNextPage.Click += ButtonNextPage_Click;
- //
- // labelInfoPages
- //
- labelInfoPages.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- labelInfoPages.Location = new Point(93, 464);
- labelInfoPages.Name = "labelInfoPages";
- labelInfoPages.Size = new Size(104, 19);
- labelInfoPages.TabIndex = 3;
- labelInfoPages.Text = "{0} страница";
- labelInfoPages.TextAlign = ContentAlignment.MiddleCenter;
- //
- // FormViewMail
- //
- AutoScaleDimensions = new SizeF(7F, 15F);
- AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(727, 498);
- Controls.Add(labelInfoPages);
- Controls.Add(buttonNextPage);
- Controls.Add(buttonPrevPage);
- Controls.Add(dataGridView);
- Name = "FormViewMail";
- Text = "Письма";
- Load += FormViewMail_Load;
- ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
- ResumeLayout(false);
- }
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ buttonPrevPage = new Button();
+ buttonNextPage = new Button();
+ labelInfoPages = new Label();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(730, 454);
+ dataGridView.TabIndex = 0;
+ dataGridView.RowHeaderMouseClick += dataGridView_RowHeaderMouseClick;
+ //
+ // buttonPrevPage
+ //
+ buttonPrevPage.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonPrevPage.Location = new Point(12, 460);
+ buttonPrevPage.Name = "buttonPrevPage";
+ buttonPrevPage.Size = new Size(75, 23);
+ buttonPrevPage.TabIndex = 1;
+ buttonPrevPage.Text = "<<<";
+ buttonPrevPage.UseVisualStyleBackColor = true;
+ buttonPrevPage.Click += ButtonPrevPage_Click;
+ //
+ // buttonNextPage
+ //
+ buttonNextPage.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonNextPage.Location = new Point(203, 460);
+ buttonNextPage.Name = "buttonNextPage";
+ buttonNextPage.Size = new Size(75, 23);
+ buttonNextPage.TabIndex = 2;
+ buttonNextPage.Text = ">>>";
+ buttonNextPage.UseVisualStyleBackColor = true;
+ buttonNextPage.Click += ButtonNextPage_Click;
+ //
+ // labelInfoPages
+ //
+ labelInfoPages.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ labelInfoPages.Location = new Point(93, 464);
+ labelInfoPages.Name = "labelInfoPages";
+ labelInfoPages.Size = new Size(104, 19);
+ labelInfoPages.TabIndex = 3;
+ labelInfoPages.Text = "{0} страница";
+ labelInfoPages.TextAlign = ContentAlignment.MiddleCenter;
+ //
+ // FormViewMail
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(727, 498);
+ Controls.Add(labelInfoPages);
+ Controls.Add(buttonNextPage);
+ Controls.Add(buttonPrevPage);
+ Controls.Add(dataGridView);
+ Name = "FormViewMail";
+ Text = "Письма";
+ Load += FormViewMail_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
- #endregion
+ #endregion
- private DataGridView dataGridView;
- private Button buttonPrevPage;
- private Button buttonNextPage;
- private Label labelInfoPages;
- }
+ private DataGridView dataGridView;
+ private Button buttonPrevPage;
+ private Button buttonNextPage;
+ private Label labelInfoPages;
+ }
}
\ No newline at end of file
diff --git a/Confectionery/FormViewMail.cs b/Confectionery/FormViewMail.cs
index 004b1b3..2bedb35 100644
--- a/Confectionery/FormViewMail.cs
+++ b/Confectionery/FormViewMail.cs
@@ -14,87 +14,101 @@ using ConfectioneryContracts.ViewModels;
namespace ConfectioneryView
{
- public partial class FormViewMail : Form
- {
- private readonly ILogger _logger;
- private readonly IMessageInfoLogic _logic;
- private int currentPage = 1;
- public int pageSize = 5;
+ public partial class FormViewMail : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IMessageInfoLogic _logic;
+ private int currentPage = 1;
+ public int pageSize = 5;
- public FormViewMail(ILogger logger, IMessageInfoLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- buttonPrevPage.Enabled = false;
- }
+ public FormViewMail(ILogger logger, IMessageInfoLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ buttonPrevPage.Enabled = false;
+ }
- private void FormViewMail_Load(object sender, EventArgs e)
- {
- MailLoad();
- }
+ private void FormViewMail_Load(object sender, EventArgs e)
+ {
+ MailLoad();
+ }
- private bool MailLoad()
- {
- try
- {
- var list = _logic.ReadList(new()
- {
- Page = currentPage,
- PageSize = pageSize,
- });
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["ClientId"].Visible = false;
- dataGridView.Columns["MessageId"].Visible = false;
- dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation("Загрузка списка писем");
- labelInfoPages.Text = $"{currentPage} страница";
- return true;
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки писем");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- return false;
- }
- }
+ private bool MailLoad()
+ {
+ try
+ {
+ var list = _logic.ReadList(new()
+ {
+ Page = currentPage,
+ PageSize = pageSize,
+ });
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["ClientId"].Visible = false;
+ dataGridView.Columns["MessageId"].Visible = false;
+ dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка списка писем");
+ labelInfoPages.Text = $"{currentPage} страница";
+ return true;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки писем");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ return false;
+ }
+ }
- private void ButtonPrevPage_Click(object sender, EventArgs e)
- {
- if (currentPage == 1)
- {
- _logger.LogWarning("Неккоректный номер страницы {page}", currentPage - 1);
- return;
- }
- currentPage--;
- if (MailLoad())
- {
- buttonNextPage.Enabled = true;
- if (currentPage == 1)
- {
- buttonPrevPage.Enabled = false;
- }
- }
- }
+ private void ButtonPrevPage_Click(object sender, EventArgs e)
+ {
+ if (currentPage == 1)
+ {
+ _logger.LogWarning("Неккоректный номер страницы {page}", currentPage - 1);
+ return;
+ }
+ currentPage--;
+ if (MailLoad())
+ {
+ buttonNextPage.Enabled = true;
+ if (currentPage == 1)
+ {
+ buttonPrevPage.Enabled = false;
+ }
+ }
+ }
- private void ButtonNextPage_Click(object sender, EventArgs e)
- {
- currentPage++;
- if (!MailLoad() || ((List)dataGridView.DataSource).Count == 0)
- {
- _logger.LogWarning("Out of range messages");
- currentPage--;
- MailLoad();
- buttonNextPage.Enabled = false;
- }
- else
- {
- buttonPrevPage.Enabled = true;
- }
- }
- }
+ private void ButtonNextPage_Click(object sender, EventArgs e)
+ {
+ currentPage++;
+ if (!MailLoad() || ((List)dataGridView.DataSource).Count == 0)
+ {
+ _logger.LogWarning("Out of range messages");
+ currentPage--;
+ MailLoad();
+ buttonNextPage.Enabled = false;
+ }
+ else
+ {
+ buttonPrevPage.Enabled = true;
+ }
+ }
+
+ private void dataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReplyMail));
+ if (service is FormReplyMail form)
+ {
+ form.MessageId = (string)dataGridView.Rows[e.RowIndex].Cells["MessageId"].Value;
+ form.ShowDialog();
+ if (form.DialogResult == DialogResult.OK)
+ {
+ MailLoad();
+ }
+ }
+ }
+ }
}
diff --git a/Confectionery/Program.cs b/Confectionery/Program.cs
index f964699..5406826 100644
--- a/Confectionery/Program.cs
+++ b/Confectionery/Program.cs
@@ -105,6 +105,7 @@ namespace ConfectioneryView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck();
diff --git a/ConfectioneryContracts/BusinessLogicsContracts/IMessageInfoLogic.cs b/ConfectioneryContracts/BusinessLogicsContracts/IMessageInfoLogic.cs
index 248770f..f954f4e 100644
--- a/ConfectioneryContracts/BusinessLogicsContracts/IMessageInfoLogic.cs
+++ b/ConfectioneryContracts/BusinessLogicsContracts/IMessageInfoLogic.cs
@@ -16,5 +16,7 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
bool Create(MessageInfoBindingModel model);
bool Update(MessageInfoBindingModel model);
+
+ MessageInfoViewModel? ReadElement(MessageInfoSearchModel model);
}
}
diff --git a/ConfectioneryContracts/ViewModels/MessageInfoViewModel.cs b/ConfectioneryContracts/ViewModels/MessageInfoViewModel.cs
index 43080c8..2955d75 100644
--- a/ConfectioneryContracts/ViewModels/MessageInfoViewModel.cs
+++ b/ConfectioneryContracts/ViewModels/MessageInfoViewModel.cs
@@ -26,7 +26,10 @@ namespace ConfectioneryContracts.ViewModels
[DisplayName("Текст")]
public string Body { get; set; } = string.Empty;
+ [DisplayName("Прочитано")]
public bool HasRead { get; set; }
+
+ [DisplayName("Ответ")]
public string? Reply { get; set; }
}
}
diff --git a/ConfectioneryDatabaseImplement/Migrations/20230317234305_upgrade-message.Designer.cs b/ConfectioneryDatabaseImplement/Migrations/20230317234305_upgrade-message.Designer.cs
new file mode 100644
index 0000000..6ba4437
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Migrations/20230317234305_upgrade-message.Designer.cs
@@ -0,0 +1,395 @@
+//
+using System;
+using ConfectioneryDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace ConfectioneryDatabaseImplement.Migrations
+{
+ [DbContext(typeof(ConfectioneryDatabase))]
+ [Migration("20230317234305_upgrade-message")]
+ partial class upgrademessage
+ {
+ ///
+ 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("ConfectioneryDatabaseImplement.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("ConfectioneryDatabaseImplement.Models.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Cost")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.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("ConfectioneryDatabaseImplement.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("HasRead")
+ .HasColumnType("bit");
+
+ b.Property("Reply")
+ .HasColumnType("nvarchar(max)");
+
+ 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("ConfectioneryDatabaseImplement.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("PastryId")
+ .HasColumnType("int");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("Sum")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("ImplementerId");
+
+ b.HasIndex("PastryId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("PastryName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Price")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.ToTable("Pastries");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ComponentId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComponentId");
+
+ b.HasIndex("PastryId");
+
+ b.ToTable("PastryComponents");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Address")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOpening")
+ .HasColumnType("datetime2");
+
+ b.Property("MaxCountPastries")
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PastryId");
+
+ b.ToTable("Shops");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.ShopPastry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.Property("ShopId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PastryId");
+
+ b.HasIndex("ShopId");
+
+ b.ToTable("ShopPastries");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.MessageInfo", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Client", "Client")
+ .WithMany("Messages")
+ .HasForeignKey("ClientId");
+
+ b.Navigation("Client");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Client", "Client")
+ .WithMany("Orders")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
+ .WithMany("Orders")
+ .HasForeignKey("PastryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Client");
+
+ b.Navigation("Implementer");
+
+ b.Navigation("Pastry");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
+ .WithMany("PastryComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
+ .WithMany("Components")
+ .HasForeignKey("PastryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Pastry");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", null)
+ .WithMany("Shops")
+ .HasForeignKey("PastryId");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.ShopPastry", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
+ .WithMany()
+ .HasForeignKey("PastryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Shop", "Shop")
+ .WithMany("ShopPastries")
+ .HasForeignKey("ShopId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Pastry");
+
+ b.Navigation("Shop");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b =>
+ {
+ b.Navigation("Messages");
+
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
+ {
+ b.Navigation("PastryComponents");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+
+ b.Navigation("Shops");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.Navigation("ShopPastries");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/Migrations/20230317234305_upgrade-message.cs b/ConfectioneryDatabaseImplement/Migrations/20230317234305_upgrade-message.cs
new file mode 100644
index 0000000..ac45468
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Migrations/20230317234305_upgrade-message.cs
@@ -0,0 +1,39 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace ConfectioneryDatabaseImplement.Migrations
+{
+ ///
+ public partial class upgrademessage : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "HasRead",
+ table: "Messages",
+ type: "bit",
+ nullable: false,
+ defaultValue: false);
+
+ migrationBuilder.AddColumn(
+ name: "Reply",
+ table: "Messages",
+ type: "nvarchar(max)",
+ nullable: true);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "HasRead",
+ table: "Messages");
+
+ migrationBuilder.DropColumn(
+ name: "Reply",
+ table: "Messages");
+ }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs b/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
index 6532f79..be68b52 100644
--- a/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
+++ b/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
@@ -109,6 +109,12 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Property("DateDelivery")
.HasColumnType("datetime2");
+ b.Property("HasRead")
+ .HasColumnType("bit");
+
+ b.Property("Reply")
+ .HasColumnType("nvarchar(max)");
+
b.Property("SenderName")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -271,6 +277,15 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.ToTable("ShopPastries");
});
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.MessageInfo", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Client", "Client")
+ .WithMany("Messages")
+ .HasForeignKey("ClientId");
+
+ b.Navigation("Client");
+ });
+
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
{
b.HasOne("ConfectioneryDatabaseImplement.Models.Client", "Client")