lab7
This commit is contained in:
parent
4e86563468
commit
722792852e
11
Bar/Bar/App.config
Normal file
11
Bar/Bar/App.config
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="SmtpClientHost" value="smtp.gmail.com" />
|
||||||
|
<add key="SmtpClientPort" value="587" />
|
||||||
|
<add key="PopHost" value="pop.gmail.com" />
|
||||||
|
<add key="PopPort" value="995" />
|
||||||
|
<add key="MailLogin" value="danilafilippov7299@gmail.com" />
|
||||||
|
<add key="MailPassword" value="ayks nyia mgiv hzlf" />
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
12
Bar/Bar/FormMain.Designer.cs
generated
12
Bar/Bar/FormMain.Designer.cs
generated
@ -45,6 +45,7 @@
|
|||||||
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.MailToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -115,7 +116,8 @@
|
|||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.ToolStripMenu,
|
this.ToolStripMenu,
|
||||||
this.отчётыToolStripMenuItem,
|
this.отчётыToolStripMenuItem,
|
||||||
this.запускРаботToolStripMenuItem});
|
this.запускРаботToolStripMenuItem,
|
||||||
|
this.MailToolStripMenuItem});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(1279, 28);
|
this.menuStrip1.Size = new System.Drawing.Size(1279, 28);
|
||||||
@ -199,6 +201,13 @@
|
|||||||
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
|
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||||
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
|
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// MailToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.MailToolStripMenuItem.Name = "MailToolStripMenuItem";
|
||||||
|
this.MailToolStripMenuItem.Size = new System.Drawing.Size(65, 24);
|
||||||
|
this.MailToolStripMenuItem.Text = "Почта";
|
||||||
|
this.MailToolStripMenuItem.Click += new System.EventHandler(this.MailToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
@ -241,5 +250,6 @@
|
|||||||
private ToolStripMenuItem ClientsToolStripMenuItem;
|
private ToolStripMenuItem ClientsToolStripMenuItem;
|
||||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
private ToolStripMenuItem EmployersToolStripMenuItem;
|
private ToolStripMenuItem EmployersToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem MailToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,9 +39,11 @@ namespace BarView
|
|||||||
{
|
{
|
||||||
DataGridView.DataSource = List;
|
DataGridView.DataSource = List;
|
||||||
DataGridView.Columns["CocktailId"].Visible = false;
|
DataGridView.Columns["CocktailId"].Visible = false;
|
||||||
|
DataGridView.Columns["ClientEmail"].Visible = false;
|
||||||
DataGridView.Columns["ClientId"].Visible = false;
|
DataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
DataGridView.Columns["ClientEmail"].Visible = false;
|
||||||
DataGridView.Columns["ImplementerId"].Visible = false;
|
DataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
DataGridView.Columns["CocktailName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
DataGridView.Columns["CocktailName"].Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
@ -229,5 +231,15 @@ namespace BarView
|
|||||||
Form.ShowDialog();
|
Form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var Service = Program.ServiceProvider?.GetService(typeof(FormMail));
|
||||||
|
|
||||||
|
if (Service is FormMail Form)
|
||||||
|
{
|
||||||
|
Form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
68
Bar/Bar/Forms/FormMail.Designer.cs
generated
Normal file
68
Bar/Bar/Forms/FormMail.Designer.cs
generated
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
namespace BarView.Forms
|
||||||
|
{
|
||||||
|
partial class FormMail
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
DataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
DataGridView.AllowUserToAddRows = false;
|
||||||
|
DataGridView.AllowUserToDeleteRows = false;
|
||||||
|
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
DataGridView.Dock = DockStyle.Fill;
|
||||||
|
DataGridView.Location = new Point(0, 0);
|
||||||
|
DataGridView.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
DataGridView.Name = "DataGridView";
|
||||||
|
DataGridView.ReadOnly = true;
|
||||||
|
DataGridView.RowHeadersWidth = 51;
|
||||||
|
DataGridView.RowTemplate.Height = 29;
|
||||||
|
DataGridView.Size = new Size(1084, 456);
|
||||||
|
DataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// FormMail
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1084, 456);
|
||||||
|
Controls.Add(DataGridView);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
|
Name = "FormMail";
|
||||||
|
Text = "Письма";
|
||||||
|
Load += FormMail_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView DataGridView;
|
||||||
|
}
|
||||||
|
}
|
47
Bar/Bar/Forms/FormMail.cs
Normal file
47
Bar/Bar/Forms/FormMail.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using BarContracts.BusinessLogicContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BarView.Forms
|
||||||
|
{
|
||||||
|
public partial class FormMail : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IMessageInfoLogic _messageLogic;
|
||||||
|
|
||||||
|
public FormMail(ILogger<FormMail> Logger, IMessageInfoLogic MessageLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_logger = Logger;
|
||||||
|
_messageLogic = MessageLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var List = _messageLogic.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMail_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Bar/Bar/Forms/FormMail.resx
Normal file
120
Bar/Bar/Forms/FormMail.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<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>
|
@ -9,8 +9,8 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using BarContracts.BusinessLogicsContracts;
|
using BarContracts.BusinessLogicsContracts;
|
||||||
using BarContracts.BusinessLogicContracts;
|
using BarBusinessLogic.MailWorker;
|
||||||
|
using BarContracts.BindingModels;
|
||||||
|
|
||||||
namespace BarView
|
namespace BarView
|
||||||
{
|
{
|
||||||
@ -28,9 +28,33 @@ namespace BarView
|
|||||||
ConfigureServices(Services);
|
ConfigureServices(Services);
|
||||||
|
|
||||||
_serviceProvider = Services.BuildServiceProvider();
|
_serviceProvider = Services.BuildServiceProvider();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var MailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||||
|
MailSender?.MailConfig(new MailConfigBindingModel
|
||||||
|
{
|
||||||
|
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["SmtpClientPort"]),
|
||||||
|
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
||||||
|
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
||||||
|
});
|
||||||
|
|
||||||
|
var Timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 5000);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var Logger = _serviceProvider.GetService<ILogger>();
|
||||||
|
Logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
|
}
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.CheckMailAsync();
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection Services)
|
private static void ConfigureServices(ServiceCollection Services)
|
||||||
{
|
{
|
||||||
Services.AddLogging(option =>
|
Services.AddLogging(option =>
|
||||||
@ -42,9 +66,9 @@ namespace BarView
|
|||||||
Services.AddTransient<IComponentStorage, ComponentStorage>();
|
Services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||||
Services.AddTransient<IOrderStorage, OrderStorage>();
|
Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
Services.AddTransient<ICocktailStorage, CocktailStorage>();
|
Services.AddTransient<ICocktailStorage, CocktailStorage>();
|
||||||
|
|
||||||
Services.AddTransient<IClientStorage, ClientStorage>();
|
Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
|
||||||
Services.AddTransient<IComponentLogic, ComponentLogic>();
|
Services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
Services.AddTransient<IOrderLogic, OrderLogic>();
|
Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
@ -53,10 +77,12 @@ namespace BarView
|
|||||||
Services.AddTransient<IClientLogic, ClientLogic>();
|
Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
Services.AddTransient<IWorkProcess, WorkModeling>();
|
Services.AddTransient<IWorkProcess, WorkModeling>();
|
||||||
|
Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
|
||||||
Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
Services.AddTransient<FormMain>();
|
Services.AddTransient<FormMain>();
|
||||||
Services.AddTransient<FormComponent>();
|
Services.AddTransient<FormComponent>();
|
||||||
@ -70,6 +96,7 @@ namespace BarView
|
|||||||
Services.AddTransient<FormClients>();
|
Services.AddTransient<FormClients>();
|
||||||
Services.AddTransient<FormImplementers>();
|
Services.AddTransient<FormImplementers>();
|
||||||
Services.AddTransient<FormImplementer>();
|
Services.AddTransient<FormImplementer>();
|
||||||
|
Services.AddTransient<FormMail>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
|
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
|
||||||
|
<PackageReference Include="MailKit" Version="4.6.0" />
|
||||||
<PackageReference Include="NLog" Version="5.3.2" />
|
<PackageReference Include="NLog" Version="5.3.2" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
using BarContracts.BindingModels;
|
||||||
|
using BarContracts.BusinessLogicContracts;
|
||||||
|
using BarContracts.SearchModels;
|
||||||
|
using BarContracts.StoragesContracts;
|
||||||
|
using BarContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BarBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class MessageInfoLogic : IMessageInfoLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IMessageInfoStorage _messageInfoStorage;
|
||||||
|
private readonly IClientStorage _clientStorage;
|
||||||
|
|
||||||
|
public MessageInfoLogic(ILogger<MessageInfoLogic> Logger, IMessageInfoStorage MessageInfoStorage, IClientStorage ClientStorage)
|
||||||
|
{
|
||||||
|
_logger = Logger;
|
||||||
|
_messageInfoStorage = MessageInfoStorage;
|
||||||
|
_clientStorage = ClientStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? Model)
|
||||||
|
{
|
||||||
|
_logger.LogDebug("ReadList. MessageId: {MessageId}, ClientId: {ClientId}", Model?.MessageId, Model?.ClientId);
|
||||||
|
|
||||||
|
var Result = Model == null ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(Model);
|
||||||
|
|
||||||
|
_logger.LogDebug("ReadList result. Count: {Count}", Result.Count);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(MessageInfoBindingModel Model)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
CheckModel(Model);
|
||||||
|
|
||||||
|
if (_messageInfoStorage.Insert(Model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(MessageInfoBindingModel Model, bool WithParams = true)
|
||||||
|
{
|
||||||
|
if (Model == null)
|
||||||
|
throw new ArgumentNullException(nameof(Model));
|
||||||
|
|
||||||
|
if (!WithParams)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Model.MessageId))
|
||||||
|
throw new ArgumentNullException("Не указан id сообщения", nameof(Model.MessageId));
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Model.SenderName))
|
||||||
|
throw new ArgumentNullException("Не указао почта", nameof(Model.SenderName));
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Model.Subject))
|
||||||
|
throw new ArgumentNullException("Не указана тема", nameof(Model.Subject));
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Model.Body))
|
||||||
|
throw new ArgumentNullException("Не указан текст сообщения", nameof(Model.Subject));
|
||||||
|
|
||||||
|
_logger.LogInformation("MessageInfo. MessageId: {MessageId}. SenderName: {SenderName}. Subject: {Subject}. Body: {Body}",
|
||||||
|
Model.MessageId, Model.SenderName, Model.Subject, Model.Body);
|
||||||
|
|
||||||
|
var Element = _clientStorage.GetElement(new ClientSearchModel
|
||||||
|
{
|
||||||
|
Email = Model.SenderName
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Не удалось найти клиента, отправившего письмо с адреса {Email}", Model.SenderName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Model.ClientId = Element.Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using BarContracts.BindingModels;
|
using BarBusinessLogic.MailWorker;
|
||||||
|
using BarContracts.BindingModels;
|
||||||
using BarContracts.BusinessLogicContracts;
|
using BarContracts.BusinessLogicContracts;
|
||||||
using BarContracts.SearchModels;
|
using BarContracts.SearchModels;
|
||||||
using BarContracts.StoragesContracts;
|
using BarContracts.StoragesContracts;
|
||||||
@ -14,23 +15,28 @@ namespace BarBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
|
||||||
public OrderLogic(ILogger<CocktailLogic> Logger, IOrderStorage OrderStorage)
|
private readonly AbstractMailWorker _mailLogic;
|
||||||
|
|
||||||
|
static readonly object _locker = new object();
|
||||||
|
|
||||||
|
public OrderLogic(ILogger<CocktailLogic> Logger, IOrderStorage OrderStorage, AbstractMailWorker MailLogic)
|
||||||
{
|
{
|
||||||
_logger = Logger;
|
_logger = Logger;
|
||||||
_orderStorage = OrderStorage;
|
_orderStorage = OrderStorage;
|
||||||
|
_mailLogic = MailLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? Model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? Model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Id:{Id}", Model?.Id);
|
_logger.LogInformation("ReadList. ClientId: {ClientId}. Status: {Status}. ImplementerId: {ImplementerId}. DateFrom: {DateFrom}. DateTo: {DateTo}. OrderId: {Id}",
|
||||||
var List = Model is null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(Model);
|
Model?.ClientId, Model?.Status, Model?.ImplementerId, Model?.DateFrom, Model?.DateTo, Model?.Id);
|
||||||
|
|
||||||
|
var List = Model is null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(Model);
|
||||||
if (List is null)
|
if (List is null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("ReadList. Count: {Count}", List.Count);
|
_logger.LogInformation("ReadList. Count: {Count}", List.Count);
|
||||||
return List;
|
return List;
|
||||||
}
|
}
|
||||||
@ -47,21 +53,28 @@ namespace BarBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
Model.Status = OrderStatus.Accepted;
|
Model.Status = OrderStatus.Accepted;
|
||||||
|
|
||||||
if (_orderStorage.Insert(Model) is null)
|
var CreatedOrder = _orderStorage.Insert(Model);
|
||||||
|
|
||||||
|
if (CreatedOrder == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Task.Run(() => _mailLogic.SendMailAsync(new MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
MailAddress = CreatedOrder.ClientEmail,
|
||||||
|
Subject = $"Изменение статуса заказа номер {CreatedOrder.Id}",
|
||||||
|
Text = $"Ваш заказ номер {CreatedOrder.Id} на коктейль {CreatedOrder.CocktailName} от {CreatedOrder.DateCreate} на сумму {CreatedOrder.Sum} принят."
|
||||||
|
}));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ChangeOrderStatus(OrderBindingModel Model, OrderStatus NewStatus)
|
private bool ChangeOrderStatus(OrderBindingModel Model, OrderStatus NewStatus)
|
||||||
{
|
{
|
||||||
CheckModel(Model, false);
|
CheckModel(Model, false);
|
||||||
|
|
||||||
var Order = _orderStorage.GetElement(new OrderSearchModel { Id = Model.Id });
|
var Order = _orderStorage.GetElement(new OrderSearchModel { Id = Model.Id });
|
||||||
|
|
||||||
if (Order == null)
|
if (Order == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Change status operation failed. Order not found");
|
_logger.LogWarning("Change status operation failed. Order not found");
|
||||||
@ -94,12 +107,23 @@ namespace BarBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string DateInfo = Model.DateImplement.HasValue ? $"Дата выполнения: {Model.DateImplement}" : "";
|
||||||
|
Task.Run(() => _mailLogic.SendMailAsync(new MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
MailAddress = Order.ClientEmail,
|
||||||
|
Subject = $"Изменение статуса заказа номер {Order.Id}",
|
||||||
|
Text = $"Ваш заказ номер {Order.Id} на ремонт {Order.CocktailName} от {Order.DateCreate} на сумму {Order.Sum}. Статус изменен на {NewStatus}. {DateInfo}"
|
||||||
|
}));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel Model)
|
public bool TakeOrderInWork(OrderBindingModel Model)
|
||||||
{
|
{
|
||||||
return ChangeOrderStatus(Model, OrderStatus.BeingProcessed);
|
lock (_locker)
|
||||||
|
{
|
||||||
|
return ChangeOrderStatus(Model, OrderStatus.BeingProcessed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel Model)
|
public bool FinishOrder(OrderBindingModel Model)
|
||||||
@ -121,7 +145,7 @@ namespace BarBusinessLogic.BusinessLogics
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (Model.Count <= 0)
|
if (Model.Count <= 0)
|
||||||
throw new ArgumentNullException("Количество напитков в заказе быть больше 0", nameof(Model.Count));
|
throw new ArgumentNullException("Количество ремонтов в заказе быть больше 0", nameof(Model.Count));
|
||||||
|
|
||||||
if (Model.Sum <= 0)
|
if (Model.Sum <= 0)
|
||||||
throw new ArgumentNullException("Стоимость заказа должна быть больше 0", nameof(Model.Sum));
|
throw new ArgumentNullException("Стоимость заказа должна быть больше 0", nameof(Model.Sum));
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
using BarContracts.BindingModels;
|
||||||
|
using BarContracts.BusinessLogicContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BarBusinessLogic.MailWorker
|
||||||
|
{
|
||||||
|
public abstract class AbstractMailWorker
|
||||||
|
{
|
||||||
|
protected string _mailLogin = string.Empty;
|
||||||
|
|
||||||
|
protected string _mailPassword = string.Empty;
|
||||||
|
|
||||||
|
protected string _smtpClientHost = string.Empty;
|
||||||
|
|
||||||
|
protected int _smtpClientPort;
|
||||||
|
|
||||||
|
protected string _popHost = string.Empty;
|
||||||
|
|
||||||
|
protected int _popPort;
|
||||||
|
|
||||||
|
private readonly IMessageInfoLogic _messageInfoLogic;
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public AbstractMailWorker(ILogger<AbstractMailWorker> Logger, IMessageInfoLogic MessageInfoLogic)
|
||||||
|
{
|
||||||
|
_logger = Logger;
|
||||||
|
_messageInfoLogic = MessageInfoLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MailConfig(MailConfigBindingModel Config)
|
||||||
|
{
|
||||||
|
_mailLogin = Config.MailLogin;
|
||||||
|
_mailPassword = Config.MailPassword;
|
||||||
|
_smtpClientHost = Config.SmtpClientHost;
|
||||||
|
_smtpClientPort = Config.SmtpClientPort;
|
||||||
|
_popHost = Config.PopHost;
|
||||||
|
_popPort = Config.PopPort;
|
||||||
|
|
||||||
|
_logger.LogDebug("MailConfig: {Login}, {Password}, {ClientHost}, {ClientPort}, {PopHost}, {PopPort}",
|
||||||
|
_mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void SendMailAsync(MailSendInfoBindingModel Info)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Info.MailAddress) || string.IsNullOrEmpty(Info.Subject) || string.IsNullOrEmpty(Info.Text))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_logger.LogDebug("MailSendAsync: {To}, {Subject}", Info.MailAddress, Info.Subject);
|
||||||
|
|
||||||
|
await SendMailImpl(Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void CheckMailAsync()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_messageInfoLogic == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var List = await ReceiveMailImpl();
|
||||||
|
_logger.LogDebug("CheckMailAsync: New mails: {Count}", List.Count);
|
||||||
|
|
||||||
|
foreach (var Mail in List)
|
||||||
|
{
|
||||||
|
_messageInfoLogic.Create(Mail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Task SendMailImpl(MailSendInfoBindingModel Info);
|
||||||
|
|
||||||
|
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailImpl();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
using BarContracts.BindingModels;
|
||||||
|
using BarContracts.BusinessLogicContracts;
|
||||||
|
using MailKit.Net.Pop3;
|
||||||
|
using MailKit.Security;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace BarBusinessLogic.MailWorker
|
||||||
|
{
|
||||||
|
public class MailKitWorker : AbstractMailWorker
|
||||||
|
{
|
||||||
|
public MailKitWorker(ILogger<MailKitWorker> Logger, IMessageInfoLogic MessageInfoLogic)
|
||||||
|
: base(Logger, MessageInfoLogic) { }
|
||||||
|
|
||||||
|
protected override async Task SendMailImpl(MailSendInfoBindingModel Info)
|
||||||
|
{
|
||||||
|
using var MailMessage = new MailMessage();
|
||||||
|
using var SmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MailMessage.From = new MailAddress(_mailLogin);
|
||||||
|
MailMessage.To.Add(new MailAddress(Info.MailAddress));
|
||||||
|
MailMessage.Subject = Info.Subject;
|
||||||
|
MailMessage.Body = Info.Text;
|
||||||
|
MailMessage.SubjectEncoding = Encoding.UTF8;
|
||||||
|
MailMessage.BodyEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
SmtpClient.UseDefaultCredentials = false;
|
||||||
|
SmtpClient.EnableSsl = true;
|
||||||
|
SmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||||
|
SmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||||
|
|
||||||
|
await Task.Run(() => SmtpClient.Send(MailMessage));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailImpl()
|
||||||
|
{
|
||||||
|
var Result = new List<MessageInfoBindingModel>();
|
||||||
|
|
||||||
|
using var Client = new Pop3Client();
|
||||||
|
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
|
||||||
|
Client.Authenticate(_mailLogin, _mailPassword);
|
||||||
|
|
||||||
|
for (int i = 0; i < Client.Count; i++)
|
||||||
|
{
|
||||||
|
var Message = Client.GetMessage(i);
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var Mail in Message.From.Mailboxes)
|
||||||
|
{
|
||||||
|
//if (Mail.Address.Contains("o.filippova"))
|
||||||
|
Result.Add(new MessageInfoBindingModel
|
||||||
|
{
|
||||||
|
DateDelivery = Message.Date.DateTime,
|
||||||
|
MessageId = Message.MessageId,
|
||||||
|
SenderName = Mail.Address,
|
||||||
|
Subject = Message.Subject,
|
||||||
|
Body = Message.TextBody
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (AuthenticationException)
|
||||||
|
{ }
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Client.Disconnect(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BarBusinessLogic\BarBusinessLogic\BarBusinessLogic.csproj" />
|
<ProjectReference Include="..\BarBusinessLogic\BarBusinessLogic\BarBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\BarContracts\BarContracts\BarContracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -156,5 +156,16 @@ namespace BarClientApp.Controllers
|
|||||||
CocktailViewModel? Cocktail = ApiClient.GetRequest<CocktailViewModel>($"api/main/getcocktail?cocktailId={cocktail}");
|
CocktailViewModel? Cocktail = ApiClient.GetRequest<CocktailViewModel>($"api/main/getcocktail?cocktailId={cocktail}");
|
||||||
return count * (Cocktail?.Price ?? 1);
|
return count * (Cocktail?.Price ?? 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Mails()
|
||||||
|
{
|
||||||
|
if (ApiClient.Client == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(ApiClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={ApiClient.Client.Id}"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Коктейль:</div>
|
<div class="col-4">Ремонт:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<select id="cocktail" name="cocktail" class="form-control" asp-items="@(new SelectList(@ViewBag.Cocktails,"Id", "CocktailName"))"></select>
|
<select id="cocktail" name="cocktail" class="form-control" asp-items="@(new SelectList(@ViewBag.Cocktails,"Id", "CocktailName"))"></select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
Номер
|
Номер
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Коктейль
|
Ремонт
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Дата создания
|
Дата создания
|
||||||
|
51
Bar/BarClientApp/Views/Home/Mails.cshtml
Normal file
51
Bar/BarClientApp/Views/Home/Mails.cshtml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
@using BarContracts.ViewModels
|
||||||
|
|
||||||
|
@model List<MessageInfoViewModel>
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Mails";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Заказы</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
if (Model == null)
|
||||||
|
{
|
||||||
|
<h3 class="display-4">Авторизируйтесь</h3>
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Дата письма
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Заголовок
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Текст
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var Item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(ModelItem => Item.DateDelivery)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(ModelItem => Item.Subject)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(ModelItem => Item.Body)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
@ -13,7 +13,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Магазин коктейльов</a>
|
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Магазин ремонтов</a>
|
||||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
@ -26,6 +26,9 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Mails">Письма</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||||
</li>
|
</li>
|
||||||
@ -44,7 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<footer class="border-top footer text-muted">
|
<footer class="border-top footer text-muted">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
© 2024 - Магазин коктейльов - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
© 2024 - Магазин ремонтов - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
namespace BarContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MailConfigBindingModel
|
||||||
|
{
|
||||||
|
public string MailLogin { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string MailPassword { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string SmtpClientHost { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int SmtpClientPort { get; set; }
|
||||||
|
|
||||||
|
public string PopHost { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int PopPort { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
namespace BarContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
public string MailAddress { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using BarDataModels.Models;
|
||||||
|
|
||||||
|
namespace BarContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MessageInfoBindingModel : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Body { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using BarContracts.BindingModels;
|
||||||
|
using BarContracts.SearchModels;
|
||||||
|
using BarContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BarContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IMessageInfoLogic
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? Model);
|
||||||
|
|
||||||
|
bool Create(MessageInfoBindingModel Model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace BarContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class MessageInfoSearchModel
|
||||||
|
{
|
||||||
|
public string? MessageId { get; set; }
|
||||||
|
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using BarContracts.BindingModels;
|
||||||
|
using BarContracts.SearchModels;
|
||||||
|
using BarContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BarContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IMessageInfoStorage
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> GetFullList();
|
||||||
|
|
||||||
|
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel Model);
|
||||||
|
|
||||||
|
MessageInfoViewModel? GetElement(MessageInfoSearchModel Model);
|
||||||
|
|
||||||
|
MessageInfoViewModel? Insert(MessageInfoBindingModel Model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
using BarDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BarContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Отправитель")]
|
||||||
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата доставки")]
|
||||||
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Тема")]
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Содержание")]
|
||||||
|
public string Body { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -8,34 +8,37 @@ namespace BarContracts.ViewModels
|
|||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int CocktailId { get; set; }
|
public int CocktailId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Коктейль")]
|
[DisplayName("Ремонт")]
|
||||||
public string CocktailName { get; set; } = string.Empty;
|
public string CocktailName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Клиент")]
|
[DisplayName("Клиент")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Почта клиента")]
|
||||||
|
public string ClientEmail { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Исполнитель")]
|
[DisplayName("Исполнитель")]
|
||||||
public string? ImplementerFIO { get; set; }
|
public string? ImplementerFIO { get; set; }
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
[DisplayName("Сумма")]
|
[DisplayName("Сумма")]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
[DisplayName("Статус")]
|
[DisplayName("Статус")]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Undefined;
|
public OrderStatus Status { get; set; } = OrderStatus.Undefined;
|
||||||
|
|
||||||
[DisplayName("Дата создания")]
|
[DisplayName("Дата создания")]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
[DisplayName("Дата выполнения")]
|
[DisplayName("Дата выполнения")]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
namespace BarContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class ReportCocktailComponentViewModel
|
|
||||||
{
|
|
||||||
public string CocktailName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int TotalCount { get; set; }
|
|
||||||
|
|
||||||
public List<(string Component, int Count)> Components { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
17
Bar/BarDataModels/BarDataModels/Models/IMessageInfoModel.cs
Normal file
17
Bar/BarDataModels/BarDataModels/Models/IMessageInfoModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace BarDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IMessageInfoModel
|
||||||
|
{
|
||||||
|
string MessageId { get; }
|
||||||
|
|
||||||
|
int? ClientId { get; }
|
||||||
|
|
||||||
|
string SenderName { get; }
|
||||||
|
|
||||||
|
DateTime DateDelivery { get; }
|
||||||
|
|
||||||
|
string Subject { get; }
|
||||||
|
|
||||||
|
string Body { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -29,5 +29,7 @@ namespace BarDatabaseImplement
|
|||||||
public virtual DbSet<Client> Clients { set; get; }
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
|
||||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<MessageInfo> Messages { set; get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
using BarContracts.BindingModels;
|
||||||
|
using BarContracts.SearchModels;
|
||||||
|
using BarContracts.StoragesContracts;
|
||||||
|
using BarContracts.ViewModels;
|
||||||
|
using BarDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace BarDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var Context = new BarDatabase();
|
||||||
|
|
||||||
|
return Context.Messages
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel Model)
|
||||||
|
{
|
||||||
|
using var Context = new BarDatabase();
|
||||||
|
|
||||||
|
return Context.Messages
|
||||||
|
.Where(x => x.ClientId.HasValue && x.ClientId == Model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel Model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Model.MessageId))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
using var Context = new BarDatabase();
|
||||||
|
|
||||||
|
return Context.Messages
|
||||||
|
.FirstOrDefault(x => x.MessageId == Model.MessageId)?
|
||||||
|
.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel Model)
|
||||||
|
{
|
||||||
|
var NewMessageInfo = MessageInfo.Create(Model);
|
||||||
|
|
||||||
|
if (NewMessageInfo == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
using var Context = new BarDatabase();
|
||||||
|
Context.Messages.Add(NewMessageInfo);
|
||||||
|
|
||||||
|
Context.SaveChanges();
|
||||||
|
return NewMessageInfo.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
284
Bar/BarDatabaseImplement/BarDatabaseImplement/Migrations/20240621172735_3.Designer.cs
generated
Normal file
284
Bar/BarDatabaseImplement/BarDatabaseImplement/Migrations/20240621172735_3.Designer.cs
generated
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using BarDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BarDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(BarDatabase))]
|
||||||
|
[Migration("20240621172735_3")]
|
||||||
|
partial class _3
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "6.0.0")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Cocktail", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("CocktailName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Cocktails");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.CocktailComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("CocktailId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CocktailId");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.ToTable("CocktailComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.MessageInfo", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("MessageId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Body")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int?>("ClientId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateDelivery")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<string>("SenderName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Subject")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("MessageId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("CocktailId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("CocktailId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.CocktailComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("BarDatabaseImplement.Models.Cocktail", "Cocktail")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("CocktailId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("BarDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("CocktailComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Cocktail");
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("BarDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("BarDatabaseImplement.Models.Cocktail", "Cocktail")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("CocktailId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("BarDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Order")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Cocktail");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Cocktail", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("CocktailComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Order");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BarDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
public partial class _3 : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Messages",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
MessageId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ClientId = table.Column<int>(type: "integer", nullable: true),
|
||||||
|
SenderName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
DateDelivery = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||||
|
Subject = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Body = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Messages");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -140,6 +140,34 @@ namespace BarDatabaseImplement.Migrations
|
|||||||
b.ToTable("Implementers");
|
b.ToTable("Implementers");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BarDatabaseImplement.Models.MessageInfo", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("MessageId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Body")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int?>("ClientId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateDelivery")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<string>("SenderName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Subject")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("MessageId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BarDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("BarDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -216,13 +244,15 @@ namespace BarDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("BarDatabaseImplement.Models.Implementer", null)
|
b.HasOne("BarDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
.WithMany("Order")
|
.WithMany("Order")
|
||||||
.HasForeignKey("ImplementerId");
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
b.Navigation("Cocktail");
|
b.Navigation("Cocktail");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BarDatabaseImplement.Models.Client", b =>
|
modelBuilder.Entity("BarDatabaseImplement.Models.Client", b =>
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
using BarContracts.BindingModels;
|
||||||
|
using BarContracts.ViewModels;
|
||||||
|
using BarDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace BarDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel? Model)
|
||||||
|
{
|
||||||
|
if (Model == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
MessageId = Model.MessageId,
|
||||||
|
ClientId = Model.ClientId,
|
||||||
|
SenderName = Model.SenderName,
|
||||||
|
DateDelivery = Model.DateDelivery,
|
||||||
|
Subject = Model.Subject,
|
||||||
|
Body = Model.Body
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
MessageId = MessageId,
|
||||||
|
ClientId = ClientId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
Subject = Subject,
|
||||||
|
Body = Body
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ namespace BarDatabaseImplement.Models
|
|||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
public virtual Client Client { get; set; }
|
public virtual Client Client { get; set; }
|
||||||
|
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
|
||||||
public virtual Implementer? Implementer { get; set; }
|
public virtual Implementer? Implementer { get; set; }
|
||||||
@ -74,6 +75,7 @@ namespace BarDatabaseImplement.Models
|
|||||||
ImplementerId = ImplementerId,
|
ImplementerId = ImplementerId,
|
||||||
CocktailName = Cocktail.CocktailName,
|
CocktailName = Cocktail.CocktailName,
|
||||||
ClientFIO = Client.ClientFIO,
|
ClientFIO = Client.ClientFIO,
|
||||||
|
ClientEmail = Client.Email,
|
||||||
ImplementerFIO = Implementer?.ImplementerFIO,
|
ImplementerFIO = Implementer?.ImplementerFIO,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
|
@ -12,13 +12,15 @@ namespace BarRestApi.Controllers
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IClientLogic _clientLogic;
|
private readonly IClientLogic _clientLogic;
|
||||||
|
private readonly IMessageInfoLogic _mailLogic;
|
||||||
public ClientController(IClientLogic ClientLogic, ILogger<ClientController> Logger)
|
|
||||||
|
public ClientController(IClientLogic ClientLogic, IMessageInfoLogic MailLogic, ILogger<ClientController> Logger)
|
||||||
{
|
{
|
||||||
_logger = Logger;
|
_logger = Logger;
|
||||||
_clientLogic = ClientLogic;
|
_clientLogic = ClientLogic;
|
||||||
|
_mailLogic = MailLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ClientViewModel? Login(string Login, string Password)
|
public ClientViewModel? Login(string Login, string Password)
|
||||||
{
|
{
|
||||||
@ -36,7 +38,7 @@ namespace BarRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void Register(ClientBindingModel Model)
|
public void Register(ClientBindingModel Model)
|
||||||
{
|
{
|
||||||
@ -50,7 +52,7 @@ namespace BarRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateData(ClientBindingModel Model)
|
public void UpdateData(ClientBindingModel Model)
|
||||||
{
|
{
|
||||||
@ -64,5 +66,22 @@ namespace BarRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<MessageInfoViewModel>? GetMessages(int ClientId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _mailLogic.ReadList(new MessageInfoSearchModel
|
||||||
|
{
|
||||||
|
ClientId = ClientId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения писем клиента");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
using BarBusinessLogic.BusinessLogics;
|
using BarBusinessLogic.BusinessLogics;
|
||||||
|
using BarBusinessLogic.MailWorker;
|
||||||
|
using BarContracts.BindingModels;
|
||||||
using BarContracts.BusinessLogicContracts;
|
using BarContracts.BusinessLogicContracts;
|
||||||
|
using BarContracts.BusinessLogicsContracts;
|
||||||
using BarContracts.StoragesContracts;
|
using BarContracts.StoragesContracts;
|
||||||
using BarDatabaseImplement.Implements;
|
using BarDatabaseImplement.Implements;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
@ -12,9 +15,17 @@ Builder.Logging.AddLog4Net("log4net.config");
|
|||||||
Builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
Builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
Builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
Builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
Builder.Services.AddTransient<ICocktailStorage, CocktailStorage>();
|
Builder.Services.AddTransient<ICocktailStorage, CocktailStorage>();
|
||||||
|
Builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
Builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
|
||||||
Builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
Builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
Builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
Builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
Builder.Services.AddTransient<ICocktailLogic, CocktailLogic>();
|
Builder.Services.AddTransient<ICocktailLogic, CocktailLogic>();
|
||||||
|
Builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
Builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
|
||||||
|
Builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
Builder.Services.AddControllers();
|
Builder.Services.AddControllers();
|
||||||
|
|
||||||
Builder.Services.AddEndpointsApiExplorer();
|
Builder.Services.AddEndpointsApiExplorer();
|
||||||
@ -29,6 +40,18 @@ Builder.Services.AddSwaggerGen(c =>
|
|||||||
|
|
||||||
var App = Builder.Build();
|
var App = Builder.Build();
|
||||||
|
|
||||||
|
var MailSender = App.Services.GetService<AbstractMailWorker>();
|
||||||
|
MailSender?.MailConfig(new MailConfigBindingModel
|
||||||
|
{
|
||||||
|
MailLogin = Builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty,
|
||||||
|
MailPassword = Builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty,
|
||||||
|
SmtpClientHost = Builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty,
|
||||||
|
SmtpClientPort = Convert.ToInt32(Builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
|
||||||
|
PopHost = Builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty,
|
||||||
|
PopPort = Convert.ToInt32(Builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if (App.Environment.IsDevelopment())
|
if (App.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
App.UseSwagger();
|
App.UseSwagger();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user