Добавлен ответ на письмо но не ввиде письма, а ввиде строки

This commit is contained in:
Данияр Аглиуллов 2023-03-18 05:10:51 +04:00
parent be8b7adbf8
commit 3679613f8c
13 changed files with 943 additions and 174 deletions

View File

@ -6,7 +6,6 @@ using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.StoragesContract;
using ConfectioneryContracts.ViewModels;
using Microsoft.Extensions.Logging;
// ReSharper disable All
namespace ConfectioneryBusinessLogic
{

View File

@ -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)

149
Confectionery/FormReplyMail.Designer.cs generated Normal file
View File

@ -0,0 +1,149 @@
namespace ConfectioneryView
{
partial class FormReplyMail
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
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;
}
}

View File

@ -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<FormReplyMail> 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);
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,103 +1,104 @@
namespace ConfectioneryView
{
partial class FormViewMail
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
partial class FormViewMail
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
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);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<FormViewMail> logger, IMessageInfoLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
buttonPrevPage.Enabled = false;
}
public FormViewMail(ILogger<FormViewMail> 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<MessageInfoViewModel>)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<MessageInfoViewModel>)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();
}
}
}
}
}

View File

@ -105,6 +105,7 @@ namespace ConfectioneryView
services.AddTransient<FormViewImplementers>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormViewMail>();
services.AddTransient<FormReplyMail>();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();

View File

@ -16,5 +16,7 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
bool Create(MessageInfoBindingModel model);
bool Update(MessageInfoBindingModel model);
MessageInfoViewModel? ReadElement(MessageInfoSearchModel model);
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,395 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.MessageInfo", b =>
{
b.Property<string>("MessageId")
.HasColumnType("nvarchar(450)");
b.Property<string>("Body")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<DateTime>("DateDelivery")
.HasColumnType("datetime2");
b.Property<bool>("HasRead")
.HasColumnType("bit");
b.Property<string>("Reply")
.HasColumnType("nvarchar(max)");
b.Property<string>("SenderName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("MessageId");
b.HasIndex("ClientId");
b.ToTable("Messages");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("PastryId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("PastryName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Pastries");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("PastryId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("PastryId");
b.ToTable("PastryComponents");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateOpening")
.HasColumnType("datetime2");
b.Property<int>("MaxCountPastries")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("PastryId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PastryId");
b.ToTable("Shops");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.ShopPastry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("PastryId")
.HasColumnType("int");
b.Property<int>("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
}
}
}

View File

@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ConfectioneryDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class upgrademessage : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "HasRead",
table: "Messages",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "Reply",
table: "Messages",
type: "nvarchar(max)",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "HasRead",
table: "Messages");
migrationBuilder.DropColumn(
name: "Reply",
table: "Messages");
}
}
}

View File

@ -109,6 +109,12 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Property<DateTime>("DateDelivery")
.HasColumnType("datetime2");
b.Property<bool>("HasRead")
.HasColumnType("bit");
b.Property<string>("Reply")
.HasColumnType("nvarchar(max)");
b.Property<string>("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")