diff --git a/Pizzeria/Pizzeria/App.config b/Pizzeria/Pizzeria/App.config
index f7dfd6a..f3784c1 100644
--- a/Pizzeria/Pizzeria/App.config
+++ b/Pizzeria/Pizzeria/App.config
@@ -5,7 +5,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/Pizzeria/Pizzeria/FormMails.Designer.cs b/Pizzeria/Pizzeria/FormMails.Designer.cs
new file mode 100644
index 0000000..7e27b1b
--- /dev/null
+++ b/Pizzeria/Pizzeria/FormMails.Designer.cs
@@ -0,0 +1,64 @@
+namespace Pizzeria
+{
+ partial class FormMails
+ {
+ ///
+ /// 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()
+ {
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(694, 362);
+ dataGridView.TabIndex = 1;
+ //
+ // FormMails
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(718, 386);
+ Controls.Add(dataGridView);
+ Name = "FormMails";
+ Text = "Письма";
+ Load += FormMails_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/Pizzeria/Pizzeria/FormMails.cs b/Pizzeria/Pizzeria/FormMails.cs
new file mode 100644
index 0000000..30c6734
--- /dev/null
+++ b/Pizzeria/Pizzeria/FormMails.cs
@@ -0,0 +1,54 @@
+using Microsoft.Extensions.Logging;
+using PizzeriaContracts.BusinessLogicsContracts;
+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 Pizzeria
+{
+ public partial class FormMails : Form
+ {
+ ILogger _logger;
+ IMessageInfoLogic _logic;
+
+ public FormMails(ILogger logger, IMessageInfoLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+
+
+ private void FormMails_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["MessageId"].Visible = false;
+ dataGridView.Columns["ClientId"].Visible = false;
+ dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка писем");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/Pizzeria/Pizzeria/FormMails.resx b/Pizzeria/Pizzeria/FormMails.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Pizzeria/Pizzeria/FormMails.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/Pizzeria/Pizzeria/FormMain.Designer.cs b/Pizzeria/Pizzeria/FormMain.Designer.cs
index cb0a11e..c8bb969 100644
--- a/Pizzeria/Pizzeria/FormMain.Designer.cs
+++ b/Pizzeria/Pizzeria/FormMain.Designer.cs
@@ -28,190 +28,185 @@
///
private void InitializeComponent()
{
- this.components = new System.ComponentModel.Container();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- this.button4 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.menuStrip1 = new System.Windows.Forms.MenuStrip();
- this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.компонентовПоПиццамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.menuStrip1.SuspendLayout();
- this.SuspendLayout();
+ components = new System.ComponentModel.Container();
+ dataGridView = new DataGridView();
+ button4 = new Button();
+ button1 = new Button();
+ button3 = new Button();
+ contextMenuStrip = new ContextMenuStrip(components);
+ menuStrip1 = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ компонентыToolStripMenuItem = new ToolStripMenuItem();
+ изделияToolStripMenuItem = new ToolStripMenuItem();
+ клиентыToolStripMenuItem = new ToolStripMenuItem();
+ исполнителиToolStripMenuItem = new ToolStripMenuItem();
+ отчетыToolStripMenuItem = new ToolStripMenuItem();
+ списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
+ компонентовПоПиццамToolStripMenuItem = new ToolStripMenuItem();
+ списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
+ запускРаботToolStripMenuItem = new ToolStripMenuItem();
+ письмаToolStripMenuItem = new ToolStripMenuItem();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ menuStrip1.SuspendLayout();
+ SuspendLayout();
//
// dataGridView
//
- this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(0, 31);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowHeadersWidth = 51;
- this.dataGridView.RowTemplate.Height = 29;
- this.dataGridView.Size = new System.Drawing.Size(1203, 383);
- this.dataGridView.TabIndex = 0;
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 31);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(1203, 383);
+ dataGridView.TabIndex = 0;
//
// button4
//
- this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button4.Location = new System.Drawing.Point(1255, 100);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(209, 29);
- this.button4.TabIndex = 8;
- this.button4.Text = "Заказ выдан";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
+ button4.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ button4.Location = new Point(1255, 100);
+ button4.Name = "button4";
+ button4.Size = new Size(209, 29);
+ button4.TabIndex = 8;
+ button4.Text = "Заказ выдан";
+ button4.UseVisualStyleBackColor = true;
+ button4.Click += ButtonIssuedOrder_Click;
//
// button1
//
- this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button1.Location = new System.Drawing.Point(1255, 49);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(209, 29);
- this.button1.TabIndex = 6;
- this.button1.Text = "Создать заказ";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
+ button1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ button1.Location = new Point(1255, 49);
+ button1.Name = "button1";
+ button1.Size = new Size(209, 29);
+ button1.TabIndex = 6;
+ button1.Text = "Создать заказ";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += ButtonCreateOrder_Click;
//
// button3
//
- this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button3.Location = new System.Drawing.Point(1255, 146);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(209, 29);
- this.button3.TabIndex = 10;
- this.button3.Text = "Обновить список";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.ButtonRef_Click);
+ button3.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ button3.Location = new Point(1255, 146);
+ button3.Name = "button3";
+ button3.Size = new Size(209, 29);
+ button3.TabIndex = 10;
+ button3.Text = "Обновить список";
+ button3.UseVisualStyleBackColor = true;
+ button3.Click += ButtonRef_Click;
//
// contextMenuStrip
//
- this.contextMenuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.contextMenuStrip.Name = "contextMenuStrip";
- this.contextMenuStrip.Size = new System.Drawing.Size(61, 4);
+ contextMenuStrip.ImageScalingSize = new Size(20, 20);
+ contextMenuStrip.Name = "contextMenuStrip";
+ contextMenuStrip.Size = new Size(61, 4);
//
// menuStrip1
//
- this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.справочникиToolStripMenuItem,
- this.отчетыToolStripMenuItem,
- this.запускРаботToolStripMenuItem});
- this.menuStrip1.Location = new System.Drawing.Point(0, 0);
- this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(1501, 28);
- this.menuStrip1.TabIndex = 11;
- this.menuStrip1.Text = "menuStrip1";
+ menuStrip1.ImageScalingSize = new Size(20, 20);
+ menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, запускРаботToolStripMenuItem, письмаToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Size = new Size(1501, 28);
+ menuStrip1.TabIndex = 11;
+ menuStrip1.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
- this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.компонентыToolStripMenuItem,
- this.изделияToolStripMenuItem,
- this.клиентыToolStripMenuItem,
- this.исполнителиToolStripMenuItem});
- this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
- this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
- this.справочникиToolStripMenuItem.Text = "Справочники";
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem });
+ справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ справочникиToolStripMenuItem.Size = new Size(117, 24);
+ справочникиToolStripMenuItem.Text = "Справочники";
//
// компонентыToolStripMenuItem
//
- this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
- this.компонентыToolStripMenuItem.Text = "Компоненты";
- this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
+ компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ компонентыToolStripMenuItem.Size = new Size(185, 26);
+ компонентыToolStripMenuItem.Text = "Компоненты";
+ компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
//
// изделияToolStripMenuItem
//
- this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
- this.изделияToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
- this.изделияToolStripMenuItem.Text = "Пиццы";
- this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ПиццыToolStripMenuItem_Click);
+ изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
+ изделияToolStripMenuItem.Size = new Size(185, 26);
+ изделияToolStripMenuItem.Text = "Пиццы";
+ изделияToolStripMenuItem.Click += ПиццыToolStripMenuItem_Click;
//
// клиентыToolStripMenuItem
//
- this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
- this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
- this.клиентыToolStripMenuItem.Text = "Клиенты";
- this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
+ клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
+ клиентыToolStripMenuItem.Size = new Size(185, 26);
+ клиентыToolStripMenuItem.Text = "Клиенты";
+ клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
//
// исполнителиToolStripMenuItem
//
- this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
- this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
- this.исполнителиToolStripMenuItem.Text = "Исполнители";
- this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click);
+ исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
+ исполнителиToolStripMenuItem.Size = new Size(185, 26);
+ исполнителиToolStripMenuItem.Text = "Исполнители";
+ исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
- this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.списокКомпонентовToolStripMenuItem,
- this.компонентовПоПиццамToolStripMenuItem,
- this.списокЗаказовToolStripMenuItem});
- this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
- this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
- this.отчетыToolStripMenuItem.Text = "Отчеты";
+ отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентовПоПиццамToolStripMenuItem, списокЗаказовToolStripMenuItem });
+ отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
+ отчетыToolStripMenuItem.Size = new Size(73, 24);
+ отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокКомпонентовToolStripMenuItem
//
- this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
- this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(269, 26);
- this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
- this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
+ списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
+ списокКомпонентовToolStripMenuItem.Size = new Size(269, 26);
+ списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
+ списокКомпонентовToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
//
// компонентовПоПиццамToolStripMenuItem
//
- this.компонентовПоПиццамToolStripMenuItem.Name = "компонентовПоПиццамToolStripMenuItem";
- this.компонентовПоПиццамToolStripMenuItem.Size = new System.Drawing.Size(269, 26);
- this.компонентовПоПиццамToolStripMenuItem.Text = "Компонентов по пиццам";
- this.компонентовПоПиццамToolStripMenuItem.Click += new System.EventHandler(this.ComponentPizzasToolStripMenuItem_Click);
+ компонентовПоПиццамToolStripMenuItem.Name = "компонентовПоПиццамToolStripMenuItem";
+ компонентовПоПиццамToolStripMenuItem.Size = new Size(269, 26);
+ компонентовПоПиццамToolStripMenuItem.Text = "Компонентов по пиццам";
+ компонентовПоПиццамToolStripMenuItem.Click += ComponentPizzasToolStripMenuItem_Click;
//
// списокЗаказовToolStripMenuItem
//
- this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
- this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(269, 26);
- this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
- this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
+ списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
+ списокЗаказовToolStripMenuItem.Size = new Size(269, 26);
+ списокЗаказовToolStripMenuItem.Text = "Список заказов";
+ списокЗаказовToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
//
// запускРаботToolStripMenuItem
//
- this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
- this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
- this.запускРаботToolStripMenuItem.Text = "Запуск работ";
- this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
+ запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
+ запускРаботToolStripMenuItem.Size = new Size(114, 24);
+ запускРаботToolStripMenuItem.Text = "Запуск работ";
+ запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
+ //
+ // письмаToolStripMenuItem
+ //
+ письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
+ письмаToolStripMenuItem.Size = new Size(77, 24);
+ письмаToolStripMenuItem.Text = "Письма";
+ письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click;
//
// FormMain
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1501, 414);
- this.Controls.Add(this.menuStrip1);
- this.Controls.Add(this.button3);
- this.Controls.Add(this.button4);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.dataGridView);
- this.MainMenuStrip = this.menuStrip1;
- this.Name = "FormMain";
- this.Text = "Абстрактный магазин";
- this.Load += new System.EventHandler(this.FormMain_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.menuStrip1.ResumeLayout(false);
- this.menuStrip1.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1501, 414);
+ Controls.Add(menuStrip1);
+ Controls.Add(button3);
+ Controls.Add(button4);
+ Controls.Add(button1);
+ Controls.Add(dataGridView);
+ MainMenuStrip = menuStrip1;
+ Name = "FormMain";
+ Text = "Абстрактный магазин";
+ Load += FormMain_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -232,5 +227,6 @@
private ToolStripMenuItem клиентыToolStripMenuItem;
private ToolStripMenuItem запускРаботToolStripMenuItem;
private ToolStripMenuItem исполнителиToolStripMenuItem;
+ private ToolStripMenuItem письмаToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/Pizzeria/Pizzeria/FormMain.cs b/Pizzeria/Pizzeria/FormMain.cs
index 6aa0479..85ffcc7 100644
--- a/Pizzeria/Pizzeria/FormMain.cs
+++ b/Pizzeria/Pizzeria/FormMain.cs
@@ -167,5 +167,14 @@ e)
form.ShowDialog();
}
}
+
+ private void ToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormMails));
+ if (service is FormMails form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Pizzeria/Pizzeria/Program.cs b/Pizzeria/Pizzeria/Program.cs
index 6f922b8..3e817c6 100644
--- a/Pizzeria/Pizzeria/Program.cs
+++ b/Pizzeria/Pizzeria/Program.cs
@@ -37,7 +37,7 @@ namespace Pizzeria
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
- SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClient Port"]),
+ SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
});
diff --git a/Pizzeria/PizzeriaBusinessLogic/ClientLogic.cs b/Pizzeria/PizzeriaBusinessLogic/ClientLogic.cs
index 987bae6..3987989 100644
--- a/Pizzeria/PizzeriaBusinessLogic/ClientLogic.cs
+++ b/Pizzeria/PizzeriaBusinessLogic/ClientLogic.cs
@@ -3,6 +3,7 @@ using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
+using System.Text.RegularExpressions;
using Microsoft.Extensions.Logging;
@@ -98,6 +99,14 @@ namespace PizzeriaBusinessLogic
{
throw new ArgumentNullException("Нет пароля у клиента", nameof(model.ClientFIO));
}
+ if (!Regex.IsMatch(model.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"))
+ {
+ throw new ArgumentException("Некорретно введен email клиента", nameof(model.Email));
+ }
+ if (!Regex.IsMatch(model.Password, @"^(?=.*\d)(?=.*\W)(?=.*[^\d\s]).+$"))
+ {
+ throw new ArgumentException("Некорректно введен пароль клиента", nameof(model.Password));
+ }
_logger.LogInformation("Client. ClientFIO:{ClientFIO}. Email:{Email}. Id: {id}", model.ClientFIO, model.Email, model.Id);
var element = _clientStorage.GetElement(new ClientSearchModel
{
diff --git a/Pizzeria/PizzeriaBusinessLogic/MailWorker/AbstractMailWorker.cs b/Pizzeria/PizzeriaBusinessLogic/MailWorker/AbstractMailWorker.cs
index c2d3959..25aa5ff 100644
--- a/Pizzeria/PizzeriaBusinessLogic/MailWorker/AbstractMailWorker.cs
+++ b/Pizzeria/PizzeriaBusinessLogic/MailWorker/AbstractMailWorker.cs
@@ -13,12 +13,13 @@ namespace PizzeriaBusinessLogic.MailWorker
protected string _popHost = string.Empty;
protected int _popPort;
private readonly IMessageInfoLogic _messageInfoLogic;
+ private readonly IClientLogic _clientLogic;
private readonly ILogger _logger;
- public AbstractMailWorker(ILogger logger,
- IMessageInfoLogic messageInfoLogic)
+ public AbstractMailWorker(ILogger logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic)
{
_logger = logger;
_messageInfoLogic = messageInfoLogic;
+ _clientLogic = clientLogic;
}
public void MailConfig(MailConfigBindingModel config)
{
@@ -66,6 +67,7 @@ namespace PizzeriaBusinessLogic.MailWorker
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
foreach (var mail in list)
{
+ mail.ClientId = _clientLogic.ReadElement(new() { Email = mail.SenderName })?.Id;
_messageInfoLogic.Create(mail);
}
}
diff --git a/Pizzeria/PizzeriaBusinessLogic/MailWorker/MailKitWorker.cs b/Pizzeria/PizzeriaBusinessLogic/MailWorker/MailKitWorker.cs
index 8c995e9..16ea973 100644
--- a/Pizzeria/PizzeriaBusinessLogic/MailWorker/MailKitWorker.cs
+++ b/Pizzeria/PizzeriaBusinessLogic/MailWorker/MailKitWorker.cs
@@ -11,7 +11,7 @@ namespace PizzeriaBusinessLogic.MailWorker
{
public class MailKitWorker : AbstractMailWorker
{
- public MailKitWorker(ILogger logger, IMessageInfoLogic messageInfoLogic) : base(logger, messageInfoLogic) { }
+ public MailKitWorker(ILogger logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic) : base(logger, messageInfoLogic, clientLogic) { }
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
{
using var objMailMessage = new MailMessage();
diff --git a/Pizzeria/PizzeriaBusinessLogic/MessageInfoLogic .cs b/Pizzeria/PizzeriaBusinessLogic/MessageInfoLogic .cs
new file mode 100644
index 0000000..760ac90
--- /dev/null
+++ b/Pizzeria/PizzeriaBusinessLogic/MessageInfoLogic .cs
@@ -0,0 +1,48 @@
+using Microsoft.Extensions.Logging;
+using PizzeriaContracts.BindingModels;
+using PizzeriaContracts.BusinessLogicsContracts;
+using PizzeriaContracts.SearchModels;
+using PizzeriaContracts.StoragesContracts;
+using PizzeriaContracts.ViewModels;
+
+namespace PizzeriaBusinessLogic
+{
+ public class MessageInfoLogic : IMessageInfoLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IMessageInfoStorage _messageInfoStorage;
+
+ public MessageInfoLogic(ILogger logger, IMessageInfoStorage MessageInfoStorage)
+ {
+ _logger = logger;
+ _messageInfoStorage = MessageInfoStorage;
+ }
+
+ public bool Create(MessageInfoBindingModel model)
+ {
+ if (_messageInfoStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public List? ReadList(MessageInfoSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId} ", model?.MessageId, model?.ClientId);
+
+ var list = (model == null) ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+
+ return list;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs b/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs
index 698cd75..4261f7a 100644
--- a/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs
+++ b/Pizzeria/PizzeriaBusinessLogic/OrderLogic.cs
@@ -5,6 +5,8 @@ using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using PizzeriaDataModels;
using Microsoft.Extensions.Logging;
+using PizzeriaBusinessLogic.MailWorker;
+using DocumentFormat.OpenXml.Validation;
namespace PizzeriaBusinessLogic
{
@@ -12,10 +14,14 @@ namespace PizzeriaBusinessLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
- public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ private readonly IClientStorage _clientStorage;
+ private readonly AbstractMailWorker _mailWorker;
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage, IClientStorage clientStorage, AbstractMailWorker mailWorker)
{
_logger = logger;
_orderStorage = orderStorage;
+ _clientStorage = clientStorage;
+ _mailWorker = mailWorker;
}
public List? ReadList(OrderSearchModel? model)
{
@@ -55,11 +61,22 @@ namespace PizzeriaBusinessLogic
model.Status = OrderStatus.Принят;
- if (_orderStorage.Insert(model) == null)
+ var result = _orderStorage.Insert(model);
+ if(result == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
+
+ var client = _clientStorage.GetElement(new ClientSearchModel { Id = model.ClientId });
+
+ _mailWorker.MailSendAsync(new MailSendInfoBindingModel()
+ {
+ MailAddress = client.Email,
+ Subject = $"Создан новый заказ {result.Id}",
+ Text = $"Заказ {result.Id} от {result.DateCreate} на сумму {result.Sum:0.00} принят"
+ });
+
return true;
}
public bool UpdateStatus(OrderBindingModel model, OrderStatus newStatus)
@@ -77,6 +94,7 @@ namespace PizzeriaBusinessLogic
}
model.Status = order.Status;
+ model.ClientId = order.ClientId;
if(!model.ImplementerId.HasValue) model.ImplementerId = order.ImplementerId;
if(model.Status + 1 != newStatus)
@@ -97,6 +115,16 @@ namespace PizzeriaBusinessLogic
_logger.LogWarning("Update operation failed");
return false;
}
+
+ var client = _clientStorage.GetElement(new ClientSearchModel { Id = model.ClientId });
+
+ _mailWorker.MailSendAsync(new MailSendInfoBindingModel()
+ {
+ MailAddress = client.Email,
+ Subject = $"Изменен статус заказа {model.Id}",
+ Text = $"Статус заказа {model.Id} изменен на {newStatus}"
+ });
+
return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
diff --git a/Pizzeria/PizzeriaClientApp/Controllers/HomeController.cs b/Pizzeria/PizzeriaClientApp/Controllers/HomeController.cs
index caff2d2..86cf99e 100644
--- a/Pizzeria/PizzeriaClientApp/Controllers/HomeController.cs
+++ b/Pizzeria/PizzeriaClientApp/Controllers/HomeController.cs
@@ -156,7 +156,7 @@ namespace PizzeriaClientApp.Controllers
return Redirect("~/Home/Enter");
}
return
- View(APIClient.GetRequest>($"api/client/getmessages?clientId ={ APIClient.Client.Id}"));
-}
+ View(APIClient.GetRequest>($"api/client/getmessages?clientId={APIClient.Client.Id}"));
+ }
}
}
diff --git a/Pizzeria/PizzeriaClientApp/Views/Shared/_Layout.cshtml b/Pizzeria/PizzeriaClientApp/Views/Shared/_Layout.cshtml
index 55dbda5..f668b82 100644
--- a/Pizzeria/PizzeriaClientApp/Views/Shared/_Layout.cshtml
+++ b/Pizzeria/PizzeriaClientApp/Views/Shared/_Layout.cshtml
@@ -47,7 +47,7 @@
diff --git a/Pizzeria/PizzeriaDatabaseImplement/Implements/MessageInfoStorage.cs b/Pizzeria/PizzeriaDatabaseImplement/Implements/MessageInfoStorage.cs
new file mode 100644
index 0000000..4baaecf
--- /dev/null
+++ b/Pizzeria/PizzeriaDatabaseImplement/Implements/MessageInfoStorage.cs
@@ -0,0 +1,56 @@
+using PizzeriaContracts.BindingModels;
+using PizzeriaContracts.SearchModels;
+using PizzeriaContracts.StoragesContracts;
+using PizzeriaContracts.ViewModels;
+using PizzeriaDatabaseImplement.models;
+
+namespace PizzeriaDatabaseImplement.Implements
+{
+ public class MessageInfoStorage : IMessageInfoStorage
+ {
+ public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
+ {
+ using var context = new PizzeriaDatabase();
+
+ if (model.MessageId != null)
+ {
+ return context.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
+ }
+
+ return null;
+ }
+
+ public List GetFilteredList(MessageInfoSearchModel model)
+ {
+ using var context = new PizzeriaDatabase();
+ return context.Messages
+ .Where(x => x.ClientId == model.ClientId)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+
+ public List GetFullList()
+ {
+ using var context = new PizzeriaDatabase();
+ return context.Messages
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+
+ public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
+ {
+ using var context = new PizzeriaDatabase();
+
+ var newMessage = MessageInfo.Create(model);
+ if (newMessage == null || context.Messages.Any(x => x.MessageId.Equals(model.MessageId)))
+ {
+ return null;
+ }
+
+ context.Messages.Add(newMessage);
+ context.SaveChanges();
+
+ return newMessage.GetViewModel;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230424134053_AddMails.Designer.cs b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230424134053_AddMails.Designer.cs
new file mode 100644
index 0000000..bd3d48d
--- /dev/null
+++ b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230424134053_AddMails.Designer.cs
@@ -0,0 +1,285 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using PizzeriaDatabaseImplement;
+
+#nullable disable
+
+namespace PizzeriaDatabaseImplement.Migrations
+{
+ [DbContext(typeof(PizzeriaDatabase))]
+ [Migration("20230424134053_AddMails")]
+ partial class AddMails
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClientFIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Clients");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Cost")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Implementer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ImplementerFIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Qualification")
+ .HasColumnType("integer");
+
+ b.Property("WorkExperience")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.ToTable("Implementers");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.MessageInfo", b =>
+ {
+ b.Property("MessageId")
+ .HasColumnType("text");
+
+ b.Property("Body")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
+
+ b.Property("DateDelivery")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SenderName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Subject")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("MessageId");
+
+ b.ToTable("Messages");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("DateCreate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateImplement")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ImplementerId")
+ .HasColumnType("integer");
+
+ b.Property("PizzaId")
+ .HasColumnType("integer");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("Sum")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("ImplementerId");
+
+ b.HasIndex("PizzaId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Pizza", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("PizzaName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.ToTable("Pizzas");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.PizzaComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("PizzaId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComponentId");
+
+ b.HasIndex("PizzaId");
+
+ b.ToTable("PizzaComponents");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Order", b =>
+ {
+ b.HasOne("PizzeriaDatabaseImplement.models.Client", "Client")
+ .WithMany("Orders")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PizzeriaDatabaseImplement.models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
+ b.HasOne("PizzeriaDatabaseImplement.models.Pizza", "Pizza")
+ .WithMany("Orders")
+ .HasForeignKey("PizzaId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Client");
+
+ b.Navigation("Implementer");
+
+ b.Navigation("Pizza");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.PizzaComponent", b =>
+ {
+ b.HasOne("PizzeriaDatabaseImplement.models.Component", "Component")
+ .WithMany("PizzaComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PizzeriaDatabaseImplement.models.Pizza", "Pizza")
+ .WithMany("Components")
+ .HasForeignKey("PizzaId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Pizza");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Client", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Component", b =>
+ {
+ b.Navigation("PizzaComponents");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Pizza", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230424134053_AddMails.cs b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230424134053_AddMails.cs
new file mode 100644
index 0000000..b3ced49
--- /dev/null
+++ b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230424134053_AddMails.cs
@@ -0,0 +1,38 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace PizzeriaDatabaseImplement.Migrations
+{
+ ///
+ public partial class AddMails : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Messages",
+ columns: table => new
+ {
+ MessageId = table.Column(type: "text", nullable: false),
+ ClientId = table.Column(type: "integer", nullable: true),
+ SenderName = table.Column(type: "text", nullable: false),
+ DateDelivery = table.Column(type: "timestamp with time zone", nullable: false),
+ Subject = table.Column(type: "text", nullable: false),
+ Body = table.Column(type: "text", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Messages", x => x.MessageId);
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Messages");
+ }
+ }
+}
diff --git a/Pizzeria/PizzeriaDatabaseImplement/Migrations/PizzeriaDatabaseModelSnapshot.cs b/Pizzeria/PizzeriaDatabaseImplement/Migrations/PizzeriaDatabaseModelSnapshot.cs
index 242f772..8b7bcfd 100644
--- a/Pizzeria/PizzeriaDatabaseImplement/Migrations/PizzeriaDatabaseModelSnapshot.cs
+++ b/Pizzeria/PizzeriaDatabaseImplement/Migrations/PizzeriaDatabaseModelSnapshot.cs
@@ -94,6 +94,34 @@ namespace PizzeriaDatabaseImplement.Migrations
b.ToTable("Implementers");
});
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.MessageInfo", b =>
+ {
+ b.Property("MessageId")
+ .HasColumnType("text");
+
+ b.Property("Body")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
+
+ b.Property("DateDelivery")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SenderName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Subject")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("MessageId");
+
+ b.ToTable("Messages");
+ });
+
modelBuilder.Entity("PizzeriaDatabaseImplement.models.Order", b =>
{
b.Property("Id")
diff --git a/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs b/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs
index d7f7f60..47b56fe 100644
--- a/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs
+++ b/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs
@@ -17,6 +17,7 @@ namespace PizzeriaDatabaseImplement
public virtual DbSet Pizzas { set; get; }
public virtual DbSet Clients { set; get; }
public virtual DbSet Implementers { set; get; }
+ public virtual DbSet Messages { set; get; }
public virtual DbSet PizzaComponents { set; get; }
public virtual DbSet Orders { set; get; }
}
diff --git a/Pizzeria/PizzeriaDatabaseImplement/models/MessageInfo.cs b/Pizzeria/PizzeriaDatabaseImplement/models/MessageInfo.cs
new file mode 100644
index 0000000..72ac7ef
--- /dev/null
+++ b/Pizzeria/PizzeriaDatabaseImplement/models/MessageInfo.cs
@@ -0,0 +1,48 @@
+using PizzeriaContracts.BindingModels;
+using PizzeriaContracts.ViewModels;
+using PizzeriaDataModels.Models;
+using System.ComponentModel.DataAnnotations;
+
+namespace PizzeriaDatabaseImplement.models
+{
+ public class MessageInfo : IMessageInfoModel
+ {
+ [Key]
+ public string MessageId { get; set; } = string.Empty;
+ public int? ClientId { get; set; }
+ [Required]
+ public string SenderName { get; set; } = string.Empty;
+ [Required]
+ public DateTime DateDelivery { get; set; }
+ [Required]
+ public string Subject { get; set; } = string.Empty;
+ [Required]
+ public string Body { get; set; } = string.Empty;
+ public static MessageInfo? Create(MessageInfoBindingModel model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+
+ return new()
+ {
+ MessageId = model.MessageId,
+ SenderName = model.SenderName,
+ ClientId = model.ClientId,
+ DateDelivery = DateTime.SpecifyKind(model.DateDelivery, DateTimeKind.Utc),
+ Subject = model.Subject,
+ Body = model.Body
+ };
+ }
+
+ public MessageInfoViewModel GetViewModel => new()
+ {
+ MessageId = MessageId,
+ SenderName = SenderName,
+ DateDelivery = DateDelivery,
+ Subject = Subject,
+ Body = Body
+ };
+ }
+}
diff --git a/Pizzeria/PizzeriaRestApi/Controllers/ClientController.cs b/Pizzeria/PizzeriaRestApi/Controllers/ClientController.cs
index 7183fdc..7c791bb 100644
--- a/Pizzeria/PizzeriaRestApi/Controllers/ClientController.cs
+++ b/Pizzeria/PizzeriaRestApi/Controllers/ClientController.cs
@@ -3,6 +3,8 @@ using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
+using System.Collections.Generic;
+
namespace AbstractShopRestApi.Controllers
{
[Route("api/[controller]/[action]")]
@@ -61,6 +63,7 @@ namespace AbstractShopRestApi.Controllers
throw;
}
}
+ [HttpGet]
public List? GetMessages(int clientId)
{
try
diff --git a/Pizzeria/PizzeriaRestApi/Program.cs b/Pizzeria/PizzeriaRestApi/Program.cs
index 6f122b0..c9ed5f3 100644
--- a/Pizzeria/PizzeriaRestApi/Program.cs
+++ b/Pizzeria/PizzeriaRestApi/Program.cs
@@ -14,10 +14,13 @@ builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
+builder.Services.AddSingleton();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at
https://aka.ms/aspnetcore/swashbuckle
@@ -26,9 +29,8 @@ builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
- Title = "AbstractShopRestApi",
- Version
- = "v1"
+ Title = "PizzeriaRestApi",
+ Version = "v1"
});
});
var app = builder.Build();
@@ -47,8 +49,7 @@ mailSender?.MailConfig(new MailConfigBindingModel
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
- app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
- "AbstractShopRestApi v1"));
+ app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzeriaRestApi v1"));
}
app.UseAuthorization();
app.MapControllers();
diff --git a/Pizzeria/PizzeriaRestApi/appsettings.json b/Pizzeria/PizzeriaRestApi/appsettings.json
index 665f96f..cf48567 100644
--- a/Pizzeria/PizzeriaRestApi/appsettings.json
+++ b/Pizzeria/PizzeriaRestApi/appsettings.json
@@ -10,6 +10,6 @@
"SmtpClientPort": "587",
"PopHost": "pop.gmail.com",
"PopPort": "995",
- "MailLogin": "labwork15kafis@gmail.com",
- "MailPassword": "passlab15"
+ "MailLogin": "7labmaxkarme@gmail.com",
+ "MailPassword": "tpbp digc rlzk bcbd"
}
\ No newline at end of file