diff --git a/Typography/Typography/FormImplementer.Designer.cs b/Typography/Typography/FormImplementer.Designer.cs
new file mode 100644
index 0000000..996ef5f
--- /dev/null
+++ b/Typography/Typography/FormImplementer.Designer.cs
@@ -0,0 +1,163 @@
+namespace Typography
+{
+ partial class FormImplementer
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelFIO = new Label();
+ labelPassword = new Label();
+ labelWorkExperience = new Label();
+ labelQualification = new Label();
+ textBoxPassword = new TextBox();
+ textBoxFIO = new TextBox();
+ textBoxWorkExperience = new TextBox();
+ textBoxQualification = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelFIO
+ //
+ labelFIO.AutoSize = true;
+ labelFIO.Location = new Point(12, 15);
+ labelFIO.Name = "labelFIO";
+ labelFIO.Size = new Size(42, 20);
+ labelFIO.TabIndex = 0;
+ labelFIO.Text = "ФИО";
+ //
+ // labelPassword
+ //
+ labelPassword.AutoSize = true;
+ labelPassword.Location = new Point(12, 48);
+ labelPassword.Name = "labelPassword";
+ labelPassword.Size = new Size(62, 20);
+ labelPassword.TabIndex = 1;
+ labelPassword.Text = "Пароль";
+ //
+ // labelWorkExperience
+ //
+ labelWorkExperience.AutoSize = true;
+ labelWorkExperience.Location = new Point(12, 81);
+ labelWorkExperience.Name = "labelWorkExperience";
+ labelWorkExperience.Size = new Size(99, 20);
+ labelWorkExperience.TabIndex = 2;
+ labelWorkExperience.Text = "Стаж работы";
+ //
+ // labelQualification
+ //
+ labelQualification.AutoSize = true;
+ labelQualification.Location = new Point(12, 114);
+ labelQualification.Name = "labelQualification";
+ labelQualification.Size = new Size(111, 20);
+ labelQualification.TabIndex = 3;
+ labelQualification.Text = "Квалификация";
+ //
+ // textBoxPassword
+ //
+ textBoxPassword.Location = new Point(129, 45);
+ textBoxPassword.Name = "textBoxPassword";
+ textBoxPassword.Size = new Size(241, 27);
+ textBoxPassword.TabIndex = 4;
+ //
+ // textBoxFIO
+ //
+ textBoxFIO.Location = new Point(129, 12);
+ textBoxFIO.Name = "textBoxFIO";
+ textBoxFIO.Size = new Size(241, 27);
+ textBoxFIO.TabIndex = 5;
+ //
+ // textBoxWorkExperience
+ //
+ textBoxWorkExperience.Location = new Point(129, 78);
+ textBoxWorkExperience.Name = "textBoxWorkExperience";
+ textBoxWorkExperience.Size = new Size(134, 27);
+ textBoxWorkExperience.TabIndex = 6;
+ //
+ // textBoxQualification
+ //
+ textBoxQualification.Location = new Point(129, 111);
+ textBoxQualification.Name = "textBoxQualification";
+ textBoxQualification.Size = new Size(134, 27);
+ textBoxQualification.TabIndex = 7;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(168, 146);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(102, 29);
+ buttonSave.TabIndex = 8;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(276, 146);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 9;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormImplementer
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(382, 187);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxQualification);
+ Controls.Add(textBoxWorkExperience);
+ Controls.Add(textBoxFIO);
+ Controls.Add(textBoxPassword);
+ Controls.Add(labelQualification);
+ Controls.Add(labelWorkExperience);
+ Controls.Add(labelPassword);
+ Controls.Add(labelFIO);
+ Name = "FormImplementer";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Исполнитель";
+ Load += FormImplementer_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelFIO;
+ private Label labelPassword;
+ private Label labelWorkExperience;
+ private Label labelQualification;
+ private TextBox textBoxPassword;
+ private TextBox textBoxFIO;
+ private TextBox textBoxWorkExperience;
+ private TextBox textBoxQualification;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/Typography/Typography/FormImplementer.cs b/Typography/Typography/FormImplementer.cs
new file mode 100644
index 0000000..a951049
--- /dev/null
+++ b/Typography/Typography/FormImplementer.cs
@@ -0,0 +1,92 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace Typography
+{
+ 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 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;
+ textBoxWorkExperience.Text = view.WorkExperience.ToString();
+ textBoxQualification.Text = view.Qualification.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,
+ WorkExperience = Convert.ToInt32(textBoxWorkExperience.Text),
+ Qualification = Convert.ToInt32(textBoxQualification.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();
+ }
+ }
+}
diff --git a/Typography/Typography/FormImplementer.resx b/Typography/Typography/FormImplementer.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Typography/Typography/FormImplementer.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Typography/Typography/FormImplementers.Designer.cs b/Typography/Typography/FormImplementers.Designer.cs
new file mode 100644
index 0000000..0e36bcb
--- /dev/null
+++ b/Typography/Typography/FormImplementers.Designer.cs
@@ -0,0 +1,118 @@
+namespace Typography
+{
+ partial class FormImplementers
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridViewImplementers = new DataGridView();
+ buttonRef = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ buttonAdd = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridViewImplementers).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridViewImplementers
+ //
+ dataGridViewImplementers.BackgroundColor = SystemColors.ControlLightLight;
+ dataGridViewImplementers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewImplementers.Location = new Point(1, 1);
+ dataGridViewImplementers.Name = "dataGridViewImplementers";
+ dataGridViewImplementers.RowHeadersVisible = false;
+ dataGridViewImplementers.RowHeadersWidth = 51;
+ dataGridViewImplementers.RowTemplate.Height = 29;
+ dataGridViewImplementers.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridViewImplementers.Size = new Size(650, 402);
+ dataGridViewImplementers.TabIndex = 0;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(668, 117);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(102, 29);
+ buttonRef.TabIndex = 1;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += ButtonRef_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(668, 82);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(102, 29);
+ buttonDel.TabIndex = 2;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += ButtonDel_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(668, 47);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(102, 29);
+ buttonUpd.TabIndex = 3;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += ButtonUpd_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(668, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(102, 29);
+ buttonAdd.TabIndex = 4;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // FormImplementers
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(782, 403);
+ Controls.Add(buttonAdd);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonRef);
+ Controls.Add(dataGridViewImplementers);
+ Name = "FormImplementers";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Исполнители";
+ Load += FormImplementers_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridViewImplementers).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridViewImplementers;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ }
+}
\ No newline at end of file
diff --git a/Typography/Typography/FormImplementers.cs b/Typography/Typography/FormImplementers.cs
new file mode 100644
index 0000000..b9638d4
--- /dev/null
+++ b/Typography/Typography/FormImplementers.cs
@@ -0,0 +1,104 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using TypographyView;
+
+namespace Typography
+{
+ public partial class FormImplementers : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IImplementerLogic _logic;
+
+ public FormImplementers(ILogger 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)
+ {
+ dataGridViewImplementers.DataSource = list;
+ dataGridViewImplementers.Columns["Id"].Visible = false;
+ dataGridViewImplementers.Columns["ImplementerFIO"].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 (dataGridViewImplementers.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
+ if (service is FormImplementer form)
+ {
+ form.Id = Convert.ToInt32(dataGridViewImplementers.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridViewImplementers.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
+ DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridViewImplementers.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();
+ }
+ }
+}
diff --git a/Typography/Typography/FormImplementers.resx b/Typography/Typography/FormImplementers.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Typography/Typography/FormImplementers.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Typography/Typography/FormMain.Designer.cs b/Typography/Typography/FormMain.Designer.cs
index b7a5269..21272d6 100644
--- a/Typography/Typography/FormMain.Designer.cs
+++ b/Typography/Typography/FormMain.Designer.cs
@@ -33,16 +33,16 @@
directoriesToolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem();
printedsToolStripMenuItem = new ToolStripMenuItem();
+ clientsToolStripMenuItem = new ToolStripMenuItem();
+ implementersToolStripMenuItem = new ToolStripMenuItem();
ReportsToolStripMenuItem = new ToolStripMenuItem();
PrintedListToolStripMenuItem = new ToolStripMenuItem();
PrintedComponentsToolStripMenuItem = new ToolStripMenuItem();
ListOfOrdersToolStripMenuItem = new ToolStripMenuItem();
+ workLaunchToolStripMenuItem = new ToolStripMenuItem();
buttonCreateOrder = new Button();
- buttonTakeOrderInWork = new Button();
- buttonOrderReady = new Button();
buttonIssuedOrder = new Button();
buttonRef = new Button();
- clientsToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
@@ -63,7 +63,7 @@
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
- menuStrip.Items.AddRange(new ToolStripItem[] { directoriesToolStripMenuItem, ReportsToolStripMenuItem });
+ menuStrip.Items.AddRange(new ToolStripItem[] { directoriesToolStripMenuItem, ReportsToolStripMenuItem, workLaunchToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1331, 28);
@@ -72,7 +72,7 @@
//
// directoriesToolStripMenuItem
//
- directoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, printedsToolStripMenuItem, clientsToolStripMenuItem });
+ directoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, printedsToolStripMenuItem, clientsToolStripMenuItem, implementersToolStripMenuItem });
directoriesToolStripMenuItem.Name = "directoriesToolStripMenuItem";
directoriesToolStripMenuItem.Size = new Size(117, 24);
directoriesToolStripMenuItem.Text = "Справочники";
@@ -91,6 +91,20 @@
printedsToolStripMenuItem.Text = "Печатная продукция";
printedsToolStripMenuItem.Click += printedsToolStripMenuItem_Click;
//
+ // clientsToolStripMenuItem
+ //
+ clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
+ clientsToolStripMenuItem.Size = new Size(237, 26);
+ clientsToolStripMenuItem.Text = "Клиенты";
+ clientsToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
+ //
+ // implementersToolStripMenuItem
+ //
+ implementersToolStripMenuItem.Name = "implementersToolStripMenuItem";
+ implementersToolStripMenuItem.Size = new Size(237, 26);
+ implementersToolStripMenuItem.Text = "Исполнители";
+ implementersToolStripMenuItem.Click += implementersToolStripMenuItem_Click;
+ //
// ReportsToolStripMenuItem
//
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { PrintedListToolStripMenuItem, PrintedComponentsToolStripMenuItem, ListOfOrdersToolStripMenuItem });
@@ -119,6 +133,13 @@
ListOfOrdersToolStripMenuItem.Text = "Список заказов";
ListOfOrdersToolStripMenuItem.Click += ListOfOrdersToolStripMenuItem_Click;
//
+ // workLaunchToolStripMenuItem
+ //
+ workLaunchToolStripMenuItem.Name = "workLaunchToolStripMenuItem";
+ workLaunchToolStripMenuItem.Size = new Size(114, 24);
+ workLaunchToolStripMenuItem.Text = "Запуск работ";
+ workLaunchToolStripMenuItem.Click += workLaunchToolStripMenuItem_Click;
+ //
// buttonCreateOrder
//
buttonCreateOrder.Location = new Point(1109, 42);
@@ -129,29 +150,9 @@
buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += buttonCreateOrder_Click;
//
- // buttonTakeOrderInWork
- //
- buttonTakeOrderInWork.Location = new Point(1109, 96);
- buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
- buttonTakeOrderInWork.Size = new Size(195, 29);
- buttonTakeOrderInWork.TabIndex = 6;
- buttonTakeOrderInWork.Text = "Отдать на выполнение";
- buttonTakeOrderInWork.UseVisualStyleBackColor = true;
- buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
- //
- // buttonOrderReady
- //
- buttonOrderReady.Location = new Point(1109, 149);
- buttonOrderReady.Name = "buttonOrderReady";
- buttonOrderReady.Size = new Size(195, 29);
- buttonOrderReady.TabIndex = 7;
- buttonOrderReady.Text = "Заказ готов";
- buttonOrderReady.UseVisualStyleBackColor = true;
- buttonOrderReady.Click += buttonOrderReady_Click;
- //
// buttonIssuedOrder
//
- buttonIssuedOrder.Location = new Point(1109, 202);
+ buttonIssuedOrder.Location = new Point(1109, 108);
buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonIssuedOrder.Size = new Size(195, 29);
buttonIssuedOrder.TabIndex = 8;
@@ -161,7 +162,7 @@
//
// buttonRef
//
- buttonRef.Location = new Point(1109, 255);
+ buttonRef.Location = new Point(1109, 174);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(195, 29);
buttonRef.TabIndex = 9;
@@ -169,13 +170,6 @@
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += buttonRef_Click;
//
- // clientsToolStripMenuItem
- //
- clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
- clientsToolStripMenuItem.Size = new Size(237, 26);
- clientsToolStripMenuItem.Text = "Клиенты";
- clientsToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
- //
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
@@ -183,8 +177,6 @@
ClientSize = new Size(1331, 453);
Controls.Add(buttonRef);
Controls.Add(buttonIssuedOrder);
- Controls.Add(buttonOrderReady);
- Controls.Add(buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder);
Controls.Add(dataGridViewOrders);
Controls.Add(menuStrip);
@@ -207,8 +199,6 @@
private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem printedsToolStripMenuItem;
private Button buttonCreateOrder;
- private Button buttonTakeOrderInWork;
- private Button buttonOrderReady;
private Button buttonIssuedOrder;
private Button buttonRef;
private ToolStripMenuItem ReportsToolStripMenuItem;
@@ -216,5 +206,7 @@
private ToolStripMenuItem PrintedComponentsToolStripMenuItem;
private ToolStripMenuItem ListOfOrdersToolStripMenuItem;
private ToolStripMenuItem clientsToolStripMenuItem;
+ private ToolStripMenuItem implementersToolStripMenuItem;
+ private ToolStripMenuItem workLaunchToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/Typography/Typography/FormMain.cs b/Typography/Typography/FormMain.cs
index 26cb509..60a1ad4 100644
--- a/Typography/Typography/FormMain.cs
+++ b/Typography/Typography/FormMain.cs
@@ -3,6 +3,7 @@ using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using Typography;
+using TypographyContracts.BindingModels;
using TypographyBusinessLogic.BusinessLogics;
namespace TypographyView
@@ -12,12 +13,14 @@ namespace TypographyView
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic)
+ private readonly IWorkProcess _workProcess;
+ public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
+ _workProcess = workProcess;
}
private void LoadData()
{
@@ -28,6 +31,7 @@ namespace TypographyView
{
dataGridViewOrders.DataSource = list;
dataGridViewOrders.Columns["ClientId"].Visible = false;
+ dataGridViewOrders.Columns["ImplementerId"].Visible = false;
dataGridViewOrders.Columns["PrintedId"].Visible = false;
dataGridViewOrders.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
@@ -64,50 +68,6 @@ namespace TypographyView
LoadData();
}
}
- private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
- {
- if (dataGridViewOrders.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
- try
- {
- var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка передачи заказа в работу");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- private void buttonOrderReady_Click(object sender, EventArgs e)
- {
- if (dataGridViewOrders.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
- try
- {
- var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка отметки о готовности заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
private void buttonIssuedOrder_Click(object sender, EventArgs e)
{
if (dataGridViewOrders.SelectedRows.Count == 1)
@@ -172,5 +132,18 @@ namespace TypographyView
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 workLaunchToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
+ MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
}
}
diff --git a/Typography/Typography/Program.cs b/Typography/Typography/Program.cs
index f8c4f3e..c265a3d 100644
--- a/Typography/Typography/Program.cs
+++ b/Typography/Typography/Program.cs
@@ -42,12 +42,15 @@ namespace TypographyView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -63,6 +66,8 @@ namespace TypographyView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/Typography/TypographyBusinessLogic/BusinessLogics/ImplementerLogic.cs b/Typography/TypographyBusinessLogic/BusinessLogics/ImplementerLogic.cs
new file mode 100644
index 0000000..8d66666
--- /dev/null
+++ b/Typography/TypographyBusinessLogic/BusinessLogics/ImplementerLogic.cs
@@ -0,0 +1,116 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace TypographyBusinessLogic.BusinessLogics
+{
+ public class ImplementerLogic : IImplementerLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IImplementerStorage _implementerStorage;
+
+ public ImplementerLogic(ILogger logger, IImplementerStorage implementerStorage)
+ {
+ _logger = logger;
+ _implementerStorage = implementerStorage;
+ }
+ public List? ReadList(ImplementerSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Id: {Id}. ImplementerFIO: {ImplementerFIO}.",
+ model?.Id, model?.ImplementerFIO);
+ 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. Id: {Id}. ImplementerFIO: {ImplementerFIO}.",
+ model?.Id, model?.ImplementerFIO);
+ 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("Стаж работы должен быть неотрицательным", nameof(model.WorkExperience));
+ }
+ if (model.Qualification < 0)
+ {
+ throw new ArgumentNullException("Квалификация должна быть неотрицательной", nameof(model.Qualification));
+ }
+ _logger.LogInformation("Implementer. Id: {Id}. ImplementerFIO: {ImplementerFIO}. WorkExperience: {WorkExperience}. Qualification: {Qualification}.",
+ model?.Id, model?.ImplementerFIO, model?.WorkExperience, model?.Qualification);
+ var element = _implementerStorage.GetElement(new ImplementerSearchModel { ImplementerFIO = model.ImplementerFIO });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyBusinessLogic/BusinessLogics/OrderLogic.cs b/Typography/TypographyBusinessLogic/BusinessLogics/OrderLogic.cs
index e16e12c..220ebfa 100644
--- a/Typography/TypographyBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/Typography/TypographyBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -5,6 +5,7 @@ using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using Microsoft.Extensions.Logging;
using TypographyDataModels.Enums;
+using System.Xml.Linq;
namespace TypographyBusinessLogic.BusinessLogics
{
@@ -12,11 +13,29 @@ namespace TypographyBusinessLogic.BusinessLogics
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
+ static readonly object _locker = new object();
public OrderLogic(ILogger logger, IOrderStorage orderStorage)
{
_logger = logger;
_orderStorage = orderStorage;
}
+ public OrderViewModel? ReadElement(OrderSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ClientId: {ClientId}. ImplementerId: {ImplementerId}. Status: {Status}. DateFrom: {DateFrom}. DateTo: {DateTo}. Id: {Id}",
+ model.ClientId, model.ImplementerId, model.Status, model.DateFrom, model.DateTo, 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? ReadList(OrderSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
@@ -48,7 +67,10 @@ namespace TypographyBusinessLogic.BusinessLogics
}
public bool TakeOrderInWork(OrderBindingModel model)
{
- return ChangeOrderStatus(model, OrderStatus.Выполняется);
+ lock (_locker)
+ {
+ return ChangeOrderStatus(model, OrderStatus.Выполняется);
+ }
}
public bool FinishOrder(OrderBindingModel model)
{
@@ -89,11 +111,13 @@ namespace TypographyBusinessLogic.BusinessLogics
return false;
}
model.Status = newStatus;
- if (newStatus == OrderStatus.Выдан)
+ if (!model.ImplementerId.HasValue)
+ model.ImplementerId = orderView.ImplementerId;
+ model.DateImplement = orderView.DateImplement;
+ if (newStatus == OrderStatus.Готов)
{
model.DateImplement = DateTime.Now;
}
-
if (_orderStorage.Update(model) == null)
{
_logger.LogWarning("Order status change failed");
diff --git a/Typography/TypographyBusinessLogic/BusinessLogics/WorkModeling.cs b/Typography/TypographyBusinessLogic/BusinessLogics/WorkModeling.cs
new file mode 100644
index 0000000..affe598
--- /dev/null
+++ b/Typography/TypographyBusinessLogic/BusinessLogics/WorkModeling.cs
@@ -0,0 +1,118 @@
+using TypographyDataModels.Enums;
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace TypographyBusinessLogic.BusinessLogics
+{
+ public class WorkModeling : IWorkProcess
+ {
+ private readonly ILogger _logger;
+ private readonly Random _rnd;
+ private IOrderLogic? _orderLogic;
+ public WorkModeling(ILogger 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));
+ }
+ }
+ private async Task WorkerWorkAsync(ImplementerViewModel implementer, List 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;
+ }
+ }
+ });
+ }
+ 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;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyContracts/BindingModels/ImplementerBindingModel.cs b/Typography/TypographyContracts/BindingModels/ImplementerBindingModel.cs
new file mode 100644
index 0000000..0e84f5f
--- /dev/null
+++ b/Typography/TypographyContracts/BindingModels/ImplementerBindingModel.cs
@@ -0,0 +1,13 @@
+using TypographyDataModels.Models;
+
+namespace TypographyContracts.BindingModels
+{
+ public class ImplementerBindingModel : IImplementerModel
+ {
+ public int Id { get; set; }
+ public string ImplementerFIO { get; set; } = string.Empty;
+ public string Password { get; set; } = string.Empty;
+ public int WorkExperience { get; set; }
+ public int Qualification { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyContracts/BindingModels/OrderBindingModel.cs b/Typography/TypographyContracts/BindingModels/OrderBindingModel.cs
index 51d2e31..e427a88 100644
--- a/Typography/TypographyContracts/BindingModels/OrderBindingModel.cs
+++ b/Typography/TypographyContracts/BindingModels/OrderBindingModel.cs
@@ -6,8 +6,9 @@ namespace TypographyContracts.BindingModels
public class OrderBindingModel : IOrderModel
{
public int Id { get; set; }
- public int PrintedId { get; set; }
public int ClientId { get; set; }
+ public int? ImplementerId { get; set; }
+ public int PrintedId { get; set; }
public int Count { get; set; }
public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
diff --git a/Typography/TypographyContracts/BusinessLogicsContracts/IImplementerLogic.cs b/Typography/TypographyContracts/BusinessLogicsContracts/IImplementerLogic.cs
new file mode 100644
index 0000000..c51afa7
--- /dev/null
+++ b/Typography/TypographyContracts/BusinessLogicsContracts/IImplementerLogic.cs
@@ -0,0 +1,15 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+
+namespace TypographyContracts.BusinessLogicsContracts
+{
+ public interface IImplementerLogic
+ {
+ List? ReadList(ImplementerSearchModel? model);
+ ImplementerViewModel? ReadElement(ImplementerSearchModel model);
+ bool Create(ImplementerBindingModel model);
+ bool Update(ImplementerBindingModel model);
+ bool Delete(ImplementerBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyContracts/BusinessLogicsContracts/IOrderLogic.cs b/Typography/TypographyContracts/BusinessLogicsContracts/IOrderLogic.cs
index 60c0caf..0117717 100644
--- a/Typography/TypographyContracts/BusinessLogicsContracts/IOrderLogic.cs
+++ b/Typography/TypographyContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -7,6 +7,7 @@ namespace TypographyContracts.BusinessLogicsContracts
public interface IOrderLogic
{
List? ReadList(OrderSearchModel? model);
+ OrderViewModel? ReadElement(OrderSearchModel model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
diff --git a/Typography/TypographyContracts/BusinessLogicsContracts/IWorkProcess.cs b/Typography/TypographyContracts/BusinessLogicsContracts/IWorkProcess.cs
new file mode 100644
index 0000000..1ad7f6c
--- /dev/null
+++ b/Typography/TypographyContracts/BusinessLogicsContracts/IWorkProcess.cs
@@ -0,0 +1,7 @@
+namespace TypographyContracts.BusinessLogicsContracts
+{
+ public interface IWorkProcess
+ {
+ void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyContracts/SearchModels/ImplementerSearchModel.cs b/Typography/TypographyContracts/SearchModels/ImplementerSearchModel.cs
new file mode 100644
index 0000000..ba2ab8e
--- /dev/null
+++ b/Typography/TypographyContracts/SearchModels/ImplementerSearchModel.cs
@@ -0,0 +1,9 @@
+namespace TypographyContracts.SearchModels
+{
+ public class ImplementerSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ImplementerFIO { get; set; }
+ public string? Password { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyContracts/SearchModels/OrderSearchModel.cs b/Typography/TypographyContracts/SearchModels/OrderSearchModel.cs
index 7c6d367..f01f6cc 100644
--- a/Typography/TypographyContracts/SearchModels/OrderSearchModel.cs
+++ b/Typography/TypographyContracts/SearchModels/OrderSearchModel.cs
@@ -1,9 +1,13 @@
-namespace TypographyContracts.SearchModels
+using TypographyDataModels.Enums;
+
+namespace TypographyContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
public int? ClientId { get; set; }
+ public int? ImplementerId { get; set; }
+ public OrderStatus? Status { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
diff --git a/Typography/TypographyContracts/StoragesContracts/IImplementerStorage.cs b/Typography/TypographyContracts/StoragesContracts/IImplementerStorage.cs
new file mode 100644
index 0000000..deef979
--- /dev/null
+++ b/Typography/TypographyContracts/StoragesContracts/IImplementerStorage.cs
@@ -0,0 +1,16 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+
+namespace TypographyContracts.StoragesContracts
+{
+ public interface IImplementerStorage
+ {
+ List GetFullList();
+ List GetFilteredList(ImplementerSearchModel model);
+ ImplementerViewModel? GetElement(ImplementerSearchModel model);
+ ImplementerViewModel? Insert(ImplementerBindingModel model);
+ ImplementerViewModel? Update(ImplementerBindingModel model);
+ ImplementerViewModel? Delete(ImplementerBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyContracts/ViewModels/ImplementerViewModel.cs b/Typography/TypographyContracts/ViewModels/ImplementerViewModel.cs
new file mode 100644
index 0000000..3921a6a
--- /dev/null
+++ b/Typography/TypographyContracts/ViewModels/ImplementerViewModel.cs
@@ -0,0 +1,18 @@
+using TypographyDataModels.Models;
+using System.ComponentModel;
+
+namespace TypographyContracts.ViewModels
+{
+ public class ImplementerViewModel : IImplementerModel
+ {
+ public int Id { get; set; }
+ [DisplayName("ФИО исполнителя")]
+ public string ImplementerFIO { get; set; } = string.Empty;
+ [DisplayName("Пароль")]
+ public string Password { get; set; } = string.Empty;
+ [DisplayName("Стаж работы")]
+ public int WorkExperience { get; set; }
+ [DisplayName("Квалификация")]
+ public int Qualification { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyContracts/ViewModels/OrderViewModel.cs b/Typography/TypographyContracts/ViewModels/OrderViewModel.cs
index 9573e43..a50ea9a 100644
--- a/Typography/TypographyContracts/ViewModels/OrderViewModel.cs
+++ b/Typography/TypographyContracts/ViewModels/OrderViewModel.cs
@@ -11,6 +11,9 @@ namespace TypographyContracts.ViewModels
public int ClientId { get; set; }
[DisplayName("Клиент")]
public string ClientFIO { get; set; } = string.Empty;
+ public int? ImplementerId { get; set; }
+ [DisplayName("Исполнитель")]
+ public string? ImplementerFIO { get; set; } = string.Empty;
public int PrintedId { get; set; }
[DisplayName("Изделие")]
public string PrintedName { get; set; } = string.Empty;
diff --git a/Typography/TypographyDataModels/Models/IImplementerModel.cs b/Typography/TypographyDataModels/Models/IImplementerModel.cs
new file mode 100644
index 0000000..78c71e9
--- /dev/null
+++ b/Typography/TypographyDataModels/Models/IImplementerModel.cs
@@ -0,0 +1,10 @@
+namespace TypographyDataModels.Models
+{
+ public interface IImplementerModel : IId
+ {
+ string ImplementerFIO { get; }
+ string Password { get; }
+ int WorkExperience { get; }
+ int Qualification { get; }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyDataModels/Models/IOrderModel.cs b/Typography/TypographyDataModels/Models/IOrderModel.cs
index 53fb182..bfba85f 100644
--- a/Typography/TypographyDataModels/Models/IOrderModel.cs
+++ b/Typography/TypographyDataModels/Models/IOrderModel.cs
@@ -5,6 +5,7 @@ namespace TypographyDataModels.Models
public interface IOrderModel : IId
{
int ClientId { get; }
+ int? ImplementerId { get; }
int PrintedId { get; }
int Count { get; }
double Sum { get; }
diff --git a/Typography/TypographyDatabaseImplement/Implements/ImplementerStorage.cs b/Typography/TypographyDatabaseImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..cab6e28
--- /dev/null
+++ b/Typography/TypographyDatabaseImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,80 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using TypographyDatabaseImplement.Models;
+
+namespace TypographyDatabaseImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new TypographyDatabase();
+ return context.Implementers
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ return new();
+ }
+ using var context = new TypographyDatabase();
+ return context.Implementers
+ .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ if (!model.Id.HasValue && string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
+ {
+ return null;
+ }
+ using var context = new TypographyDatabase();
+ return context.Implementers
+ .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) ||
+ (!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO &&
+ !string.IsNullOrEmpty(model.Password) && x.Password == model.Password))
+ ?.GetViewModel;
+ }
+ public ImplementerViewModel? Insert(ImplementerBindingModel model)
+ {
+ var newImplementer = Implementer.Create(model);
+ if (newImplementer == null)
+ {
+ return null;
+ }
+ using var context = new TypographyDatabase();
+ context.Implementers.Add(newImplementer);
+ context.SaveChanges();
+ return newImplementer.GetViewModel;
+ }
+ public ImplementerViewModel? Update(ImplementerBindingModel model)
+ {
+ using var context = new TypographyDatabase();
+ var implementer = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
+ if (implementer == null)
+ {
+ return null;
+ }
+ implementer.Update(model);
+ context.SaveChanges();
+ return implementer.GetViewModel;
+ }
+ public ImplementerViewModel? Delete(ImplementerBindingModel model)
+ {
+ using var context = new TypographyDatabase();
+ var element = context.Implementers.FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ context.Implementers.Remove(element);
+ context.SaveChanges();
+ return element.GetViewModel;
+ }
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyDatabaseImplement/Implements/OrderStorage.cs b/Typography/TypographyDatabaseImplement/Implements/OrderStorage.cs
index e4b9b15..217fca6 100644
--- a/Typography/TypographyDatabaseImplement/Implements/OrderStorage.cs
+++ b/Typography/TypographyDatabaseImplement/Implements/OrderStorage.cs
@@ -11,7 +11,7 @@ namespace TypographyDatabaseImplement.Implements
{
public OrderViewModel? GetElement(OrderSearchModel model)
{
- if (!model.Id.HasValue)
+ if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
{
return null;
}
@@ -19,11 +19,14 @@ namespace TypographyDatabaseImplement.Implements
return context.Orders
.Include(x => x.Printed)
.Include(x => x.Client)
- .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (model.ClientId.HasValue && x.ClientId == model.ClientId))?.GetViewModel;
+ .Include(x => x.Implementer)
+ .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) ||
+ (model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId && x.Status == model.Status))?
+ .GetViewModel;
}
public List GetFilteredList(OrderSearchModel model)
{
- if ((!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue)
+ if ((!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue && !model.Status.HasValue)
{
return new();
}
@@ -31,8 +34,10 @@ namespace TypographyDatabaseImplement.Implements
return context.Orders
.Include(x => x.Printed)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.Where(x => (model.DateFrom.HasValue && model.DateTo.HasValue && x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) ||
- (model.ClientId.HasValue && x.ClientId == model.ClientId))
+ (model.ClientId.HasValue && x.ClientId == model.ClientId) ||
+ (model.Status.HasValue && x.Status == model.Status))
.Select(x => x.GetViewModel)
.ToList();
}
@@ -42,6 +47,7 @@ namespace TypographyDatabaseImplement.Implements
return context.Orders
.Include(x => x.Printed)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.Select(x => x.GetViewModel)
.ToList();
}
@@ -65,7 +71,7 @@ namespace TypographyDatabaseImplement.Implements
{
return null;
}
- order.Update(model);
+ order.Update(model, context);
context.SaveChanges();
return order.GetViewModel;
}
diff --git a/Typography/TypographyDatabaseImplement/Migrations/20240524210919_r.Designer.cs b/Typography/TypographyDatabaseImplement/Migrations/20240525000632_r.Designer.cs
similarity index 82%
rename from Typography/TypographyDatabaseImplement/Migrations/20240524210919_r.Designer.cs
rename to Typography/TypographyDatabaseImplement/Migrations/20240525000632_r.Designer.cs
index d4fbb14..c2f4955 100644
--- a/Typography/TypographyDatabaseImplement/Migrations/20240524210919_r.Designer.cs
+++ b/Typography/TypographyDatabaseImplement/Migrations/20240525000632_r.Designer.cs
@@ -12,7 +12,7 @@ using TypographyDatabaseImplement;
namespace TypographyDatabaseImplement.Migrations
{
[DbContext(typeof(TypographyDatabase))]
- [Migration("20240524210919_r")]
+ [Migration("20240525000632_r")]
partial class r
{
///
@@ -70,6 +70,33 @@ namespace TypographyDatabaseImplement.Migrations
b.ToTable("Components");
});
+ modelBuilder.Entity("TypographyDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ImplementerFIO")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Qualification")
+ .HasColumnType("int");
+
+ b.Property("WorkExperience")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Implementers");
+ });
+
modelBuilder.Entity("TypographyDatabaseImplement.Models.Order", b =>
{
b.Property("Id")
@@ -90,6 +117,9 @@ namespace TypographyDatabaseImplement.Migrations
b.Property("DateImplement")
.HasColumnType("datetime2");
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
b.Property("PrintedId")
.HasColumnType("int");
@@ -103,6 +133,8 @@ namespace TypographyDatabaseImplement.Migrations
b.HasIndex("ClientId");
+ b.HasIndex("ImplementerId");
+
b.HasIndex("PrintedId");
b.ToTable("Orders");
@@ -162,6 +194,10 @@ namespace TypographyDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.HasOne("TypographyDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("ImplementerOrders")
+ .HasForeignKey("ImplementerId");
+
b.HasOne("TypographyDatabaseImplement.Models.Printed", "Printed")
.WithMany("Orders")
.HasForeignKey("PrintedId")
@@ -170,6 +206,8 @@ namespace TypographyDatabaseImplement.Migrations
b.Navigation("Client");
+ b.Navigation("Implementer");
+
b.Navigation("Printed");
});
@@ -202,6 +240,11 @@ namespace TypographyDatabaseImplement.Migrations
b.Navigation("PrintedComponents");
});
+ modelBuilder.Entity("TypographyDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("ImplementerOrders");
+ });
+
modelBuilder.Entity("TypographyDatabaseImplement.Models.Printed", b =>
{
b.Navigation("Components");
diff --git a/Typography/TypographyDatabaseImplement/Migrations/20240524210919_r.cs b/Typography/TypographyDatabaseImplement/Migrations/20240525000632_r.cs
similarity index 82%
rename from Typography/TypographyDatabaseImplement/Migrations/20240524210919_r.cs
rename to Typography/TypographyDatabaseImplement/Migrations/20240525000632_r.cs
index a34a53f..80efa95 100644
--- a/Typography/TypographyDatabaseImplement/Migrations/20240524210919_r.cs
+++ b/Typography/TypographyDatabaseImplement/Migrations/20240525000632_r.cs
@@ -40,6 +40,22 @@ namespace TypographyDatabaseImplement.Migrations
table.PrimaryKey("PK_Components", x => x.Id);
});
+ migrationBuilder.CreateTable(
+ name: "Implementers",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false),
+ Password = table.Column(type: "nvarchar(max)", nullable: false),
+ WorkExperience = table.Column(type: "int", nullable: false),
+ Qualification = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Implementers", x => x.Id);
+ });
+
migrationBuilder.CreateTable(
name: "Printeds",
columns: table => new
@@ -61,6 +77,7 @@ namespace TypographyDatabaseImplement.Migrations
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientId = table.Column(type: "int", nullable: false),
+ ImplementerId = table.Column(type: "int", nullable: true),
PrintedId = table.Column(type: "int", nullable: false),
Count = table.Column(type: "int", nullable: false),
Sum = table.Column(type: "float", nullable: false),
@@ -77,6 +94,11 @@ namespace TypographyDatabaseImplement.Migrations
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ column: x => x.ImplementerId,
+ principalTable: "Implementers",
+ principalColumn: "Id");
table.ForeignKey(
name: "FK_Orders_Printeds_PrintedId",
column: x => x.PrintedId,
@@ -117,6 +139,11 @@ namespace TypographyDatabaseImplement.Migrations
table: "Orders",
column: "ClientId");
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId");
+
migrationBuilder.CreateIndex(
name: "IX_Orders_PrintedId",
table: "Orders",
@@ -145,6 +172,9 @@ namespace TypographyDatabaseImplement.Migrations
migrationBuilder.DropTable(
name: "Clients");
+ migrationBuilder.DropTable(
+ name: "Implementers");
+
migrationBuilder.DropTable(
name: "Components");
diff --git a/Typography/TypographyDatabaseImplement/Migrations/TypographyDatabaseModelSnapshot.cs b/Typography/TypographyDatabaseImplement/Migrations/TypographyDatabaseModelSnapshot.cs
index cc7d7f1..16842c9 100644
--- a/Typography/TypographyDatabaseImplement/Migrations/TypographyDatabaseModelSnapshot.cs
+++ b/Typography/TypographyDatabaseImplement/Migrations/TypographyDatabaseModelSnapshot.cs
@@ -67,6 +67,33 @@ namespace TypographyDatabaseImplement.Migrations
b.ToTable("Components");
});
+ modelBuilder.Entity("TypographyDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ImplementerFIO")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Qualification")
+ .HasColumnType("int");
+
+ b.Property("WorkExperience")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Implementers");
+ });
+
modelBuilder.Entity("TypographyDatabaseImplement.Models.Order", b =>
{
b.Property("Id")
@@ -87,6 +114,9 @@ namespace TypographyDatabaseImplement.Migrations
b.Property("DateImplement")
.HasColumnType("datetime2");
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
b.Property("PrintedId")
.HasColumnType("int");
@@ -100,6 +130,8 @@ namespace TypographyDatabaseImplement.Migrations
b.HasIndex("ClientId");
+ b.HasIndex("ImplementerId");
+
b.HasIndex("PrintedId");
b.ToTable("Orders");
@@ -159,6 +191,10 @@ namespace TypographyDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.HasOne("TypographyDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("ImplementerOrders")
+ .HasForeignKey("ImplementerId");
+
b.HasOne("TypographyDatabaseImplement.Models.Printed", "Printed")
.WithMany("Orders")
.HasForeignKey("PrintedId")
@@ -167,6 +203,8 @@ namespace TypographyDatabaseImplement.Migrations
b.Navigation("Client");
+ b.Navigation("Implementer");
+
b.Navigation("Printed");
});
@@ -199,6 +237,11 @@ namespace TypographyDatabaseImplement.Migrations
b.Navigation("PrintedComponents");
});
+ modelBuilder.Entity("TypographyDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("ImplementerOrders");
+ });
+
modelBuilder.Entity("TypographyDatabaseImplement.Models.Printed", b =>
{
b.Navigation("Components");
diff --git a/Typography/TypographyDatabaseImplement/Models/Implementer.cs b/Typography/TypographyDatabaseImplement/Models/Implementer.cs
new file mode 100644
index 0000000..dc568aa
--- /dev/null
+++ b/Typography/TypographyDatabaseImplement/Models/Implementer.cs
@@ -0,0 +1,57 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.ViewModels;
+using TypographyDataModels.Models;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace TypographyDatabaseImplement.Models
+{
+ public class Implementer : IImplementerModel
+ {
+ public int Id { get; set; }
+ [Required]
+ public string ImplementerFIO { get; set; } = string.Empty;
+ [Required]
+ public string Password { get; set; } = string.Empty;
+ [Required]
+ public int WorkExperience { get; set; }
+ [Required]
+ public int Qualification { get; set; }
+ [ForeignKey("ImplementerId")]
+ public virtual List ImplementerOrders { get; set; } = new();
+ 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
+ };
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyDatabaseImplement/Models/Order.cs b/Typography/TypographyDatabaseImplement/Models/Order.cs
index 87bd16f..bcc406a 100644
--- a/Typography/TypographyDatabaseImplement/Models/Order.cs
+++ b/Typography/TypographyDatabaseImplement/Models/Order.cs
@@ -15,6 +15,8 @@ namespace TypographyDatabaseImplement.Models
[Required]
public int ClientId { get; private set; }
public virtual Client Client { get; set; } = new();
+ public int? ImplementerId { get; private set; }
+ public virtual Implementer? Implementer { get; set; } = new();
[Required]
public int PrintedId { get; private set; }
public virtual Printed Printed { get; set; } = new();
@@ -38,6 +40,8 @@ namespace TypographyDatabaseImplement.Models
Id = model.Id,
ClientId = model.ClientId,
Client = context.Clients.First(x => model.ClientId == x.Id),
+ ImplementerId = model.ImplementerId,
+ Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => model.ImplementerId == x.Id) : null,
PrintedId = model.PrintedId,
Printed = context.Printeds.First(x => model.PrintedId == x.Id),
Count = model.Count,
@@ -47,12 +51,14 @@ namespace TypographyDatabaseImplement.Models
DateImplement = model.DateImplement
};
}
- public void Update(OrderBindingModel? model)
+ public void Update(OrderBindingModel? model, TypographyDatabase context)
{
if (model == null)
{
return;
}
+ ImplementerId = model.ImplementerId;
+ Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => model.ImplementerId == x.Id) : null;
Status = model.Status;
DateImplement = model.DateImplement;
}
@@ -61,6 +67,8 @@ namespace TypographyDatabaseImplement.Models
Id = Id,
ClientId = ClientId,
ClientFIO = Client.ClientFIO,
+ ImplementerId = ImplementerId,
+ ImplementerFIO = Implementer != null ? Implementer.ImplementerFIO : null,
PrintedId = PrintedId,
PrintedName = Printed.PrintedName,
Count = Count,
diff --git a/Typography/TypographyDatabaseImplement/TypographyDatabase.cs b/Typography/TypographyDatabaseImplement/TypographyDatabase.cs
index 7247aa2..02f8300 100644
--- a/Typography/TypographyDatabaseImplement/TypographyDatabase.cs
+++ b/Typography/TypographyDatabaseImplement/TypographyDatabase.cs
@@ -10,7 +10,7 @@ namespace TypographyDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
- optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=TypographyDatabase_5;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
+ optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=Typograph6;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
@@ -19,5 +19,6 @@ namespace TypographyDatabaseImplement
public virtual DbSet PrintedComponents { set; get; }
public virtual DbSet Orders { set; get; }
public virtual DbSet Clients { set; get; }
+ public virtual DbSet Implementers { set; get; }
}
}
\ No newline at end of file
diff --git a/Typography/TypographyFileImplement/DataFileSingleton.cs b/Typography/TypographyFileImplement/DataFileSingleton.cs
index cc2a54f..4776a8d 100644
--- a/Typography/TypographyFileImplement/DataFileSingleton.cs
+++ b/Typography/TypographyFileImplement/DataFileSingleton.cs
@@ -11,10 +11,12 @@ namespace TypographyFileImplement
private readonly string OrderFileName = "Order.xml";
private readonly string PrintedFileName = "Printed.xml";
private readonly string ClientFileName = "Client.xml";
+ private readonly string ImplementerFileName = "Implementer.xml";
public List Components { get; private set; }
public List Orders { get; private set; }
public List Printeds { get; private set; }
public List Clients { get; private set; }
+ public List Implementers { get; private set; }
public static DataFileSingleton GetInstance()
{
if (instance == null)
@@ -27,12 +29,14 @@ namespace TypographyFileImplement
public void SavePrinteds() => SaveData(Printeds, PrintedFileName, "Printeds", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
+ public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
private DataFileSingleton()
{
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
Printeds = LoadData(PrintedFileName, "Product", x => Printed.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
+ Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
}
private static List? LoadData(string filename, string xmlNodeName, Func selectFunction)
{
diff --git a/Typography/TypographyFileImplement/Implements/ImplementerStorage.cs b/Typography/TypographyFileImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..aa4024a
--- /dev/null
+++ b/Typography/TypographyFileImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,80 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using TypographyFileImplement.Models;
+
+namespace TypographyFileImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ private readonly DataFileSingleton source;
+ public ImplementerStorage()
+ {
+ source = DataFileSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ return source.Implementers
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ return new();
+ }
+ return source.Implementers
+ .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ if (!model.Id.HasValue && string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
+ {
+ return null;
+ }
+ return source.Implementers
+ .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) ||
+ (!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO &&
+ !string.IsNullOrEmpty(model.Password) && x.Password == model.Password))
+ ?.GetViewModel;
+ }
+ public ImplementerViewModel? Insert(ImplementerBindingModel model)
+ {
+ model.Id = source.Components.Count > 0 ? source.Components.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(x => x.Id == model.Id);
+ if (element != null)
+ {
+ source.Implementers.Remove(element);
+ source.SaveImplementers();
+ return element.GetViewModel;
+ }
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyFileImplement/Implements/OrderStorage.cs b/Typography/TypographyFileImplement/Implements/OrderStorage.cs
index 827e196..c14f0db 100644
--- a/Typography/TypographyFileImplement/Implements/OrderStorage.cs
+++ b/Typography/TypographyFileImplement/Implements/OrderStorage.cs
@@ -22,11 +22,16 @@ namespace TypographyFileImplement.Implements
private OrderViewModel DefineOthersNames(OrderViewModel model)
{
string? clientFIO = source.Clients.FirstOrDefault(x => model.ClientId == x.Id)?.ClientFIO;
+ string? implementerFIO = source.Implementers.FirstOrDefault(x => model.ImplementerId == x.Id)?.ImplementerFIO;
string? printedName = source.Printeds.FirstOrDefault(x => model.PrintedId == x.Id)?.PrintedName;
if (clientFIO != null)
{
model.ClientFIO = clientFIO;
}
+ if (implementerFIO != null)
+ {
+ model.ImplementerFIO = implementerFIO;
+ }
if (printedName != null)
{
model.PrintedName = printedName;
@@ -35,24 +40,28 @@ namespace TypographyFileImplement.Implements
}
public List GetFilteredList(OrderSearchModel model)
{
- if ((!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue)
+ if ((!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue && !model.Status.HasValue)
{
return new();
}
return source.Orders
.Where(x => (model.DateFrom.HasValue && model.DateTo.HasValue && x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) ||
- (model.ClientId.HasValue && x.ClientId == model.ClientId))
+ (model.ClientId.HasValue && x.ClientId == model.ClientId) ||
+ (model.Status.HasValue && x.Status == model.Status))
.Select(x => DefineOthersNames(x.GetViewModel))
.ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
- if (!model.Id.HasValue && !model.ClientId.HasValue)
+ if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
{
return null;
}
return DefineOthersNames(source.Orders
- .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (model.ClientId.HasValue && x.Id == model.ClientId))?.GetViewModel);
+ .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) ||
+ (model.ClientId.HasValue && x.Id == model.ClientId) ||
+ (model.ImplementerId.HasValue && x.Id == model.ImplementerId && x.Status == model.Status))?
+ .GetViewModel);
}
public OrderViewModel? Insert(OrderBindingModel model)
{
diff --git a/Typography/TypographyFileImplement/Models/Implementer.cs b/Typography/TypographyFileImplement/Models/Implementer.cs
new file mode 100644
index 0000000..4cc6492
--- /dev/null
+++ b/Typography/TypographyFileImplement/Models/Implementer.cs
@@ -0,0 +1,72 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.ViewModels;
+using TypographyDataModels.Models;
+using System.Xml.Linq;
+using System.Reflection;
+
+namespace TypographyFileImplement.Models
+{
+ public class Implementer : IImplementerModel
+ {
+ public int Id { get; private set; }
+ public string ImplementerFIO { get; private set; } = string.Empty;
+ public string Password { get; private set; } = string.Empty;
+ public int WorkExperience { get; private set; }
+ public int Qualification { get; private set; }
+ 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 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,
+ WorkExperience = Convert.ToInt32(element.Element("Cost")!.Value),
+ Qualification = Convert.ToInt32(element.Element("Cost")!.Value)
+ };
+ }
+ 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 XElement GetXElement => new("Implementer",
+ new XAttribute("Id", Id),
+ new XElement("ImplementerFIO", ImplementerFIO),
+ new XElement("Password", Password),
+ new XElement("WorkExperience", WorkExperience),
+ new XElement("Qualification", Qualification));
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyFileImplement/Models/Order.cs b/Typography/TypographyFileImplement/Models/Order.cs
index 4d14e55..180c389 100644
--- a/Typography/TypographyFileImplement/Models/Order.cs
+++ b/Typography/TypographyFileImplement/Models/Order.cs
@@ -15,6 +15,7 @@ namespace TypographyFileImplement.Models
{
public int Id { get; private set; }
public int ClientId { get; private set; }
+ public int? ImplementerId { get; private set; }
public int PrintedId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
@@ -31,6 +32,7 @@ namespace TypographyFileImplement.Models
{
Id = model.Id,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
PrintedId = model.PrintedId,
Count = model.Count,
Sum = model.Sum,
@@ -49,6 +51,7 @@ namespace TypographyFileImplement.Models
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
+ ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
PrintedId = Convert.ToInt32(element.Element("PrintedId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
@@ -65,12 +68,14 @@ namespace TypographyFileImplement.Models
return;
}
Status = model.Status;
+ ImplementerId = model.ImplementerId;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
ClientId = ClientId,
+ ImplementerId = ImplementerId,
PrintedId = PrintedId,
Count = Count,
Sum = Sum,
@@ -81,6 +86,7 @@ namespace TypographyFileImplement.Models
public XElement GetXElement => new("Order",
new XAttribute("Id", Id),
new XElement("ClientId", ClientId),
+ new XElement("ImplementerId", ImplementerId),
new XElement("PrintedId", PrintedId),
new XElement("Count", Count),
new XElement("Sum", Sum.ToString()),
diff --git a/Typography/TypographyListImplement/DataListSingleton.cs b/Typography/TypographyListImplement/DataListSingleton.cs
index 69cb538..c64fa22 100644
--- a/Typography/TypographyListImplement/DataListSingleton.cs
+++ b/Typography/TypographyListImplement/DataListSingleton.cs
@@ -9,12 +9,14 @@ namespace TypographyListImplement
public List Orders { get; set; }
public List Printeds { get; set; }
public List Clients { get; set; }
+ public List Implementers { get; set; }
private DataListSingleton()
{
Components = new List();
Orders = new List();
Printeds = new List();
Clients = new List();
+ Implementers = new List();
}
public static DataListSingleton GetInstance()
{
diff --git a/Typography/TypographyListImplement/Implements/ImplementerStorage.cs b/Typography/TypographyListImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..4687720
--- /dev/null
+++ b/Typography/TypographyListImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,102 @@
+using TypographyContracts.BindingModels;
+using TypographyContracts.SearchModels;
+using TypographyContracts.StoragesContracts;
+using TypographyContracts.ViewModels;
+using TypographyListImplement.Models;
+
+namespace TypographyListImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ private readonly DataListSingleton _source;
+ public ImplementerStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var implementer in _source.Implementers)
+ {
+ result.Add(implementer.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ 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)
+ {
+ if (!model.Id.HasValue && string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password))
+ {
+ return null;
+ }
+ foreach (var implementer in _source.Implementers)
+ {
+ if ((model.Id.HasValue && implementer.Id == model.Id) ||
+ (!string.IsNullOrEmpty(model.ImplementerFIO) && implementer.ImplementerFIO == model.ImplementerFIO &&
+ !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 (implementer.Id == model.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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyListImplement/Implements/OrderStorage.cs b/Typography/TypographyListImplement/Implements/OrderStorage.cs
index 1a0e24f..647fb7d 100644
--- a/Typography/TypographyListImplement/Implements/OrderStorage.cs
+++ b/Typography/TypographyListImplement/Implements/OrderStorage.cs
@@ -25,19 +25,27 @@ namespace TypographyListImplement.Implements
private OrderViewModel DefineOthersNames(Order model)
{
OrderViewModel result = model.GetViewModel;
- foreach (var order in _source.Clients)
+ foreach (var client in _source.Clients)
{
- if (result.ClientId == order.Id)
+ if (result.ClientId == client.Id)
{
- result.ClientFIO = order.ClientFIO;
+ result.ClientFIO = client.ClientFIO;
break;
}
}
- foreach (var order in _source.Printeds)
+ foreach (var implementer in _source.Implementers)
{
- if (result.PrintedId == order.Id)
+ if (result.ImplementerId == implementer.Id)
{
- result.PrintedName = order.PrintedName;
+ result.ImplementerFIO = implementer.ImplementerFIO;
+ break;
+ }
+ }
+ foreach (var printed in _source.Printeds)
+ {
+ if (result.PrintedId == printed.Id)
+ {
+ result.PrintedName = printed.PrintedName;
break;
}
}
@@ -46,14 +54,15 @@ namespace TypographyListImplement.Implements
public List GetFilteredList(OrderSearchModel model)
{
var result = new List();
- if ((!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue)
+ if ((!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue && !model.Status.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if ((model.DateFrom.HasValue && model.DateTo.HasValue && order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) ||
- (model.ClientId.HasValue && order.ClientId == model.ClientId))
+ (model.ClientId.HasValue && order.ClientId == model.ClientId) ||
+ (model.Status.HasValue && order.Status == model.Status))
{
result.Add(DefineOthersNames(order));
}
@@ -62,13 +71,14 @@ namespace TypographyListImplement.Implements
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
- if (!model.Id.HasValue)
+ if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
{
return null;
}
foreach (var order in _source.Orders)
{
- if ((model.Id.HasValue && order.Id == model.Id) || (model.ClientId.HasValue && order.ClientId == model.ClientId))
+ if ((model.Id.HasValue && order.Id == model.Id) ||
+ (model.ImplementerId.HasValue && order.Id == model.ImplementerId && order.Status == model.Status))
{
return DefineOthersNames(order);
}
diff --git a/Typography/TypographyListImplement/Models/Implementer.cs b/Typography/TypographyListImplement/Models/Implementer.cs
new file mode 100644
index 0000000..00cd798
--- /dev/null
+++ b/Typography/TypographyListImplement/Models/Implementer.cs
@@ -0,0 +1,49 @@
+using TypographyDataModels.Models;
+using TypographyContracts.BindingModels;
+using TypographyContracts.ViewModels;
+
+namespace TypographyListImplement.Models
+{
+ public class Implementer : IImplementerModel
+ {
+ public int Id { get; private set; }
+ public string ImplementerFIO { get; private set; } = string.Empty;
+ public string Password { get; private set; } = string.Empty;
+ public int WorkExperience { get; private set; }
+ public int Qualification { get; private set; }
+ 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
+ };
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyListImplement/Models/Order.cs b/Typography/TypographyListImplement/Models/Order.cs
index 63a2cb5..d96a572 100644
--- a/Typography/TypographyListImplement/Models/Order.cs
+++ b/Typography/TypographyListImplement/Models/Order.cs
@@ -9,6 +9,7 @@ namespace TypographyListImplement.Models
{
public int Id { get; private set; }
public int ClientId { get; private set; }
+ public int? ImplementerId { get; private set; }
public int PrintedId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
@@ -25,6 +26,7 @@ namespace TypographyListImplement.Models
{
Id = model.Id,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
PrintedId = model.PrintedId,
Count = model.Count,
Sum = model.Sum,
@@ -40,12 +42,14 @@ namespace TypographyListImplement.Models
return;
}
Status = model.Status;
+ ImplementerId = model.ImplementerId;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
ClientId = ClientId,
+ ImplementerId = ImplementerId,
PrintedId = PrintedId,
Count = Count,
Sum = Sum,
diff --git a/Typography/TypographyRestApi/Controllers/ImplementerController.cs b/Typography/TypographyRestApi/Controllers/ImplementerController.cs
new file mode 100644
index 0000000..a4d38c3
--- /dev/null
+++ b/Typography/TypographyRestApi/Controllers/ImplementerController.cs
@@ -0,0 +1,99 @@
+using TypographyDataModels.Enums;
+using TypographyContracts.BindingModels;
+using TypographyContracts.BusinessLogicsContracts;
+using TypographyContracts.SearchModels;
+using TypographyContracts.ViewModels;
+using Microsoft.AspNetCore.Mvc;
+
+namespace TypographyRestApi.Controllers
+{
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ public class ImplementerController : Controller
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _order;
+ private readonly IImplementerLogic _logic;
+ public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger 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? 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;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Typography/TypographyRestApi/Program.cs b/Typography/TypographyRestApi/Program.cs
index f91de6a..ded48e5 100644
--- a/Typography/TypographyRestApi/Program.cs
+++ b/Typography/TypographyRestApi/Program.cs
@@ -13,10 +13,12 @@ builder.Logging.AddLog4Net("log4net.config");
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle