This commit is contained in:
DeerElk 2024-05-08 15:04:44 +04:00
parent 93ed433da9
commit a9b8cbf312
43 changed files with 1962 additions and 79 deletions

View File

@ -0,0 +1,174 @@
using System.Windows.Forms;
namespace ConfectioneryView
{
partial class FormImplementer
{
/// <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()
{
textBoxFIO = new TextBox();
textBoxPassword = new TextBox();
textBoxQualification = new TextBox();
textBoxWorkExperience = new TextBox();
labelFIO = new Label();
labelPassword = new Label();
labelQualification = new Label();
labelWorkExperience = new Label();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// textBoxFIO
//
textBoxFIO.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBoxFIO.Location = new Point(170, 11);
textBoxFIO.Name = "textBoxFIO";
textBoxFIO.Size = new Size(396, 31);
textBoxFIO.TabIndex = 0;
//
// textBoxPassword
//
textBoxPassword.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBoxPassword.Location = new Point(170, 57);
textBoxPassword.Name = "textBoxPassword";
textBoxPassword.Size = new Size(396, 31);
textBoxPassword.TabIndex = 1;
//
// textBoxQualification
//
textBoxQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBoxQualification.Location = new Point(170, 102);
textBoxQualification.Name = "textBoxQualification";
textBoxQualification.Size = new Size(396, 31);
textBoxQualification.TabIndex = 2;
//
// textBoxWorkExperience
//
textBoxWorkExperience.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBoxWorkExperience.Location = new Point(170, 149);
textBoxWorkExperience.Name = "textBoxWorkExperience";
textBoxWorkExperience.Size = new Size(159, 31);
textBoxWorkExperience.TabIndex = 3;
//
// labelFIO
//
labelFIO.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
labelFIO.AutoSize = true;
labelFIO.Location = new Point(16, 14);
labelFIO.Name = "labelFIO";
labelFIO.Size = new Size(56, 25);
labelFIO.TabIndex = 4;
labelFIO.Text = "ФИО:";
//
// labelPassword
//
labelPassword.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
labelPassword.AutoSize = true;
labelPassword.Location = new Point(16, 61);
labelPassword.Name = "labelPassword";
labelPassword.Size = new Size(78, 25);
labelPassword.TabIndex = 5;
labelPassword.Text = "Пароль:";
//
// labelQualification
//
labelQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
labelQualification.AutoSize = true;
labelQualification.Location = new Point(16, 108);
labelQualification.Name = "labelQualification";
labelQualification.Size = new Size(134, 25);
labelQualification.TabIndex = 6;
labelQualification.Text = "Квалификация:";
//
// labelWorkExperience
//
labelWorkExperience.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
labelWorkExperience.AutoSize = true;
labelWorkExperience.Location = new Point(16, 153);
labelWorkExperience.Name = "labelWorkExperience";
labelWorkExperience.Size = new Size(122, 25);
labelWorkExperience.TabIndex = 7;
labelWorkExperience.Text = "Стаж работы:";
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSave.Location = new Point(336, 148);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(112, 34);
buttonSave.TabIndex = 2;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(454, 148);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(112, 34);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormImplementer
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(578, 194);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelWorkExperience);
Controls.Add(labelQualification);
Controls.Add(labelPassword);
Controls.Add(labelFIO);
Controls.Add(textBoxWorkExperience);
Controls.Add(textBoxQualification);
Controls.Add(textBoxPassword);
Controls.Add(textBoxFIO);
Name = "FormImplementer";
Text = "Исполнитель";
Load += FormImplementer_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxFIO;
private TextBox textBoxPassword;
private TextBox textBoxQualification;
private TextBox textBoxWorkExperience;
private Label labelFIO;
private Label labelPassword;
private Label labelQualification;
private Label labelWorkExperience;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,100 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace ConfectioneryView
{
public partial class FormImplementer : Form
{
private readonly ILogger _logger;
private readonly IImplementerLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormImplementer(ILogger<FormImplementer> logger,
IImplementerLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormImplementer_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение исполнителя");
var view = _logic.ReadElement(new ImplementerSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxFIO.Text = view.ImplementerFIO;
textBoxPassword.Text = view.Password;
textBoxQualification.Text =
view.Qualification.ToString();
textBoxWorkExperience.Text =
view.WorkExperience.ToString();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFIO.Text))
{
MessageBox.Show("Заполните ФИО", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxPassword.Text))
{
MessageBox.Show("Заполните пароль", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение компонента");
try
{
var model = new ImplementerBindingModel
{
Id = _id ?? 0,
ImplementerFIO = textBoxFIO.Text,
Password = textBoxPassword.Text,
Qualification = Convert.ToInt32(textBoxQualification.Text),
WorkExperience = Convert.ToInt32(
textBoxWorkExperience.Text),
};
var operationResult = _id.HasValue ? _logic.Update(model) :
_logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. " +
"Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -0,0 +1,119 @@
namespace ConfectioneryView
{
partial class FormImplementers
{
/// <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();
buttonAdd = new Button();
buttonUpd = new Button();
buttonDel = new Button();
buttonRef = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonAdd
//
buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonAdd.Location = new Point(754, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(112, 56);
buttonAdd.TabIndex = 0;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonUpd
//
buttonUpd.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonUpd.Location = new Point(754, 74);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(112, 56);
buttonUpd.TabIndex = 1;
buttonUpd.Text = "Изменить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonDel
//
buttonDel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonDel.Location = new Point(754, 198);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(112, 56);
buttonDel.TabIndex = 2;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonRef
//
buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonRef.Location = new Point(754, 136);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(112, 56);
buttonRef.TabIndex = 3;
buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = SystemColors.Window;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 62;
dataGridView.Size = new Size(742, 444);
dataGridView.TabIndex = 4;
//
// FormImplementers
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(878, 444);
Controls.Add(buttonRef);
Controls.Add(buttonDel);
Controls.Add(buttonUpd);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormImplementers";
Text = "Исполнители";
Load += FormImplementers_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonRef;
}
}

View File

@ -0,0 +1,114 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace ConfectioneryView
{
public partial class FormImplementers : Form
{
private readonly ILogger _logger;
private readonly IImplementerLogic _logic;
public FormImplementers(ILogger<FormImplementers> logger,
IImplementerLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormImplementers_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ImplementerFIO"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Password"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Qualification"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["WorkExperience"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка компонентов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки исполнителей");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?
.GetService(typeof(FormImplementer));
if (service is FormImplementer form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?
.GetService(typeof(FormImplementer));
if (service is FormImplementer form)
{
form.Id = Convert.ToInt32(dataGridView
.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView
.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента");
try
{
if (!_logic.Delete(new ImplementerBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. " +
"Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления исполнителя");
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -39,10 +39,12 @@
componentsToolStripMenuItem = new ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem();
pastriesToolStripMenuItem = new ToolStripMenuItem(); pastriesToolStripMenuItem = new ToolStripMenuItem();
clientsToolStripMenuItem = new ToolStripMenuItem(); clientsToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem(); reportsToolStripMenuItem = new ToolStripMenuItem();
listOfComponentsToolStripMenuItem = new ToolStripMenuItem(); listOfComponentsToolStripMenuItem = new ToolStripMenuItem();
ComponentsByPastryToolStripMenuItem = new ToolStripMenuItem(); ComponentsByPastryToolStripMenuItem = new ToolStripMenuItem();
listOfOrdersToolStripMenuItem = new ToolStripMenuItem(); listOfOrdersToolStripMenuItem = new ToolStripMenuItem();
startWorkToolStripMenuItem = new ToolStripMenuItem();
implementersToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
menuStrip.SuspendLayout(); menuStrip.SuspendLayout();
SuspendLayout(); SuspendLayout();
@ -117,16 +119,16 @@
// //
menuStrip.Dock = DockStyle.None; menuStrip.Dock = DockStyle.None;
menuStrip.ImageScalingSize = new Size(24, 24); menuStrip.ImageScalingSize = new Size(24, 24);
menuStrip.Items.AddRange(new ToolStripItem[] { referencesToolStripMenuItem, отчётыToolStripMenuItem }); menuStrip.Items.AddRange(new ToolStripItem[] { referencesToolStripMenuItem, reportsToolStripMenuItem, startWorkToolStripMenuItem });
menuStrip.Location = new Point(0, 0); menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip"; menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(415, 33); menuStrip.Size = new Size(551, 33);
menuStrip.TabIndex = 8; menuStrip.TabIndex = 8;
menuStrip.Text = "menuStrip1"; menuStrip.Text = "menuStrip1";
// //
// referencesToolStripMenuItem // referencesToolStripMenuItem
// //
referencesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastriesToolStripMenuItem, clientsToolStripMenuItem }); referencesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, pastriesToolStripMenuItem, clientsToolStripMenuItem, implementersToolStripMenuItem });
referencesToolStripMenuItem.Name = "referencesToolStripMenuItem"; referencesToolStripMenuItem.Name = "referencesToolStripMenuItem";
referencesToolStripMenuItem.Size = new Size(139, 29); referencesToolStripMenuItem.Size = new Size(139, 29);
referencesToolStripMenuItem.Text = "Справочники"; referencesToolStripMenuItem.Text = "Справочники";
@ -152,12 +154,12 @@
clientsToolStripMenuItem.Text = "Клиенты"; clientsToolStripMenuItem.Text = "Клиенты";
clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
// //
// отчётыToolStripMenuItem // reportsToolStripMenuItem
// //
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listOfComponentsToolStripMenuItem, ComponentsByPastryToolStripMenuItem, listOfOrdersToolStripMenuItem }); reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listOfComponentsToolStripMenuItem, ComponentsByPastryToolStripMenuItem, listOfOrdersToolStripMenuItem });
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
отчётыToolStripMenuItem.Size = new Size(88, 29); reportsToolStripMenuItem.Size = new Size(88, 29);
отчётыToolStripMenuItem.Text = "Отчёты"; reportsToolStripMenuItem.Text = "Отчёты";
// //
// listOfComponentsToolStripMenuItem // listOfComponentsToolStripMenuItem
// //
@ -180,6 +182,20 @@
listOfOrdersToolStripMenuItem.Text = "Список заказов"; listOfOrdersToolStripMenuItem.Text = "Список заказов";
listOfOrdersToolStripMenuItem.Click += ListOfOrdersToolStripMenuItem_Click; listOfOrdersToolStripMenuItem.Click += ListOfOrdersToolStripMenuItem_Click;
// //
// startWorkToolStripMenuItem
//
startWorkToolStripMenuItem.Name = "startWorkToolStripMenuItem";
startWorkToolStripMenuItem.Size = new Size(136, 29);
startWorkToolStripMenuItem.Text = "Запуск работ";
startWorkToolStripMenuItem.Click += StartWorkToolStripMenuItem_Click;
//
// implementersToolStripMenuItem
//
implementersToolStripMenuItem.Name = "implementersToolStripMenuItem";
implementersToolStripMenuItem.Size = new Size(298, 34);
implementersToolStripMenuItem.Text = "Исполнители";
implementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
//
// FormMain // FormMain
// //
AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleDimensions = new SizeF(10F, 25F);
@ -215,10 +231,12 @@
private ToolStripMenuItem referencesToolStripMenuItem; private ToolStripMenuItem referencesToolStripMenuItem;
private ToolStripMenuItem pastriesToolStripMenuItem; private ToolStripMenuItem pastriesToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem отчётыToolStripMenuItem; private ToolStripMenuItem reportsToolStripMenuItem;
private ToolStripMenuItem listOfComponentsToolStripMenuItem; private ToolStripMenuItem listOfComponentsToolStripMenuItem;
private ToolStripMenuItem ComponentsByPastryToolStripMenuItem; private ToolStripMenuItem ComponentsByPastryToolStripMenuItem;
private ToolStripMenuItem listOfOrdersToolStripMenuItem; private ToolStripMenuItem listOfOrdersToolStripMenuItem;
private ToolStripMenuItem clientsToolStripMenuItem; private ToolStripMenuItem clientsToolStripMenuItem;
private ToolStripMenuItem startWorkToolStripMenuItem;
private ToolStripMenuItem implementersToolStripMenuItem;
} }
} }

View File

@ -10,13 +10,15 @@ namespace ConfectioneryView
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic; private readonly IReportLogic _reportLogic;
private readonly IWorkProcess _workProcess;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic,
IReportLogic reportLogic) IReportLogic reportLogic, IWorkProcess workProcess)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _orderLogic = orderLogic;
_reportLogic = reportLogic; _reportLogic = reportLogic;
_workProcess = workProcess;
} }
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
{ {
@ -108,6 +110,25 @@ namespace ConfectioneryView
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ImplementersToolStripMenuItem_Click(
object sender, EventArgs e)
{
var service = Program.ServiceProvider?
.GetService(typeof(FormImplementers));
if (service is FormImplementers form)
{
form.ShowDialog();
}
}
private void StartWorkToolStripMenuItem_Click(
object sender, EventArgs e)
{
_workProcess.DoWork((Program.ServiceProvider?.GetService(
typeof(IImplementerLogic)) as IImplementerLogic)!,
_orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void ButtonCreateOrder_Click(object sender, EventArgs e) private void ButtonCreateOrder_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService( var service = Program.ServiceProvider?.GetService(

View File

@ -39,11 +39,14 @@ namespace ConfectioneryView
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IPastryStorage, PastryStorage>(); services.AddTransient<IPastryStorage, PastryStorage>();
services.AddTransient<IClientStorage, ClientStorage>(); services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPastryLogic, PastryLogic>(); services.AddTransient<IPastryLogic, PastryLogic>();
services.AddTransient<IReportLogic, ReportLogic>(); services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IClientLogic, ClientLogic>(); services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IWorkProcess, WorkModeling>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormComponent>(); services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>(); services.AddTransient<FormComponents>();
@ -54,6 +57,8 @@ namespace ConfectioneryView
services.AddTransient<FormReportPastryComponents>(); services.AddTransient<FormReportPastryComponents>();
services.AddTransient<FormReportOrders>(); services.AddTransient<FormReportOrders>();
services.AddTransient<FormClients>(); services.AddTransient<FormClients>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormImplementers>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>(); services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>(); services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>(); services.AddTransient<AbstractSaveToPdf, SaveToPdf>();

View File

@ -10,11 +10,11 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IClientStorage _clientStorage; private readonly IClientStorage _clientStorage;
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage public ClientLogic(ILogger<ClientLogic> logger, IClientStorage
componentStorage) clientStorage)
{ {
_logger = logger; _logger = logger;
_clientStorage = componentStorage; _clientStorage = clientStorage;
} }
public List<ClientViewModel>? ReadList(ClientSearchModel? model) public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{ {

View File

@ -0,0 +1,130 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.StoragesContracts;
using ConfectioneryContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ConfectioneryBusinessLogic.BusinessLogics
{
public class ImplementerLogic : IImplementerLogic
{
private readonly ILogger _logger;
private readonly IImplementerStorage _implementerStorage;
public ImplementerLogic(ILogger<ImplementerLogic> logger,
IImplementerStorage implementerStorage)
{
_logger = logger;
_implementerStorage = implementerStorage;
}
public List<ImplementerViewModel>? ReadList(
ImplementerSearchModel? model)
{
_logger.LogInformation("ReadList. ImplementerFIO:{ClientFIO}. " +
"Id:{ Id}", model?.ImplementerFIO, model?.Id);
var list = model == null ? _implementerStorage.GetFullList() :
_implementerStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ImplementerFIO:" +
"{ImplementerFIO}.Id:{ Id}", model.ImplementerFIO, model.Id);
var element = _implementerStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
return element;
}
public bool Create(ImplementerBindingModel model)
{
CheckModel(model);
if (_implementerStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ImplementerBindingModel model)
{
CheckModel(model);
if (_implementerStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ImplementerBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_implementerStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(ImplementerBindingModel model,
bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ImplementerFIO))
{
throw new ArgumentNullException("Нет ФИО исполнителя",
nameof(model.ImplementerFIO));
}
if (string.IsNullOrEmpty(model.Password))
{
throw new ArgumentNullException("Нет пароля клиента",
nameof(model.Password));
}
if (model.WorkExperience < 0)
{
throw new ArgumentNullException("Стаж меньше 0",
nameof(model.WorkExperience));
}
if (model.Qualification < 0)
{
throw new ArgumentException("Квалификация меньше 0",
nameof(model.Qualification));
}
_logger.LogInformation("Implementer. ImplementerFIO: " +
"{ImplementerFIO}. Password: {Password}. WorkExperience: " +
"{WorkExperience}. Qualification:{ Qualification}. Id: { Id} ",
model.ImplementerFIO, model.Password, model.WorkExperience,
model.Qualification, model.Id);
var element = _implementerStorage.GetElement(
new ImplementerSearchModel
{
ImplementerFIO = model.ImplementerFIO,
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException(
"Исполнитель с таким ФИО уже есть");
}
}
}
}

View File

@ -11,12 +11,29 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
static readonly object locker = new object();
public OrderLogic(ILogger<OrderLogic> logger, public OrderLogic(ILogger<OrderLogic> logger,
IOrderStorage orderStorage) IOrderStorage orderStorage)
{ {
_logger = logger; _logger = logger;
_orderStorage = orderStorage; _orderStorage = orderStorage;
} }
public OrderViewModel? ReadElement(OrderSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
var element = _orderStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
return element;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model) public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{ {
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id); _logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
@ -44,7 +61,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
} }
public bool ChangeStatus(OrderBindingModel model, OrderStatus status) public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
{ {
CheckModel(model); CheckModel(model, false);
var element = _orderStorage.GetElement( var element = _orderStorage.GetElement(
new OrderSearchModel { Id = model.Id }); new OrderSearchModel { Id = model.Id });
if (element == null) if (element == null)
@ -61,12 +78,17 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
model.Status = status; model.Status = status;
if (model.Status == OrderStatus.Выдан) if (model.Status == OrderStatus.Выдан)
model.DateImplement = DateTime.Now; model.DateImplement = DateTime.Now;
if (element.ImplementerId.HasValue) model.ImplementerId
= element.ImplementerId;
_orderStorage.Update(model); _orderStorage.Update(model);
return true; return true;
} }
public bool TakeOrderInWork(OrderBindingModel model) public bool TakeOrderInWork(OrderBindingModel model)
{ {
return ChangeStatus(model, OrderStatus.Выполняется); lock (locker)
{
return ChangeStatus(model, OrderStatus.Выполняется);
}
} }
public bool FinishOrder(OrderBindingModel model) public bool FinishOrder(OrderBindingModel model)
{ {

View File

@ -0,0 +1,141 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Enums;
using Microsoft.Extensions.Logging;
namespace ConfectioneryBusinessLogic.BusinessLogics
{
public class WorkModeling : IWorkProcess
{
private readonly ILogger _logger;
private readonly Random _rnd;
private IOrderLogic? _orderLogic;
public WorkModeling(ILogger<WorkModeling> logger)
{
_logger = logger;
_rnd = new Random(1000);
}
public void DoWork(IImplementerLogic implementerLogic,
IOrderLogic orderLogic)
{
_orderLogic = orderLogic;
var implementers = implementerLogic.ReadList(null);
if (implementers == null)
{
_logger.LogWarning("DoWork. Implementers is null");
return;
}
var orders = _orderLogic.ReadList(new OrderSearchModel
{
Status = OrderStatus.Принят
});
if (orders == null || orders.Count == 0)
{
_logger.LogWarning("DoWork. Orders is null or empty");
return;
}
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
foreach (var implementer in implementers)
{
Task.Run(() => WorkerWorkAsync(implementer, orders));
}
}
/// <summary>
/// Иммитация работы исполнителя
/// </summary>
/// <param name="implementer"></param>
/// <param name="orders"></param>
private async Task WorkerWorkAsync(ImplementerViewModel implementer,
List<OrderViewModel> orders)
{
if (_orderLogic == null || implementer == null)
{
return;
}
await RunOrderInWork(implementer);
await Task.Run(() =>
{
foreach (var order in orders)
{
try
{
_logger.LogDebug(
"DoWork. Worker {Id} try get order { Order}",
implementer.Id, order.Id);
_orderLogic.TakeOrderInWork(new OrderBindingModel
{
Id = order.Id,
ImplementerId = implementer.Id
});
Thread.Sleep(implementer.WorkExperience *
_rnd.Next(100, 1000) * order.Count);
_logger.LogDebug(
"DoWork. Worker {Id} finish order { Order}",
implementer.Id, order.Id);
_orderLogic.FinishOrder(new OrderBindingModel
{
Id = order.Id
});
Thread.Sleep(implementer.Qualification *
_rnd.Next(10, 100));
}
catch (InvalidOperationException ex)
{
_logger.LogWarning(ex, "Error try get work");
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while do work");
throw;
}
}
});
}
/// <summary>
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
/// </summary>
/// <param name="implementer"></param>
/// <returns></returns>
private async Task RunOrderInWork(ImplementerViewModel implementer)
{
if (_orderLogic == null || implementer == null)
{
return;
}
try
{
var runOrder = await Task.Run(() => _orderLogic.ReadElement(
new OrderSearchModel
{
ImplementerId = implementer.Id,
Status = OrderStatus.Выполняется
}));
if (runOrder == null)
{
return;
}
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}",
implementer.Id, runOrder.Id);
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300)
* runOrder.Count);
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}",
implementer.Id, runOrder.Id);
_orderLogic.FinishOrder(new OrderBindingModel
{
Id = runOrder.Id
});
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
catch (InvalidOperationException ex)
{
_logger.LogWarning(ex, "Error try get work");
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while do work");
throw;
}
}
}
}

View File

@ -0,0 +1,12 @@
using ConfectioneryDataModels.Models;
namespace ConfectioneryContracts.BindingModels
{
public class ImplementerBindingModel : IImplementerModel
{
public int Id { get; set; }
public string ImplementerFIO { get; set; } = string.Empty;
public int WorkExperience { get; set; } = 0;
public int Qualification { get; set; } = 0;
public string Password { get; set; } = string.Empty;
}
}

View File

@ -6,6 +6,7 @@ namespace ConfectioneryContracts.BindingModels
{ {
public int Id { get; set; } public int Id { get; set; }
public int PastryId { get; set; } public int PastryId { get; set; }
public int? ImplementerId { get; set; } = null;
public int ClientId { get; set; } public int ClientId { get; set; }
public int Count { get; set; } public int Count { get; set; }
public double Sum { get; set; } public double Sum { get; set; }

View File

@ -0,0 +1,14 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.ViewModels;
namespace ConfectioneryContracts.BusinessLogicsContracts
{
public interface IImplementerLogic
{
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
bool Create(ImplementerBindingModel model);
bool Update(ImplementerBindingModel model);
bool Delete(ImplementerBindingModel model);
}
}

View File

@ -6,6 +6,7 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
public interface IOrderLogic public interface IOrderLogic
{ {
List<OrderViewModel>? ReadList(OrderSearchModel? model); List<OrderViewModel>? ReadList(OrderSearchModel? model);
OrderViewModel? ReadElement(OrderSearchModel model);
bool CreateOrder(OrderBindingModel model); bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model); bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model); bool FinishOrder(OrderBindingModel model);

View File

@ -0,0 +1,8 @@
namespace ConfectioneryContracts.BusinessLogicsContracts
{
public interface IWorkProcess
{
void DoWork(IImplementerLogic implementerLogic,
IOrderLogic orderLogic);
}
}

View File

@ -0,0 +1,9 @@
namespace ConfectioneryContracts.SearchModels
{
public class ImplementerSearchModel
{
public int? Id { get; set; }
public string? ImplementerFIO { get; set; } = string.Empty;
public string? Password { get; set; } = string.Empty;
}
}

View File

@ -1,9 +1,12 @@
namespace ConfectioneryContracts.SearchModels using ConfectioneryDataModels.Enums;
namespace ConfectioneryContracts.SearchModels
{ {
public class OrderSearchModel public class OrderSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ClientId { get; set; } public int? ClientId { get; set; }
public int? ImplementerId { get; set; }
public OrderStatus? Status { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
} }

View File

@ -0,0 +1,16 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.ViewModels;
namespace ConfectioneryContracts.StoragesContracts
{
public interface IImplementerStorage
{
List<ImplementerViewModel> GetFullList();
List<ImplementerViewModel> GetFilteredList(
ImplementerSearchModel model);
ImplementerViewModel? GetElement(ImplementerSearchModel model);
ImplementerViewModel? Insert(ImplementerBindingModel model);
ImplementerViewModel? Update(ImplementerBindingModel model);
ImplementerViewModel? Delete(ImplementerBindingModel model);
}
}

View File

@ -0,0 +1,17 @@
using ConfectioneryDataModels.Models;
using System.ComponentModel;
namespace ConfectioneryContracts.ViewModels
{
public class ImplementerViewModel : IImplementerModel
{
public int Id { get; set; }
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Стаж работы")]
public int WorkExperience { get; set; } = 0;
[DisplayName("Квалификация")]
public int Qualification { get; set; } = 0;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
}
}

View File

@ -13,6 +13,9 @@ namespace ConfectioneryContracts.ViewModels
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;
public int? ImplementerId { get; set; } = null;
[DisplayName("Исполнитель")]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }
[DisplayName("Сумма")] [DisplayName("Сумма")]

View File

@ -0,0 +1,10 @@
namespace ConfectioneryDataModels.Models
{
public interface IImplementerModel : IId
{
string ImplementerFIO { get; }
string Password { get; }
int WorkExperience { get; }
int Qualification { get; }
}
}

View File

@ -18,5 +18,6 @@ namespace ConfectioneryDatabaseImplement
public virtual DbSet<PastryComponent> PastryComponents { set; get; } public virtual DbSet<PastryComponent> PastryComponents { set; get; }
public virtual DbSet<Order> Orders { set; get; } public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Client> Clients { set; get; } public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<Implementer> Implementers { set; get; }
} }
} }

View File

@ -0,0 +1,83 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.StoragesContracts;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDatabaseImplement.Models;
namespace ConfectioneryDatabaseImplement.Implements
{
public class ImplementerStorage : IImplementerStorage
{
public ImplementerViewModel? Delete(ImplementerBindingModel model)
{
using var context = new ConfectioneryDatabase();
var res = context.Implementers
.FirstOrDefault(x => x.Id == model.Id);
if (res != null)
{
context.Implementers.Remove(res);
context.SaveChanges();
}
return res?.GetViewModel;
}
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
{
if (string.IsNullOrEmpty(model.ImplementerFIO) &&
string.IsNullOrEmpty(model.Password) &&
!model.Id.HasValue)
{
return null;
}
using var context = new ConfectioneryDatabase();
return context.Implementers
.FirstOrDefault(x =>
(string.IsNullOrEmpty(model.ImplementerFIO) ||
x.ImplementerFIO == model.ImplementerFIO) &&
(!model.Id.HasValue || x.Id == model.Id) &&
(string.IsNullOrEmpty(model.Password) ||
x.Password == model.Password))
?.GetViewModel;
}
public List<ImplementerViewModel> GetFilteredList(
ImplementerSearchModel model)
{
if (model == null)
{
return new();
}
if (model.Id.HasValue)
{
var res = GetElement(model);
return res != null ? new() { res } : new();
}
return new();
}
public List<ImplementerViewModel> GetFullList()
{
using var context = new ConfectioneryDatabase();
return context.Implementers.Select(x => x.GetViewModel).ToList();
}
public ImplementerViewModel? Insert(ImplementerBindingModel model)
{
using var context = new ConfectioneryDatabase();
var res = Implementer.Create(model);
if (res != null)
{
context.Implementers.Add(res);
context.SaveChanges();
}
return res?.GetViewModel;
}
public ImplementerViewModel? Update(ImplementerBindingModel model)
{
using var context = new ConfectioneryDatabase();
var res = context.Implementers
.FirstOrDefault(x => x.Id == model.Id);
if (res != null)
{
res.Update(model);
context.SaveChanges();
}
return res?.GetViewModel;
}
}
}

View File

@ -13,6 +13,7 @@ namespace ConfectioneryDatabaseImplement.Implements
using var context = new ConfectioneryDatabase(); using var context = new ConfectioneryDatabase();
return context.Orders.Include(x => x.Pastries) return context.Orders.Include(x => x.Pastries)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
@ -21,6 +22,7 @@ namespace ConfectioneryDatabaseImplement.Implements
using var context = new ConfectioneryDatabase(); using var context = new ConfectioneryDatabase();
return context.Orders.Include(x => x.Pastries) return context.Orders.Include(x => x.Pastries)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => ( .Where(x => (
(!model.Id.HasValue || x.Id == model.Id) && (!model.Id.HasValue || x.Id == model.Id) &&
(!model.DateFrom.HasValue || x.DateCreate >= (!model.DateFrom.HasValue || x.DateCreate >=
@ -41,7 +43,14 @@ namespace ConfectioneryDatabaseImplement.Implements
using var context = new ConfectioneryDatabase(); using var context = new ConfectioneryDatabase();
return context.Orders.Include(x => x.Pastries) return context.Orders.Include(x => x.Pastries)
.Include(x => x.Client) .Include(x => x.Client)
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; .Include(x => x.Implementer)
.FirstOrDefault(x => (
(model.Id.HasValue && x.Id == model.Id) ||
(model.ImplementerId.HasValue && model.Status.HasValue &&
x.ImplementerId == model.ImplementerId &&
x.Status == model.Status)
)
)?.GetViewModel;
} }
public OrderViewModel? Insert(OrderBindingModel model) public OrderViewModel? Insert(OrderBindingModel model)
{ {
@ -60,6 +69,7 @@ namespace ConfectioneryDatabaseImplement.Implements
using var context = new ConfectioneryDatabase(); using var context = new ConfectioneryDatabase();
var order = context.Orders.Include(x => x.Pastries) var order = context.Orders.Include(x => x.Pastries)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x => x.Id == model.Id); .FirstOrDefault(x => x.Id == model.Id);
if (order == null) if (order == null)
{ {
@ -74,6 +84,7 @@ namespace ConfectioneryDatabaseImplement.Implements
using var context = new ConfectioneryDatabase(); using var context = new ConfectioneryDatabase();
var element = context.Orders.Include(x => x.Pastries) var element = context.Orders.Include(x => x.Pastries)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(rec => rec.Id == model.Id); .FirstOrDefault(rec => rec.Id == model.Id);
if (element != null) if (element != null)
{ {

View File

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ConfectioneryDatabaseImplement.Migrations namespace ConfectioneryDatabaseImplement.Migrations
{ {
[DbContext(typeof(ConfectioneryDatabase))] [DbContext(typeof(ConfectioneryDatabase))]
[Migration("20240508053013_InitialCreate")] [Migration("20240508100134_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -70,6 +70,33 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.ToTable("Components"); b.ToTable("Components");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -90,6 +117,9 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("PastryId") b.Property<int>("PastryId")
.HasColumnType("int"); .HasColumnType("int");
@ -103,6 +133,8 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.HasIndex("PastryId"); b.HasIndex("PastryId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -162,6 +194,10 @@ namespace ConfectioneryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("ConfectioneryDatabaseImplement.Models.Implementer", "Implementer")
.WithMany("Orders")
.HasForeignKey("ImplementerId");
b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastries") b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastries")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("PastryId") .HasForeignKey("PastryId")
@ -170,6 +206,8 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("Client"); b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Pastries"); b.Navigation("Pastries");
}); });
@ -202,6 +240,11 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("PastryComponents"); b.Navigation("PastryComponents");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
{ {
b.Navigation("Components"); b.Navigation("Components");

View File

@ -40,6 +40,22 @@ namespace ConfectioneryDatabaseImplement.Migrations
table.PrimaryKey("PK_Components", x => x.Id); table.PrimaryKey("PK_Components", x => x.Id);
}); });
migrationBuilder.CreateTable(
name: "Implementers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
Qualification = table.Column<int>(type: "int", nullable: false),
WorkExperience = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Implementers", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Pastries", name: "Pastries",
columns: table => new columns: table => new
@ -66,7 +82,8 @@ namespace ConfectioneryDatabaseImplement.Migrations
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false), DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true), DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
PastryId = table.Column<int>(type: "int", nullable: false), PastryId = table.Column<int>(type: "int", nullable: false),
ClientId = table.Column<int>(type: "int", nullable: false) ClientId = table.Column<int>(type: "int", nullable: false),
ImplementerId = table.Column<int>(type: "int", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -77,6 +94,11 @@ namespace ConfectioneryDatabaseImplement.Migrations
principalTable: "Clients", principalTable: "Clients",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Implementers_ImplementerId",
column: x => x.ImplementerId,
principalTable: "Implementers",
principalColumn: "Id");
table.ForeignKey( table.ForeignKey(
name: "FK_Orders_Pastries_PastryId", name: "FK_Orders_Pastries_PastryId",
column: x => x.PastryId, column: x => x.PastryId,
@ -117,6 +139,11 @@ namespace ConfectioneryDatabaseImplement.Migrations
table: "Orders", table: "Orders",
column: "ClientId"); column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ImplementerId",
table: "Orders",
column: "ImplementerId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Orders_PastryId", name: "IX_Orders_PastryId",
table: "Orders", table: "Orders",
@ -145,6 +172,9 @@ namespace ConfectioneryDatabaseImplement.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Clients"); name: "Clients");
migrationBuilder.DropTable(
name: "Implementers");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Components"); name: "Components");

View File

@ -67,6 +67,33 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.ToTable("Components"); b.ToTable("Components");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -87,6 +114,9 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("PastryId") b.Property<int>("PastryId")
.HasColumnType("int"); .HasColumnType("int");
@ -100,6 +130,8 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.HasIndex("PastryId"); b.HasIndex("PastryId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -159,6 +191,10 @@ namespace ConfectioneryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("ConfectioneryDatabaseImplement.Models.Implementer", "Implementer")
.WithMany("Orders")
.HasForeignKey("ImplementerId");
b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastries") b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastries")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("PastryId") .HasForeignKey("PastryId")
@ -167,6 +203,8 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("Client"); b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Pastries"); b.Navigation("Pastries");
}); });
@ -199,6 +237,11 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("PastryComponents"); b.Navigation("PastryComponents");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Implementer", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
{ {
b.Navigation("Components"); b.Navigation("Components");

View File

@ -0,0 +1,56 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace ConfectioneryDatabaseImplement.Models
{
public class Implementer : IImplementerModel
{
public int Id { get; private set; }
[Required]
public string ImplementerFIO { get; private set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[Required]
public int Qualification { get; set; } = 0;
[Required]
public int WorkExperience { get; set; } = 0;
[ForeignKey("ImplementerId")]
public virtual List<Order> Orders { get; set; } = new();
public static Implementer? Create(ImplementerBindingModel model)
{
if (model == null)
{
return null;
}
return new()
{
Id = model.Id,
Password = model.Password,
Qualification = model.Qualification,
ImplementerFIO = model.ImplementerFIO,
WorkExperience = model.WorkExperience,
};
}
public void Update(ImplementerBindingModel model)
{
if (model == null)
{
return;
}
Password = model.Password;
Qualification = model.Qualification;
ImplementerFIO = model.ImplementerFIO;
WorkExperience = model.WorkExperience;
}
public ImplementerViewModel GetViewModel => new()
{
Id = Id,
Password = Password,
Qualification = Qualification,
ImplementerFIO = ImplementerFIO,
WorkExperience = WorkExperience,
};
}
}

View File

@ -22,6 +22,8 @@ namespace ConfectioneryDatabaseImplement.Models
[Required] [Required]
public int ClientId { get; private set; } public int ClientId { get; private set; }
public virtual Client? Client { get; private set; } public virtual Client? Client { get; private set; }
public int? ImplementerId { get; private set; } = null;
public virtual Implementer? Implementer { get; private set; }
public static Order? Create(OrderBindingModel model) public static Order? Create(OrderBindingModel model)
{ {
if (model == null) if (model == null)
@ -37,7 +39,8 @@ namespace ConfectioneryDatabaseImplement.Models
DateCreate = model.DateCreate, DateCreate = model.DateCreate,
DateImplement = model.DateImplement, DateImplement = model.DateImplement,
PastryId = model.PastryId, PastryId = model.PastryId,
ClientId = model.ClientId ClientId = model.ClientId,
ImplementerId = model.ImplementerId
}; };
} }
public void Update(OrderBindingModel? model) public void Update(OrderBindingModel? model)
@ -48,11 +51,13 @@ namespace ConfectioneryDatabaseImplement.Models
} }
Status = model.Status; Status = model.Status;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
ImplementerId = model.ImplementerId;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
PastryId = PastryId, PastryId = PastryId,
ClientId = ClientId, ClientId = ClientId,
ImplementerId = ImplementerId,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,
@ -60,7 +65,8 @@ namespace ConfectioneryDatabaseImplement.Models
DateImplement = DateImplement, DateImplement = DateImplement,
Id = Id, Id = Id,
PastryName = Pastries?.PastryName ?? string.Empty, PastryName = Pastries?.PastryName ?? string.Empty,
ClientFIO = Client?.ClientFIO ?? string.Empty ClientFIO = Client?.ClientFIO ?? string.Empty,
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty
}; };
} }
} }

View File

@ -9,10 +9,12 @@ namespace ConfectioneryFileImplement
private readonly string OrderFileName = "Order.xml"; private readonly string OrderFileName = "Order.xml";
private readonly string PastryFileName = "Pastry.xml"; private readonly string PastryFileName = "Pastry.xml";
private readonly string ClientFileName = "Client.xml"; private readonly string ClientFileName = "Client.xml";
private readonly string ImplementerFileName = "Implementer.xml";
public List<Component> Components { get; private set; } public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; } public List<Order> Orders { get; private set; }
public List<Pastry> Pastries { get; private set; } public List<Pastry> Pastries { get; private set; }
public List<Client> Clients { get; private set; } public List<Client> Clients { get; private set; }
public List<Implementer> Implementers { get; private set; }
public static DataFileSingleton GetInstance() public static DataFileSingleton GetInstance()
{ {
if (instance == null) if (instance == null)
@ -29,6 +31,8 @@ namespace ConfectioneryFileImplement
"Orders", x => x.GetXElement); "Orders", x => x.GetXElement);
public void SaveClients() => SaveData(Clients, ClientFileName, public void SaveClients() => SaveData(Clients, ClientFileName,
"Clients", x => x.GetXElement); "Clients", x => x.GetXElement);
public void SaveImplementers() => SaveData(Implementers,
ImplementerFileName, "Implementers", x => x.GetXElement);
private DataFileSingleton() private DataFileSingleton()
{ {
Components = LoadData(ComponentFileName, "Component", Components = LoadData(ComponentFileName, "Component",
@ -39,6 +43,8 @@ namespace ConfectioneryFileImplement
x => Order.Create(x)!)!; x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", Clients = LoadData(ClientFileName, "Client",
x => Client.Create(x)!)!; x => Client.Create(x)!)!;
Implementers = LoadData(ImplementerFileName, "Implementer",
x => Implementer.Create(x)!)!;
} }
private static List<T>? LoadData<T>(string filename, private static List<T>? LoadData<T>(string filename,
string xmlNodeName, Func<XElement, T> selectFunction) string xmlNodeName, Func<XElement, T> selectFunction)

View File

@ -0,0 +1,86 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.StoragesContracts;
using ConfectioneryContracts.ViewModels;
using ConfectioneryFileImplement.Models;
namespace ConfectioneryFileImplement.Implements
{
public class ImplementerStorage : IImplementerStorage
{
private readonly DataFileSingleton source;
public ImplementerStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<ImplementerViewModel> GetFullList()
{
return source.Implementers
.Select(x => x.GetViewModel)
.ToList();
}
public List<ImplementerViewModel> GetFilteredList(
ImplementerSearchModel model)
{
if (string.IsNullOrEmpty(model.ImplementerFIO) &&
string.IsNullOrEmpty(model.Password))
{
return new();
}
return source.Implementers
.Where(x => (string.IsNullOrEmpty(model.ImplementerFIO) ||
x.ImplementerFIO.Contains(model.ImplementerFIO)) &&
(string.IsNullOrEmpty(model.Password) ||
x.Password.Contains(model.Password)))
.Select(x => x.GetViewModel)
.ToList();
}
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
{
return source.Implementers
.FirstOrDefault(x =>
(string.IsNullOrEmpty(model.ImplementerFIO) ||
x.ImplementerFIO == model.ImplementerFIO) &&
(!model.Id.HasValue || x.Id == model.Id) &&
(string.IsNullOrEmpty(model.Password) ||
x.Password == model.Password))
?.GetViewModel;
}
public ImplementerViewModel? Insert(ImplementerBindingModel model)
{
model.Id = source.Implementers.Count > 0 ?
source.Implementers.Max(x => x.Id) + 1 : 1;
var newImplementer = Implementer.Create(model);
if (newImplementer == null)
{
return null;
}
source.Implementers.Add(newImplementer);
source.SaveImplementers();
return newImplementer.GetViewModel;
}
public ImplementerViewModel? Update(ImplementerBindingModel model)
{
var implementer = source.Implementers
.FirstOrDefault(x => x.Id == model.Id);
if (implementer == null)
{
return null;
}
implementer.Update(model);
source.SaveImplementers();
return implementer.GetViewModel;
}
public ImplementerViewModel? Delete(ImplementerBindingModel model)
{
var element = source.Implementers
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
source.Implementers.Remove(element);
source.SaveImplementers();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -15,30 +15,36 @@ namespace ConfectioneryFileImplement.Implements
public List<OrderViewModel> GetFullList() public List<OrderViewModel> GetFullList()
{ {
return source.Orders return source.Orders
.Select(x => AccessPastryStorage(x.GetViewModel)) .Select(x => AccessStorage(x.GetViewModel))
.ToList(); .ToList();
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
return source.Orders return source.Orders
.Where(x => ( .Where(x => (
(!model.Id.HasValue || x.Id == model.Id) && (!model.Id.HasValue || x.Id == model.Id) &&
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) && (!model.DateFrom.HasValue || x.DateCreate >=
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo) && model.DateFrom) && (!model.DateTo.HasValue ||
(!model.ClientId.HasValue || x.ClientId == model.ClientId) x.DateCreate <= model.DateTo) &&
(!model.ClientId.HasValue ||
x.ClientId == model.ClientId) &&
(!model.Status.HasValue || x.Status == model.Status)
) )
) )
.Select(x => AccessPastryStorage(x.GetViewModel)) .Select(x => AccessStorage(x.GetViewModel))
.ToList(); .ToList();
} }
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
{ {
if (!model.Id.HasValue) if (!model.Id.HasValue)
{ {
return null; return null;
} }
return AccessPastryStorage(source.Orders.FirstOrDefault( return AccessStorage(source.Orders.FirstOrDefault(
x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel); x => (model.Id.HasValue && x.Id == model.Id) ||
(model.ImplementerId.HasValue && model.Status.HasValue &&
x.ImplementerId == model.ImplementerId &&
x.Status == model.Status))?.GetViewModel ?? new());
} }
public OrderViewModel? Insert(OrderBindingModel model) public OrderViewModel? Insert(OrderBindingModel model)
{ {
@ -51,7 +57,7 @@ namespace ConfectioneryFileImplement.Implements
} }
source.Orders.Add(newOrder); source.Orders.Add(newOrder);
source.SaveOrders(); source.SaveOrders();
return AccessPastryStorage(newOrder.GetViewModel); return AccessStorage(newOrder.GetViewModel);
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
{ {
@ -62,7 +68,7 @@ namespace ConfectioneryFileImplement.Implements
} }
order.Update(model); order.Update(model);
source.SaveOrders(); source.SaveOrders();
return AccessPastryStorage(order.GetViewModel); return AccessStorage(order.GetViewModel);
} }
public OrderViewModel? Delete(OrderBindingModel model) public OrderViewModel? Delete(OrderBindingModel model)
{ {
@ -71,31 +77,24 @@ namespace ConfectioneryFileImplement.Implements
{ {
source.Orders.Remove(element); source.Orders.Remove(element);
source.SaveOrders(); source.SaveOrders();
return AccessPastryStorage(element.GetViewModel); return AccessStorage(element.GetViewModel);
} }
return null; return null;
} }
public OrderViewModel AccessPastryStorage(OrderViewModel model) public OrderViewModel AccessStorage(OrderViewModel model)
{
if (model == null)
return null;
foreach (var Pastry in source.Pastries)
{
if (Pastry.Id == model.PastryId)
{
model.PastryName = Pastry.PastryName;
break;
}
}
return model;
}
public OrderViewModel AccessClientStorage(OrderViewModel model)
{ {
if (model == null) if (model == null)
return null; return null;
var pastry = source.Pastries.FirstOrDefault(x => x.Id == model.Id);
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id); var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
var implementer = source.Implementers.FirstOrDefault(
x => x.Id == model.ImplementerId);
if (pastry != null)
model.PastryName = pastry.PastryName;
if (client != null) if (client != null)
model.ClientFIO = client.ClientFIO; model.ClientFIO = client.ClientFIO;
if (implementer != null)
model.ImplementerFIO = implementer.ImplementerFIO;
return model; return model;
} }
} }

View File

@ -0,0 +1,73 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models;
using System.Xml.Linq;
namespace ConfectioneryFileImplement.Models
{
public class Implementer : IImplementerModel
{
public int Id { get; private set; }
public string ImplementerFIO { get; private set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public int Qualification { get; set; } = 0;
public int WorkExperience { get; set; } = 0;
public static Implementer? Create(ImplementerBindingModel model)
{
if (model == null)
{
return null;
}
return new Implementer()
{
Id = model.Id,
ImplementerFIO = model.ImplementerFIO,
Password = model.Password,
WorkExperience = model.WorkExperience,
Qualification = model.Qualification
};
}
public void Update(ImplementerBindingModel model)
{
if (model == null)
{
return;
}
ImplementerFIO = model.ImplementerFIO;
Password = model.Password;
WorkExperience = model.WorkExperience;
Qualification = model.Qualification;
}
public ImplementerViewModel GetViewModel => new()
{
Id = Id,
ImplementerFIO = ImplementerFIO,
Password = Password,
WorkExperience = WorkExperience,
Qualification = Qualification
};
public static Implementer? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Implementer()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
Password = element.Element("Password")!.Value,
Qualification = Convert.ToInt32(
element.Element("Qualification")!.Value),
WorkExperience = Convert.ToInt32(
element.Element("WorkExperience")!.Value)
};
}
public XElement GetXElement => new("Implementer",
new XAttribute("Id", Id),
new XElement("ImplementerFIO", ImplementerFIO),
new XElement("Password", Password),
new XElement("Qualification", Qualification.ToString()),
new XElement("WorkExperience", WorkExperience.ToString())
);
}
}

View File

@ -15,6 +15,7 @@ namespace ConfectioneryFileImplement.Models
public OrderStatus Status { get; private set; } public OrderStatus Status { get; private set; }
public DateTime DateCreate { get; private set; } public DateTime DateCreate { get; private set; }
public DateTime? DateImplement { get; private set; } public DateTime? DateImplement { get; private set; }
public int? ImplementerId { get; private set; } = null;
public static Order? Create(OrderBindingModel model) public static Order? Create(OrderBindingModel model)
{ {
if (model == null) if (model == null)
@ -31,6 +32,7 @@ namespace ConfectioneryFileImplement.Models
Status = model.Status, Status = model.Status,
DateCreate = model.DateCreate, DateCreate = model.DateCreate,
DateImplement = model.DateImplement, DateImplement = model.DateImplement,
ImplementerId = model.ImplementerId
}; };
} }
public static Order? Create(XElement element) public static Order? Create(XElement element)
@ -44,6 +46,8 @@ namespace ConfectioneryFileImplement.Models
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
PastryId = Convert.ToInt32(element.Element("PastryId")!.Value), PastryId = Convert.ToInt32(element.Element("PastryId")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value), ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
ImplementerId = Convert.ToInt32(
element.Element("ImplementerId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), Status = (OrderStatus)Enum.Parse(typeof(OrderStatus),
@ -62,6 +66,7 @@ namespace ConfectioneryFileImplement.Models
} }
Status = model.Status; Status = model.Status;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
ImplementerId = model.ImplementerId;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
@ -73,6 +78,7 @@ namespace ConfectioneryFileImplement.Models
Status = Status, Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
DateImplement = DateImplement, DateImplement = DateImplement,
ImplementerId = ImplementerId
}; };
public XElement GetXElement => new("Order", public XElement GetXElement => new("Order",
new XAttribute("Id", Id), new XAttribute("Id", Id),
@ -82,7 +88,8 @@ namespace ConfectioneryFileImplement.Models
new XElement("Count", Count), new XElement("Count", Count),
new XElement("Status", Status.ToString()), new XElement("Status", Status.ToString()),
new XElement("DateCreate", DateCreate.ToString()), new XElement("DateCreate", DateCreate.ToString()),
new XElement("DateImplement", DateImplement.ToString()) new XElement("DateImplement", DateImplement.ToString()),
new XElement("ImplementerId", ImplementerId)
); );
} }
} }

View File

@ -8,12 +8,14 @@ namespace ConfectioneryListImplement
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Pastry> Pastries { get; set; } public List<Pastry> Pastries { get; set; }
public List<Client> Clients { get; set; } public List<Client> Clients { get; set; }
public List<Implementer> Implementers { get; set; }
private DataListSingleton() private DataListSingleton()
{ {
Components = new List<Component>(); Components = new List<Component>();
Orders = new List<Order>(); Orders = new List<Order>();
Pastries = new List<Pastry>(); Pastries = new List<Pastry>();
Clients = new List<Client>(); Clients = new List<Client>();
Implementers = new List<Implementer>();
} }
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()
{ {

View File

@ -0,0 +1,101 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.StoragesContracts;
using ConfectioneryContracts.ViewModels;
using ConfectioneryListImplement.Models;
namespace ConfectioneryListImplement.Implements
{
public class ImplementerStorage : IImplementerStorage
{
private readonly DataListSingleton _source;
public ImplementerStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<ImplementerViewModel> GetFullList()
{
var result = new List<ImplementerViewModel>();
foreach (var implementer in _source.Implementers)
{
result.Add(implementer.GetViewModel);
}
return result;
}
public List<ImplementerViewModel> GetFilteredList(
ImplementerSearchModel model)
{
var result = new List<ImplementerViewModel>();
if (string.IsNullOrEmpty(model.ImplementerFIO) &&
string.IsNullOrEmpty(model.Password))
{
return result;
}
foreach (var implementer in _source.Implementers)
{
if (implementer.ImplementerFIO.Contains(model.ImplementerFIO))
{
result.Add(implementer.GetViewModel);
}
}
return result;
}
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
{
foreach (var implementer in _source.Implementers)
{
if ((string.IsNullOrEmpty(model.ImplementerFIO) ||
implementer.ImplementerFIO == model.ImplementerFIO) &&
(!model.Id.HasValue || implementer.Id == model.Id) &&
(string.IsNullOrEmpty(model.Password) ||
implementer.Password == model.Password))
{
return implementer.GetViewModel;
}
}
return null;
}
public ImplementerViewModel? Insert(ImplementerBindingModel model)
{
model.Id = 1;
foreach (var implementer in _source.Implementers)
{
if (model.Id <= implementer.Id)
{
model.Id = implementer.Id + 1;
}
}
var newImplementer = Implementer.Create(model);
if (newImplementer == null)
{
return null;
}
_source.Implementers.Add(newImplementer);
return newImplementer.GetViewModel;
}
public ImplementerViewModel? Update(ImplementerBindingModel model)
{
foreach (var implementer in _source.Implementers)
{
if (model.Id == implementer.Id)
{
implementer.Update(model);
return implementer.GetViewModel;
}
}
return null;
}
public ImplementerViewModel? Delete(ImplementerBindingModel model)
{
for (int i = 0; i < _source.Implementers.Count; ++i)
{
if (_source.Implementers[i].Id == model.Id)
{
var element = _source.Implementers[i];
_source.Implementers.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -17,7 +17,7 @@ namespace ConfectioneryListImplement.Implements
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
result.Add(AccessPastryStorage(order.GetViewModel)); result.Add(AccessStorage(order.GetViewModel));
} }
return result; return result;
} }
@ -26,13 +26,16 @@ namespace ConfectioneryListImplement.Implements
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
if ((!model.Id.HasValue || order.Id == model.Id) && if ((!model.Id.HasValue || order.Id == model.Id) &&
(!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) && (!model.DateFrom.HasValue || order.DateCreate >=
(!model.DateTo.HasValue || order.DateCreate <= model.DateTo) && model.DateFrom) && (!model.DateTo.HasValue ||
(!model.ClientId.HasValue || order.ClientId == model.ClientId)) order.DateCreate <= model.DateTo) &&
{ (!model.ClientId.HasValue ||
result.Add(AccessPastryStorage(order.GetViewModel)); order.ClientId == model.ClientId) &&
} (!model.Status.HasValue || order.Status == model.Status))
{
result.Add(AccessStorage(order.GetViewModel));
}
} }
return result; return result;
} }
@ -44,9 +47,12 @@ namespace ConfectioneryListImplement.Implements
} }
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
if (model.Id.HasValue && order.Id == model.Id) if ((model.Id.HasValue && order.Id == model.Id) ||
(model.ImplementerId.HasValue && model.Status.HasValue &&
order.ImplementerId == model.ImplementerId &&
order.Status == model.Status))
{ {
return order.GetViewModel; return AccessStorage(order.GetViewModel);
} }
} }
return null; return null;
@ -94,24 +100,19 @@ namespace ConfectioneryListImplement.Implements
} }
return null; return null;
} }
public OrderViewModel AccessPastryStorage(OrderViewModel model) public OrderViewModel AccessStorage(OrderViewModel model)
{
foreach (var Pastry in _source.Pastries)
{
if (Pastry.Id == model.PastryId)
{
model.PastryName = Pastry.PastryName;
break;
}
}
return model;
}
public OrderViewModel AccessClientStorage(OrderViewModel model)
{ {
if (model == null) return null;
var pastry = _source.Pastries
.FirstOrDefault(x => x.Id == model.Id);
var client = _source.Clients var client = _source.Clients
.FirstOrDefault(x => x.Id == model.ClientId); .FirstOrDefault(x => x.Id == model.Id);
if (client != null) var implementer = _source.Implementers
model.ClientFIO = client.ClientFIO; .FirstOrDefault(x => x.Id == model.ImplementerId);
if (pastry != null) model.PastryName = pastry.PastryName;
if (client != null) model.ClientFIO = client.ClientFIO;
if (implementer != null)
model.ImplementerFIO = implementer.ImplementerFIO;
return model; return model;
} }
} }

View File

@ -0,0 +1,48 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models;
namespace ConfectioneryListImplement.Models
{
public class Implementer : IImplementerModel
{
public int Id { get; private set; }
public string ImplementerFIO { get; private set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public int WorkExperience { get; set; } = 0;
public int Qualification { get; set; } = 0;
public static Implementer? Create(ImplementerBindingModel model)
{
if (model == null)
{
return null;
}
return new Implementer()
{
Id = model.Id,
ImplementerFIO = model.ImplementerFIO,
Password = model.Password,
WorkExperience = model.WorkExperience,
Qualification = model.Qualification
};
}
public void Update(ImplementerBindingModel model)
{
if (model == null)
{
return;
}
ImplementerFIO = model.ImplementerFIO;
Password = model.Password;
WorkExperience = model.WorkExperience;
Qualification = model.Qualification;
}
public ImplementerViewModel GetViewModel => new()
{
Id = Id,
ImplementerFIO = ImplementerFIO,
Password = Password,
WorkExperience = WorkExperience,
Qualification = Qualification
};
}
}

View File

@ -14,6 +14,7 @@ namespace ConfectioneryListImplement.Models
public OrderStatus Status { get; private set; } public OrderStatus Status { get; private set; }
public DateTime DateCreate { get; private set; } public DateTime DateCreate { get; private set; }
public DateTime? DateImplement { get; private set; } public DateTime? DateImplement { get; private set; }
public int? ImplementerId { get; private set; }
public static Order? Create(OrderBindingModel? model) public static Order? Create(OrderBindingModel? model)
{ {
if (model == null) if (model == null)
@ -30,6 +31,7 @@ namespace ConfectioneryListImplement.Models
Status = model.Status, Status = model.Status,
DateCreate = model.DateCreate, DateCreate = model.DateCreate,
DateImplement = model.DateImplement, DateImplement = model.DateImplement,
ImplementerId = model.ImplementerId
}; };
} }
public void Update(OrderBindingModel? model) public void Update(OrderBindingModel? model)
@ -40,6 +42,7 @@ namespace ConfectioneryListImplement.Models
} }
Status = model.Status; Status = model.Status;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
ImplementerId = model.ImplementerId;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
@ -51,6 +54,7 @@ namespace ConfectioneryListImplement.Models
Status = Status, Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
DateImplement = DateImplement, DateImplement = DateImplement,
ImplementerId = ImplementerId,
}; };
} }
} }

View File

@ -0,0 +1,105 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Enums;
using Microsoft.AspNetCore.Mvc;
namespace ConfectioneryRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ImplementerController : ControllerBase
{
private readonly ILogger _logger;
private readonly IOrderLogic _order;
private readonly IImplementerLogic _logic;
public ImplementerController(IOrderLogic order,
IImplementerLogic logic, ILogger<ImplementerController> logger)
{
_logger = logger;
_order = order;
_logic = logic;
}
[HttpGet]
public ImplementerViewModel? Login(string login, string password)
{
try
{
return _logic.ReadElement(new ImplementerSearchModel
{
ImplementerFIO = login,
Password = password
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка авторизации сотрудника");
throw;
}
}
[HttpGet]
public List<OrderViewModel>? GetNewOrders()
{
try
{
return _order.ReadList(new OrderSearchModel
{
Status = OrderStatus.Принят
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения новых заказов");
throw;
}
}
[HttpGet]
public OrderViewModel? GetImplementerOrder(int implementerId)
{
try
{
return _order.ReadElement(new OrderSearchModel
{
ImplementerId = implementerId
});
}
catch (Exception ex)
{
_logger.LogError(
ex, "Ошибка получения текущего заказа исполнителя");
throw;
}
}
[HttpPost]
public void TakeOrderInWork(OrderBindingModel model)
{
try
{
_order.TakeOrderInWork(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу",
model.Id);
throw;
}
}
[HttpPost]
public void FinishOrder(OrderBindingModel model)
{
try
{
_order.FinishOrder(model);
}
catch (Exception ex)
{
_logger.LogError(
ex, "Ошибка отметки о готовности заказа с №{ Id}",
model.Id);
throw;
}
}
}
}