diff --git a/GarmentFactory/FormImplementer.Designer.cs b/GarmentFactory/FormImplementer.Designer.cs
new file mode 100644
index 0000000..d61b6ba
--- /dev/null
+++ b/GarmentFactory/FormImplementer.Designer.cs
@@ -0,0 +1,167 @@
+namespace GarmentFactoryView
+{
+ 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()
+ {
+ this.textBoxFIO = new System.Windows.Forms.TextBox();
+ this.labelFIO = new System.Windows.Forms.Label();
+ this.textBoxPassword = new System.Windows.Forms.TextBox();
+ this.labelPassword = new System.Windows.Forms.Label();
+ this.labelWorkExperience = new System.Windows.Forms.Label();
+ this.numericUpDownWorkExperience = new System.Windows.Forms.NumericUpDown();
+ this.numericUpDownQualification = new System.Windows.Forms.NumericUpDown();
+ this.labelQualification = new System.Windows.Forms.Label();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).BeginInit();
+ this.SuspendLayout();
+ //
+ // textBoxFIO
+ //
+ this.textBoxFIO.Location = new System.Drawing.Point(157, 12);
+ this.textBoxFIO.Name = "textBoxFIO";
+ this.textBoxFIO.Size = new System.Drawing.Size(382, 27);
+ this.textBoxFIO.TabIndex = 3;
+ //
+ // labelFIO
+ //
+ this.labelFIO.AutoSize = true;
+ this.labelFIO.Location = new System.Drawing.Point(12, 15);
+ this.labelFIO.Name = "labelFIO";
+ this.labelFIO.Size = new System.Drawing.Size(139, 20);
+ this.labelFIO.TabIndex = 2;
+ this.labelFIO.Text = "ФИО исполнителя:";
+ //
+ // textBoxPassword
+ //
+ this.textBoxPassword.Location = new System.Drawing.Point(157, 50);
+ this.textBoxPassword.Name = "textBoxPassword";
+ this.textBoxPassword.Size = new System.Drawing.Size(205, 27);
+ this.textBoxPassword.TabIndex = 5;
+ //
+ // labelPassword
+ //
+ this.labelPassword.AutoSize = true;
+ this.labelPassword.Location = new System.Drawing.Point(12, 53);
+ this.labelPassword.Name = "labelPassword";
+ this.labelPassword.Size = new System.Drawing.Size(65, 20);
+ this.labelPassword.TabIndex = 4;
+ this.labelPassword.Text = "Пароль:";
+ //
+ // labelWorkExperience
+ //
+ this.labelWorkExperience.AutoSize = true;
+ this.labelWorkExperience.Location = new System.Drawing.Point(12, 99);
+ this.labelWorkExperience.Name = "labelWorkExperience";
+ this.labelWorkExperience.Size = new System.Drawing.Size(105, 20);
+ this.labelWorkExperience.TabIndex = 6;
+ this.labelWorkExperience.Text = "Опыт работы:";
+ //
+ // numericUpDownWorkExperience
+ //
+ this.numericUpDownWorkExperience.Location = new System.Drawing.Point(157, 97);
+ this.numericUpDownWorkExperience.Name = "numericUpDownWorkExperience";
+ this.numericUpDownWorkExperience.Size = new System.Drawing.Size(124, 27);
+ this.numericUpDownWorkExperience.TabIndex = 8;
+ //
+ // numericUpDownQualification
+ //
+ this.numericUpDownQualification.Location = new System.Drawing.Point(157, 142);
+ this.numericUpDownQualification.Name = "numericUpDownQualification";
+ this.numericUpDownQualification.Size = new System.Drawing.Size(124, 27);
+ this.numericUpDownQualification.TabIndex = 10;
+ //
+ // labelQualification
+ //
+ this.labelQualification.AutoSize = true;
+ this.labelQualification.Location = new System.Drawing.Point(12, 144);
+ this.labelQualification.Name = "labelQualification";
+ this.labelQualification.Size = new System.Drawing.Size(114, 20);
+ this.labelQualification.TabIndex = 9;
+ this.labelQualification.Text = "Квалификация:";
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(422, 203);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(136, 40);
+ this.buttonCancel.TabIndex = 12;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(265, 203);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(130, 40);
+ this.buttonSave.TabIndex = 11;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // FormImplementer
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(570, 255);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.numericUpDownQualification);
+ this.Controls.Add(this.labelQualification);
+ this.Controls.Add(this.numericUpDownWorkExperience);
+ this.Controls.Add(this.labelWorkExperience);
+ this.Controls.Add(this.textBoxPassword);
+ this.Controls.Add(this.labelPassword);
+ this.Controls.Add(this.textBoxFIO);
+ this.Controls.Add(this.labelFIO);
+ this.Name = "FormImplementer";
+ this.Text = "Исполнитель";
+ this.Load += new System.EventHandler(this.FormImplementer_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private TextBox textBoxFIO;
+ private Label labelFIO;
+ private TextBox textBoxPassword;
+ private Label labelPassword;
+ private Label labelWorkExperience;
+ private NumericUpDown numericUpDownWorkExperience;
+ private NumericUpDown numericUpDownQualification;
+ private Label labelQualification;
+ private Button buttonCancel;
+ private Button buttonSave;
+ }
+}
\ No newline at end of file
diff --git a/GarmentFactory/FormImplementer.cs b/GarmentFactory/FormImplementer.cs
new file mode 100644
index 0000000..11f471a
--- /dev/null
+++ b/GarmentFactory/FormImplementer.cs
@@ -0,0 +1,103 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.BusinessLogicsContracts;
+using GarmentFactoryContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace GarmentFactoryView
+{
+ 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;
+ numericUpDownWorkExperience.Value = view.WorkExperience;
+ numericUpDownQualification.Value = view.Qualification;
+ }
+ }
+ 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 = (int)numericUpDownWorkExperience.Value,
+ Qualification = (int)numericUpDownQualification.Value
+ };
+ 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/GarmentFactory/FormImplementer.resx b/GarmentFactory/FormImplementer.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/GarmentFactory/FormImplementer.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/GarmentFactory/FormImplementers.Designer.cs b/GarmentFactory/FormImplementers.Designer.cs
new file mode 100644
index 0000000..24d15a0
--- /dev/null
+++ b/GarmentFactory/FormImplementers.Designer.cs
@@ -0,0 +1,117 @@
+namespace GarmentFactoryView
+{
+ 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()
+ {
+ buttonRefresh = new Button();
+ buttonDelete = new Button();
+ buttonUpdate = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Location = new Point(650, 230);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(126, 36);
+ buttonRefresh.TabIndex = 3;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += buttonRefresh_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(650, 160);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(126, 36);
+ buttonDelete.TabIndex = 2;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(650, 95);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(126, 36);
+ buttonUpdate.TabIndex = 1;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(650, 33);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(126, 36);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(590, 426);
+ dataGridView.TabIndex = 2;
+ //
+ // FormImplementers
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonRefresh);
+ Controls.Add(buttonDelete);
+ Controls.Add(dataGridView);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonAdd);
+ Name = "FormImplementers";
+ Text = "Исполнители";
+ Load += FormImplementers_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+ private Button buttonRefresh;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/GarmentFactory/FormImplementers.cs b/GarmentFactory/FormImplementers.cs
new file mode 100644
index 0000000..9c8d008
--- /dev/null
+++ b/GarmentFactory/FormImplementers.cs
@@ -0,0 +1,118 @@
+using GarmentFactory;
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace GarmentFactoryView
+{
+ public partial class FormImplementers : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IImplementerLogic _logic;
+
+ public FormImplementers(ILogger logger, IImplementerLogic implementerLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = implementerLogic;
+ }
+
+ 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;
+ }
+ _logger.LogInformation("Загрузка исполнителей");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки исполнителей");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormImplementers_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ 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 buttonUpdate_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 buttonDelete_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 buttonRefresh_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/GarmentFactory/FormImplementers.resx b/GarmentFactory/FormImplementers.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/GarmentFactory/FormImplementers.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/GarmentFactory/FormMain.Designer.cs b/GarmentFactory/FormMain.Designer.cs
index 33a8a6d..7e121da 100644
--- a/GarmentFactory/FormMain.Designer.cs
+++ b/GarmentFactory/FormMain.Designer.cs
@@ -1,228 +1,246 @@
namespace GarmentFactoryView
{
- partial class FormMain
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
+ partial class FormMain
+ {
+ ///
+ /// 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);
- }
+ ///
+ /// 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
+ #region Windows Form Designer generated code
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- dataGridView = new DataGridView();
- buttonCreateOrder = new Button();
- buttonTakeOrderInWork = new Button();
- buttonOrderReady = new Button();
- buttonCompletedOrder = new Button();
- buttonRefresh = new Button();
- menuStrip1 = new MenuStrip();
- справочникиToolStripMenuItem = new ToolStripMenuItem();
- компонентыToolStripMenuItem = new ToolStripMenuItem();
- текстилиToolStripMenuItem = new ToolStripMenuItem();
- клиентыToolStripMenuItem = new ToolStripMenuItem();
- отчётыToolStripMenuItem = new ToolStripMenuItem();
- textilesToolStripMenuItem = new ToolStripMenuItem();
- textileComponentsToolStripMenuItem = new ToolStripMenuItem();
- ordersToolStripMenuItem = new ToolStripMenuItem();
- ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
- menuStrip1.SuspendLayout();
- SuspendLayout();
- //
- // dataGridView
- //
- dataGridView.AllowUserToAddRows = false;
- dataGridView.AllowUserToDeleteRows = false;
- dataGridView.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- dataGridView.Location = new Point(0, 31);
- dataGridView.Name = "dataGridView";
- dataGridView.ReadOnly = true;
- dataGridView.RowHeadersVisible = false;
- dataGridView.RowHeadersWidth = 51;
- dataGridView.RowTemplate.Height = 29;
- dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- dataGridView.Size = new Size(1112, 425);
- dataGridView.TabIndex = 0;
- //
- // buttonCreateOrder
- //
- buttonCreateOrder.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonCreateOrder.Location = new Point(1165, 79);
- buttonCreateOrder.Name = "buttonCreateOrder";
- buttonCreateOrder.Size = new Size(180, 40);
- buttonCreateOrder.TabIndex = 1;
- buttonCreateOrder.Text = "Создать заказ";
- buttonCreateOrder.UseVisualStyleBackColor = true;
- buttonCreateOrder.Click += ButtonCreateOrder_Click;
- //
- // buttonTakeOrderInWork
- //
- buttonTakeOrderInWork.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonTakeOrderInWork.Location = new Point(1165, 146);
- buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
- buttonTakeOrderInWork.Size = new Size(180, 40);
- buttonTakeOrderInWork.TabIndex = 2;
- buttonTakeOrderInWork.Text = "Отдать на выполнение";
- buttonTakeOrderInWork.UseVisualStyleBackColor = true;
- buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
- //
- // buttonOrderReady
- //
- buttonOrderReady.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonOrderReady.Location = new Point(1165, 216);
- buttonOrderReady.Name = "buttonOrderReady";
- buttonOrderReady.Size = new Size(180, 40);
- buttonOrderReady.TabIndex = 3;
- buttonOrderReady.Text = "Заказ готов";
- buttonOrderReady.UseVisualStyleBackColor = true;
- buttonOrderReady.Click += ButtonOrderReady_Click;
- //
- // buttonCompletedOrder
- //
- buttonCompletedOrder.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonCompletedOrder.Location = new Point(1165, 284);
- buttonCompletedOrder.Name = "buttonCompletedOrder";
- buttonCompletedOrder.Size = new Size(180, 40);
- buttonCompletedOrder.TabIndex = 4;
- buttonCompletedOrder.Text = "Заказ выдан";
- buttonCompletedOrder.UseVisualStyleBackColor = true;
- buttonCompletedOrder.Click += ButtonCompletedOrder_Click;
- //
- // buttonRefresh
- //
- buttonRefresh.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonRefresh.Location = new Point(1165, 362);
- buttonRefresh.Name = "buttonRefresh";
- buttonRefresh.Size = new Size(180, 40);
- buttonRefresh.TabIndex = 5;
- buttonRefresh.Text = "Обновить список";
- buttonRefresh.UseVisualStyleBackColor = true;
- buttonRefresh.Click += ButtonRefresh_Click;
- //
- // menuStrip1
- //
- menuStrip1.ImageScalingSize = new Size(20, 20);
- menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem });
- menuStrip1.Location = new Point(0, 0);
- menuStrip1.Name = "menuStrip1";
- menuStrip1.Size = new Size(1380, 28);
- menuStrip1.TabIndex = 7;
- menuStrip1.Text = "menuStrip1";
- //
- // справочникиToolStripMenuItem
- //
- справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, текстилиToolStripMenuItem, клиентыToolStripMenuItem });
- справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
- справочникиToolStripMenuItem.Size = new Size(117, 24);
- справочникиToolStripMenuItem.Text = "Справочники";
- //
- // компонентыToolStripMenuItem
- //
- компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- компонентыToolStripMenuItem.Size = new Size(224, 26);
- компонентыToolStripMenuItem.Text = "Компоненты";
- компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
- //
- // текстилиToolStripMenuItem
- //
- текстилиToolStripMenuItem.Name = "текстилиToolStripMenuItem";
- текстилиToolStripMenuItem.Size = new Size(224, 26);
- текстилиToolStripMenuItem.Text = "Текстили";
- текстилиToolStripMenuItem.Click += текстилиToolStripMenuItem_Click;
- //
- // клиентыToolStripMenuItem
- //
- клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
- клиентыToolStripMenuItem.Size = new Size(224, 26);
- клиентыToolStripMenuItem.Text = "Клиенты";
- клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
- //
- // отчётыToolStripMenuItem
- //
- отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem });
- отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
- отчётыToolStripMenuItem.Size = new Size(73, 24);
- отчётыToolStripMenuItem.Text = "Отчёты";
- //
- // textilesToolStripMenuItem
- //
- textilesToolStripMenuItem.Name = "textilesToolStripMenuItem";
- textilesToolStripMenuItem.Size = new Size(274, 26);
- textilesToolStripMenuItem.Text = "Текстили";
- textilesToolStripMenuItem.Click += TextilesToolStripMenuItem_Click;
- //
- // textileComponentsToolStripMenuItem
- //
- textileComponentsToolStripMenuItem.Name = "textileComponentsToolStripMenuItem";
- textileComponentsToolStripMenuItem.Size = new Size(274, 26);
- textileComponentsToolStripMenuItem.Text = "Текстили с компонентами";
- textileComponentsToolStripMenuItem.Click += ComponentTextilesToolStripMenuItem_Click;
- //
- // ordersToolStripMenuItem
- //
- ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
- ordersToolStripMenuItem.Size = new Size(274, 26);
- ordersToolStripMenuItem.Text = "Заказы";
- ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
- //
- // FormMain
- //
- AutoScaleDimensions = new SizeF(8F, 20F);
- AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(1380, 453);
- Controls.Add(menuStrip1);
- Controls.Add(buttonRefresh);
- Controls.Add(buttonCompletedOrder);
- Controls.Add(buttonOrderReady);
- Controls.Add(buttonTakeOrderInWork);
- Controls.Add(buttonCreateOrder);
- Controls.Add(dataGridView);
- MainMenuStrip = menuStrip1;
- Name = "FormMain";
- Text = "Швейная фабрика";
- Load += FormMain_Load;
- ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
- menuStrip1.ResumeLayout(false);
- menuStrip1.PerformLayout();
- ResumeLayout(false);
- PerformLayout();
- }
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonCompletedOrder = new Button();
+ buttonRefresh = new Button();
+ menuStrip1 = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ компонентыToolStripMenuItem = new ToolStripMenuItem();
+ текстилиToolStripMenuItem = new ToolStripMenuItem();
+ клиентыToolStripMenuItem = new ToolStripMenuItem();
+ исполнителиToolStripMenuItem = new ToolStripMenuItem();
+ отчётыToolStripMenuItem = new ToolStripMenuItem();
+ textilesToolStripMenuItem = new ToolStripMenuItem();
+ textileComponentsToolStripMenuItem = new ToolStripMenuItem();
+ ordersToolStripMenuItem = new ToolStripMenuItem();
+ запускРаботToolStripMenuItem = new ToolStripMenuItem();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ menuStrip1.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 31);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(1277, 425);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
+ buttonCreateOrder.Location = new Point(1325, 81);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(180, 40);
+ buttonCreateOrder.TabIndex = 1;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += ButtonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
+ buttonTakeOrderInWork.Location = new Point(1325, 148);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(180, 40);
+ buttonTakeOrderInWork.TabIndex = 2;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
+ buttonOrderReady.Location = new Point(1325, 218);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(180, 40);
+ buttonOrderReady.TabIndex = 3;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += ButtonOrderReady_Click;
+ //
+ // buttonCompletedOrder
+ //
+ buttonCompletedOrder.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
+ buttonCompletedOrder.Location = new Point(1325, 286);
+ buttonCompletedOrder.Name = "buttonCompletedOrder";
+ buttonCompletedOrder.Size = new Size(180, 40);
+ buttonCompletedOrder.TabIndex = 4;
+ buttonCompletedOrder.Text = "Заказ выдан";
+ buttonCompletedOrder.UseVisualStyleBackColor = true;
+ buttonCompletedOrder.Click += ButtonCompletedOrder_Click;
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
+ buttonRefresh.Location = new Point(1325, 364);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(180, 40);
+ buttonRefresh.TabIndex = 5;
+ buttonRefresh.Text = "Обновить список";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // menuStrip1
+ //
+ menuStrip1.ImageScalingSize = new Size(20, 20);
+ menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem, запускРаботToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Size = new Size(1547, 28);
+ menuStrip1.TabIndex = 7;
+ menuStrip1.Text = "menuStrip1";
+ //
+ // справочникиToolStripMenuItem
+ //
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, текстилиToolStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem });
+ справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ справочникиToolStripMenuItem.Size = new Size(117, 24);
+ справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // компонентыToolStripMenuItem
+ //
+ компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ компонентыToolStripMenuItem.Size = new Size(185, 26);
+ компонентыToolStripMenuItem.Text = "Компоненты";
+ компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
+ //
+ // текстилиToolStripMenuItem
+ //
+ текстилиToolStripMenuItem.Name = "текстилиToolStripMenuItem";
+ текстилиToolStripMenuItem.Size = new Size(185, 26);
+ текстилиToolStripMenuItem.Text = "Текстили";
+ текстилиToolStripMenuItem.Click += текстилиToolStripMenuItem_Click;
+ //
+ // клиентыToolStripMenuItem
+ //
+ клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
+ клиентыToolStripMenuItem.Size = new Size(185, 26);
+ клиентыToolStripMenuItem.Text = "Клиенты";
+ клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
+ //
+ // исполнителиToolStripMenuItem
+ //
+ исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
+ исполнителиToolStripMenuItem.Size = new Size(185, 26);
+ исполнителиToolStripMenuItem.Text = "Исполнители";
+ исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
+ //
+ // отчётыToolStripMenuItem
+ //
+ отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem });
+ отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
+ отчётыToolStripMenuItem.Size = new Size(73, 24);
+ отчётыToolStripMenuItem.Text = "Отчёты";
+ //
+ // textilesToolStripMenuItem
+ //
+ textilesToolStripMenuItem.Name = "textilesToolStripMenuItem";
+ textilesToolStripMenuItem.Size = new Size(274, 26);
+ textilesToolStripMenuItem.Text = "Текстили";
+ textilesToolStripMenuItem.Click += TextilesToolStripMenuItem_Click;
+ //
+ // textileComponentsToolStripMenuItem
+ //
+ textileComponentsToolStripMenuItem.Name = "textileComponentsToolStripMenuItem";
+ textileComponentsToolStripMenuItem.Size = new Size(274, 26);
+ textileComponentsToolStripMenuItem.Text = "Текстили с компонентами";
+ textileComponentsToolStripMenuItem.Click += ComponentTextilesToolStripMenuItem_Click;
+ //
+ // ordersToolStripMenuItem
+ //
+ ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
+ ordersToolStripMenuItem.Size = new Size(274, 26);
+ ordersToolStripMenuItem.Text = "Заказы";
+ ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
+ //
+ // запускРаботToolStripMenuItem
+ //
+ запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
+ запускРаботToolStripMenuItem.Size = new Size(114, 24);
+ запускРаботToolStripMenuItem.Text = "Запуск работ";
+ запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1547, 453);
+ Controls.Add(menuStrip1);
+ Controls.Add(buttonRefresh);
+ Controls.Add(buttonCompletedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ MainMenuStrip = menuStrip1;
+ Name = "FormMain";
+ Text = "Швейная фабрика";
+ Load += FormMain_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
- #endregion
+ #endregion
- private DataGridView dataGridView;
- private Button buttonCreateOrder;
- private Button buttonTakeOrderInWork;
- private Button buttonOrderReady;
- private Button buttonCompletedOrder;
- private Button buttonRefresh;
- private MenuStrip menuStrip1;
- private ToolStripMenuItem справочникиToolStripMenuItem;
- private ToolStripMenuItem компонентыToolStripMenuItem;
- private ToolStripMenuItem текстилиToolStripMenuItem;
- private ToolStripMenuItem отчётыToolStripMenuItem;
- private ToolStripMenuItem textilesToolStripMenuItem;
- private ToolStripMenuItem textileComponentsToolStripMenuItem;
- private ToolStripMenuItem ordersToolStripMenuItem;
- private ToolStripMenuItem клиентыToolStripMenuItem;
- }
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonCompletedOrder;
+ private Button buttonRefresh;
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem текстилиToolStripMenuItem;
+ private ToolStripMenuItem отчётыToolStripMenuItem;
+ private ToolStripMenuItem textilesToolStripMenuItem;
+ private ToolStripMenuItem textileComponentsToolStripMenuItem;
+ private ToolStripMenuItem ordersToolStripMenuItem;
+ private ToolStripMenuItem клиентыToolStripMenuItem;
+ private ToolStripMenuItem исполнителиToolStripMenuItem;
+ private ToolStripMenuItem запускРаботToolStripMenuItem;
+ }
}
\ No newline at end of file
diff --git a/GarmentFactory/FormMain.cs b/GarmentFactory/FormMain.cs
index 0293a53..d84801d 100644
--- a/GarmentFactory/FormMain.cs
+++ b/GarmentFactory/FormMain.cs
@@ -15,182 +15,201 @@ using System.Windows.Forms;
namespace GarmentFactoryView
{
- public partial class FormMain : Form
- {
- private readonly ILogger _logger;
- private readonly IOrderLogic _orderLogic;
- private readonly IReportLogic _reportLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic)
- {
- InitializeComponent();
- _logger = logger;
- _orderLogic = orderLogic;
- _reportLogic = reportLogic;
- }
- private void LoadData()
- {
- _logger.LogInformation("Загрузка заказов");
- try
- {
- var list = _orderLogic.ReadList(null);
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["TextileId"].Visible = false;
- dataGridView.Columns["ClientId"].Visible = false;
- dataGridView.Columns["TextileName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
- dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation("Загрузка заказов");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки заказов");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void FormMain_Load(object sender, EventArgs e)
- {
- LoadData();
- }
+ public partial class FormMain : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+ private readonly 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()
+ {
+ _logger.LogInformation("Загрузка заказов");
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["TextileId"].Visible = false;
+ dataGridView.Columns["ClientId"].Visible = false;
+ dataGridView.Columns["ImplementerId"].Visible = false;
+ dataGridView.Columns["TextileName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка заказов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
- private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
- if (service is FormComponents form)
- {
- form.ShowDialog();
- }
+ private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
- }
+ }
- private void текстилиToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormTextiles));
- if (service is FormTextiles form)
- {
- form.ShowDialog();
- }
- }
+ private void текстилиToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormTextiles));
+ if (service is FormTextiles form)
+ {
+ form.ShowDialog();
+ }
+ }
- private void TextilesToolStripMenuItem_Click(object sender, EventArgs e)
- {
- using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- _reportLogic.SaveTextilesToWordFile(new ReportBindingModel
- {
- FileName = dialog.FileName
- });
- MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private void ComponentTextilesToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormReportTextileComponents));
- if (service is FormReportTextileComponents form)
- {
- form.ShowDialog();
- }
- }
- private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
- if (service is FormReportOrders form)
- {
- form.ShowDialog();
- }
- }
+ private void TextilesToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ _reportLogic.SaveTextilesToWordFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName
+ });
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+ private void ComponentTextilesToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportTextileComponents));
+ if (service is FormReportTextileComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
+ if (service is FormReportOrders form)
+ {
+ form.ShowDialog();
+ }
+ }
- private void ButtonCreateOrder_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
- if (service is FormCreateOrder form)
- {
- form.ShowDialog();
- LoadData();
- }
- }
- private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridView.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 (dataGridView.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridView.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 ButtonCompletedOrder_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
- try
- {
- var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- _logger.LogInformation("Заказ №{id} выдан", id);
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonRefresh_Click(object sender, EventArgs e)
- {
- LoadData();
- }
+ private void ButtonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+ private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.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 (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.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 ButtonCompletedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonRefresh_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
- private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormClients));
- if (service is FormClients form)
- {
- form.ShowDialog();
- }
- }
- }
+ private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormClients));
+ if (service is FormClients form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
+ if (service is FormImplementers form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
+ MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
}
diff --git a/GarmentFactory/Program.cs b/GarmentFactory/Program.cs
index 9ef1d09..72f878e 100644
--- a/GarmentFactory/Program.cs
+++ b/GarmentFactory/Program.cs
@@ -37,18 +37,21 @@ namespace GarmentFactory
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
- 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();
+ services.AddTransient();
- services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -62,6 +65,8 @@ namespace GarmentFactory
services.AddTransient();
services.AddTransient();
services.AddTransient();
- }
+ services.AddTransient();
+ services.AddTransient();
+ }
}
}
\ No newline at end of file
diff --git a/GarmentFactoryBusinessLogic/BusinessLogics/ImplementerLogic.cs b/GarmentFactoryBusinessLogic/BusinessLogics/ImplementerLogic.cs
new file mode 100644
index 0000000..e914bef
--- /dev/null
+++ b/GarmentFactoryBusinessLogic/BusinessLogics/ImplementerLogic.cs
@@ -0,0 +1,128 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.BusinessLogicsContracts;
+using GarmentFactoryContracts.SearchModels;
+using GarmentFactoryContracts.StoragesContracts;
+using GarmentFactoryContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryBusinessLogic.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. ImplementerFIO:{ImplementerFIO}.Password:{Password}.Id:{ Id}", model?.ImplementerFIO, model?.Password?.Length, 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}.Password:{Password}.Id:{ Id}", model?.ImplementerFIO, model?.Password?.Length, 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 ArgumentNullException("Квалификация должна быть положительной", 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("Исполнитель с таким ФИО уже есть");
+ }
+ }
+ }
+}
diff --git a/GarmentFactoryBusinessLogic/BusinessLogics/OrderLogic.cs b/GarmentFactoryBusinessLogic/BusinessLogics/OrderLogic.cs
index d889937..797b110 100644
--- a/GarmentFactoryBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/GarmentFactoryBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -19,17 +19,36 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
private readonly ILogger _logger;
//Хранение всех заказов
private readonly IOrderStorage _orderStorage;
- public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ static readonly object _locker = new object();
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
{
_logger = logger;
_orderStorage = orderStorage;
}
- //Чтение всего списка заказов
- public List? ReadList(OrderSearchModel? model)
+ public OrderViewModel? ReadElement(OrderSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ _logger.LogInformation("ReadElement. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}", model.ClientId, model.Status, model.ImplementerId, 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. OrderId:{Id}", model?.Id);
- var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+ _logger.LogInformation("ReadList. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",model?.ClientId, model?.Status, model?.ImplementerId, model?.DateFrom, model?.DateTo, model?.Id);
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
@@ -97,10 +116,15 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
model.Status = order.Status;
model.Count = order.Count;
model.Sum = order.Sum;
- if (newStatus - model.Status == 1)
+ model.ClientId = order.ClientId;
+ if (!model.ImplementerId.HasValue)
+ {
+ model.ImplementerId = order.ImplementerId;
+ }
+ if (newStatus - model.Status == 1)
{
model.Status = newStatus;
- if (model.Status == OrderStatus.Выдан)
+ if (model.Status == OrderStatus.Готов)
{
model.DateComplete = DateTime.Now;
}
@@ -123,8 +147,12 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
//Перевод заказа в состояние выполнения
public bool TakeOrderInWork(OrderBindingModel model)
{
- return ChangeStatus(model, OrderStatus.Выполняется);
- }
+ lock (_locker)
+ {
+ return ChangeStatus(model, OrderStatus.Выполняется);
+ }
+ }
+
//Перевод заказа в состояние готовности
public bool FinishOrder(OrderBindingModel model)
{
diff --git a/GarmentFactoryBusinessLogic/BusinessLogics/WorkModeling.cs b/GarmentFactoryBusinessLogic/BusinessLogics/WorkModeling.cs
new file mode 100644
index 0000000..339a160
--- /dev/null
+++ b/GarmentFactoryBusinessLogic/BusinessLogics/WorkModeling.cs
@@ -0,0 +1,145 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.BusinessLogicsContracts;
+using GarmentFactoryContracts.SearchModels;
+using GarmentFactoryContracts.ViewModels;
+using GarmentFactoryDataModels.Enums;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryBusinessLogic.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.Принят });
+ var processingOrders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Выполняется });
+ if (orders == null || processingOrders == null || (orders.Count == 0 && processingOrders.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);
+ // пытаемся назначить заказ на исполнителя
+ bool result = _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = order.Id,
+ ImplementerId = implementer.Id
+ });
+ if (!result)
+ {
+ _logger.LogDebug("WorkerWorkAsync. Worker {Id} tried to get order {Order} but it's already acquired by other worker", implementer.Id, order.Id);
+ continue;
+ }
+ // делаем работу
+ 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
+ });
+ }
+ // кто-то мог уже перехватить заказ, игнорируем ошибку
+ catch (InvalidOperationException ex)
+ {
+ _logger.LogWarning(ex, "Error try get work");
+ }
+ // заканчиваем выполнение имитации в случае иной ошибки
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while do work");
+ throw;
+ }
+ // отдыхаем
+ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
+ }
+ });
+ }
+
+ 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/GarmentFactoryContracts/BindingModels/ImplementerBindingModel.cs b/GarmentFactoryContracts/BindingModels/ImplementerBindingModel.cs
new file mode 100644
index 0000000..8e79ae0
--- /dev/null
+++ b/GarmentFactoryContracts/BindingModels/ImplementerBindingModel.cs
@@ -0,0 +1,18 @@
+using GarmentFactoryDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryContracts.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; }
+ }
+}
diff --git a/GarmentFactoryContracts/BindingModels/OrderBindingModel.cs b/GarmentFactoryContracts/BindingModels/OrderBindingModel.cs
index 54adf6e..0d6635b 100644
--- a/GarmentFactoryContracts/BindingModels/OrderBindingModel.cs
+++ b/GarmentFactoryContracts/BindingModels/OrderBindingModel.cs
@@ -13,7 +13,8 @@ namespace GarmentFactoryContracts.BindingModels
public int Id { get; set; }
public int ClientId { get; set; }
public int TextileId { get; set; }
- public int Count { get; set; }
+ public int? ImplementerId { get; set; }
+ public int Count { get; set; }
public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; set; } = DateTime.Now;
diff --git a/GarmentFactoryContracts/BusinessLogicsContracts/IImplementerLogic.cs b/GarmentFactoryContracts/BusinessLogicsContracts/IImplementerLogic.cs
new file mode 100644
index 0000000..a126550
--- /dev/null
+++ b/GarmentFactoryContracts/BusinessLogicsContracts/IImplementerLogic.cs
@@ -0,0 +1,20 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.SearchModels;
+using GarmentFactoryContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryContracts.BusinessLogicsContracts
+{
+ public interface IImplementerLogic
+ {
+ List? ReadList(ImplementerSearchModel? model);
+ ImplementerViewModel? ReadElement(ImplementerSearchModel model);
+ bool Create(ImplementerBindingModel model);
+ bool Update(ImplementerBindingModel model);
+ bool Delete(ImplementerBindingModel model);
+ }
+}
diff --git a/GarmentFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs b/GarmentFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs
index f735303..89fbbd1 100644
--- a/GarmentFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs
+++ b/GarmentFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -12,9 +12,10 @@ namespace GarmentFactoryContracts.BusinessLogicsContracts
public interface IOrderLogic
{
List? ReadList(OrderSearchModel? model);
- bool CreateOrder(OrderBindingModel model);
+ OrderViewModel? ReadElement(OrderSearchModel model);
+ bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
- }
+ }
}
diff --git a/GarmentFactoryContracts/BusinessLogicsContracts/IWorkProcess.cs b/GarmentFactoryContracts/BusinessLogicsContracts/IWorkProcess.cs
new file mode 100644
index 0000000..cc33985
--- /dev/null
+++ b/GarmentFactoryContracts/BusinessLogicsContracts/IWorkProcess.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryContracts.BusinessLogicsContracts
+{
+ public interface IWorkProcess
+ {
+ void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
+ }
+}
diff --git a/GarmentFactoryContracts/SearchModels/ImplementerSearchModel.cs b/GarmentFactoryContracts/SearchModels/ImplementerSearchModel.cs
new file mode 100644
index 0000000..6544c97
--- /dev/null
+++ b/GarmentFactoryContracts/SearchModels/ImplementerSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryContracts.SearchModels
+{
+ public class ImplementerSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ImplementerFIO { get; set; }
+ public string? Password { get; set; }
+ }
+}
diff --git a/GarmentFactoryContracts/SearchModels/OrderSearchModel.cs b/GarmentFactoryContracts/SearchModels/OrderSearchModel.cs
index c75fd0d..89501b6 100644
--- a/GarmentFactoryContracts/SearchModels/OrderSearchModel.cs
+++ b/GarmentFactoryContracts/SearchModels/OrderSearchModel.cs
@@ -1,4 +1,5 @@
-using System;
+using GarmentFactoryDataModels.Enums;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -10,7 +11,9 @@ namespace GarmentFactoryContracts.SearchModels
{
public int? Id { get; set; }
public int? ClientId { get; set; }
- public DateTime? DateFrom { 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/GarmentFactoryContracts/StoragesContracts/IImplementerStorage.cs b/GarmentFactoryContracts/StoragesContracts/IImplementerStorage.cs
new file mode 100644
index 0000000..6e77889
--- /dev/null
+++ b/GarmentFactoryContracts/StoragesContracts/IImplementerStorage.cs
@@ -0,0 +1,21 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.SearchModels;
+using GarmentFactoryContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryContracts.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);
+ }
+}
diff --git a/GarmentFactoryContracts/ViewModels/ImplementerViewModel.cs b/GarmentFactoryContracts/ViewModels/ImplementerViewModel.cs
new file mode 100644
index 0000000..8fa8a07
--- /dev/null
+++ b/GarmentFactoryContracts/ViewModels/ImplementerViewModel.cs
@@ -0,0 +1,27 @@
+using GarmentFactoryDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryContracts.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; }
+ }
+}
diff --git a/GarmentFactoryContracts/ViewModels/OrderViewModel.cs b/GarmentFactoryContracts/ViewModels/OrderViewModel.cs
index fd87747..51706a3 100644
--- a/GarmentFactoryContracts/ViewModels/OrderViewModel.cs
+++ b/GarmentFactoryContracts/ViewModels/OrderViewModel.cs
@@ -19,7 +19,11 @@ namespace GarmentFactoryContracts.ViewModels
[DisplayName("Клиент")]
public string ClientFIO { get; set; } = string.Empty;
- public int TextileId { get; set; }
+ public int? ImplementerId { get; set; }
+ [DisplayName("Исполнитель")]
+ public string? ImplementerFIO { get; set; } = null;
+
+ public int TextileId { get; set; }
[DisplayName("Текстиль")]
public string TextileName { get; set; } = string.Empty;
diff --git a/GarmentFactoryDataModels/Models/IImplementerModel.cs b/GarmentFactoryDataModels/Models/IImplementerModel.cs
new file mode 100644
index 0000000..a04ee60
--- /dev/null
+++ b/GarmentFactoryDataModels/Models/IImplementerModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryDataModels.Models
+{
+ // Исполнитель (рабочий)
+ public interface IImplementerModel : IId
+ {
+ string ImplementerFIO { get; }
+
+ string Password { get; }
+
+ //Стаж работы
+ int WorkExperience { get; }
+
+ int Qualification { get; }
+ }
+}
diff --git a/GarmentFactoryDataModels/Models/IOrderModel.cs b/GarmentFactoryDataModels/Models/IOrderModel.cs
index 82fdf66..21e05e9 100644
--- a/GarmentFactoryDataModels/Models/IOrderModel.cs
+++ b/GarmentFactoryDataModels/Models/IOrderModel.cs
@@ -11,7 +11,8 @@ namespace GarmentFactoryDataModels.Models
{
int TextileId { get; }
int ClientId { get; }
- int Count { get; }
+ int? ImplementerId { get; }
+ int Count { get; }
double Sum { get; }
OrderStatus Status { get; }
DateTime DateCreate { get; }
diff --git a/GarmentFactoryDatabaseImplement/GarmentFactoryDatabase.cs b/GarmentFactoryDatabaseImplement/GarmentFactoryDatabase.cs
index 5569c31..79b772c 100644
--- a/GarmentFactoryDatabaseImplement/GarmentFactoryDatabase.cs
+++ b/GarmentFactoryDatabaseImplement/GarmentFactoryDatabase.cs
@@ -29,5 +29,7 @@ namespace GarmentFactoryDatabaseImplement
public virtual DbSet Orders { set; get; }
public virtual DbSet Clients { set; get; }
- }
+
+ public virtual DbSet Implementers { set; get; }
+ }
}
diff --git a/GarmentFactoryDatabaseImplement/Implements/ImplementerStorage.cs b/GarmentFactoryDatabaseImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..8c53a47
--- /dev/null
+++ b/GarmentFactoryDatabaseImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,84 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.SearchModels;
+using GarmentFactoryContracts.StoragesContracts;
+using GarmentFactoryContracts.ViewModels;
+using GarmentFactoryDatabaseImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryDatabaseImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new GarmentFactoryDatabase();
+ return context.Implementers.Select(x => x.GetViewModel).ToList();
+ }
+
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ return new();
+ }
+ using var context = new GarmentFactoryDatabase();
+ return context.Implementers.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO)).Select(x => x.GetViewModel).ToList();
+ }
+
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ using var context = new GarmentFactoryDatabase();
+ return context.Implementers.FirstOrDefault(x =>
+ (!string.IsNullOrEmpty(model.ImplementerFIO) && x.ImplementerFIO == model.ImplementerFIO && (!string.IsNullOrEmpty(model.Password) ? x.Password == model.Password : true)) ||
+ (model.Id.HasValue && x.Id == model.Id))
+ ?.GetViewModel;
+ }
+
+ public ImplementerViewModel? Insert(ImplementerBindingModel model)
+ {
+ var newImplementer = Implementer.Create(model);
+ if (newImplementer == null)
+ {
+ return null;
+ }
+ using var context = new GarmentFactoryDatabase();
+ context.Implementers.Add(newImplementer);
+ context.SaveChanges();
+ return newImplementer.GetViewModel;
+ }
+
+ public ImplementerViewModel? Update(ImplementerBindingModel model)
+ {
+ using var context = new GarmentFactoryDatabase();
+ 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 GarmentFactoryDatabase();
+ var implementer = context.Implementers.FirstOrDefault(rec => rec.Id == model.Id);
+ if (implementer != null)
+ {
+ context.Implementers.Remove(implementer);
+ context.SaveChanges();
+ return implementer.GetViewModel;
+ }
+ return null;
+ }
+ }
+}
diff --git a/GarmentFactoryDatabaseImplement/Implements/OrderStorage.cs b/GarmentFactoryDatabaseImplement/Implements/OrderStorage.cs
index 0affc07..1ce14b8 100644
--- a/GarmentFactoryDatabaseImplement/Implements/OrderStorage.cs
+++ b/GarmentFactoryDatabaseImplement/Implements/OrderStorage.cs
@@ -21,7 +21,8 @@ namespace GarmentFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Textile)
.Include(x => x.Client)
- .Select(x => x.GetViewModel)
+ .Include(x => x.Implementer)
+ .Select(x => x.GetViewModel)
.ToList();
}
@@ -33,6 +34,7 @@ namespace GarmentFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Textile)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
@@ -43,7 +45,8 @@ namespace GarmentFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Textile)
.Include(x => x.Client)
- .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
+ .Include(x => x.Implementer)
+ .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
@@ -53,17 +56,39 @@ namespace GarmentFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Textile)
.Include(x => x.Client)
- .Where(x => x.ClientId == model.ClientId)
+ .Include(x => x.Implementer)
+ .Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
+ else if (model.ImplementerId.HasValue)
+ {
+ return context.Orders
+ .Include(x => x.Textile)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .Where(x => x.ImplementerId == model.ImplementerId)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+
+ else if (model.Status.HasValue)
+ {
+ return context.Orders
+ .Include(x => x.Textile)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .Where(x => x.Status == model.Status)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
return new();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
- if (!model.Id.HasValue)
+ if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
{
return null;
}
@@ -73,7 +98,10 @@ namespace GarmentFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Textile)
.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 && x.ImplementerId == model.ImplementerId && x.Status == model.Status))
+ ?.GetViewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)
@@ -92,6 +120,7 @@ namespace GarmentFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Textile)
.Include(x => x.Client)
+ .Include (x => x.Implementer)
.FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
}
@@ -111,7 +140,8 @@ namespace GarmentFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Textile)
.Include(x => x.Client)
- .FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
+ .Include(x => x.Implementer)
+ .FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public OrderViewModel? Delete(OrderBindingModel model)
@@ -121,7 +151,7 @@ namespace GarmentFactoryDatabaseImplement.Implements
if (element != null)
{
- var delElement = context.Orders.Include(x => x.Textile).Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
+ var delElement = context.Orders.Include(x => x.Textile).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
context.Orders.Remove(element);
context.SaveChanges();
return delElement;
diff --git a/GarmentFactoryDatabaseImplement/Migrations/20240416171656_AddedImplementer.Designer.cs b/GarmentFactoryDatabaseImplement/Migrations/20240416171656_AddedImplementer.Designer.cs
new file mode 100644
index 0000000..6a37041
--- /dev/null
+++ b/GarmentFactoryDatabaseImplement/Migrations/20240416171656_AddedImplementer.Designer.cs
@@ -0,0 +1,257 @@
+//
+using System;
+using GarmentFactoryDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace GarmentFactoryDatabaseImplement.Migrations
+{
+ [DbContext(typeof(GarmentFactoryDatabase))]
+ [Migration("20240416171656_AddedImplementer")]
+ partial class AddedImplementer
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.17")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClientFIO")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Clients");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Cost")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.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("GarmentFactoryDatabaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClientId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("DateComplete")
+ .HasColumnType("datetime2");
+
+ b.Property("DateCreate")
+ .HasColumnType("datetime2");
+
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("Sum")
+ .HasColumnType("float");
+
+ b.Property("TextileId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("ImplementerId");
+
+ b.HasIndex("TextileId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Price")
+ .HasColumnType("float");
+
+ b.Property("TextileName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Textiles");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.TextileComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ComponentId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("TextileId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComponentId");
+
+ b.HasIndex("TextileId");
+
+ b.ToTable("TextileComponents");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Client", "Client")
+ .WithMany("Orders")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Order")
+ .HasForeignKey("ImplementerId");
+
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
+ .WithMany("Orders")
+ .HasForeignKey("TextileId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Client");
+
+ b.Navigation("Implementer");
+
+ b.Navigation("Textile");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.TextileComponent", b =>
+ {
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Component", "Component")
+ .WithMany("TextileComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
+ .WithMany("Components")
+ .HasForeignKey("TextileId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Textile");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Client", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Component", b =>
+ {
+ b.Navigation("TextileComponents");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Order");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/GarmentFactoryDatabaseImplement/Migrations/20240416171656_AddedImplementer.cs b/GarmentFactoryDatabaseImplement/Migrations/20240416171656_AddedImplementer.cs
new file mode 100644
index 0000000..cb95612
--- /dev/null
+++ b/GarmentFactoryDatabaseImplement/Migrations/20240416171656_AddedImplementer.cs
@@ -0,0 +1,67 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace GarmentFactoryDatabaseImplement.Migrations
+{
+ ///
+ public partial class AddedImplementer : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "ImplementerId",
+ table: "Orders",
+ type: "int",
+ nullable: true);
+
+ 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.CreateIndex(
+ name: "IX_Orders_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId",
+ principalTable: "Implementers",
+ principalColumn: "Id");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ table: "Orders");
+
+ migrationBuilder.DropTable(
+ name: "Implementers");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Orders_ImplementerId",
+ table: "Orders");
+
+ migrationBuilder.DropColumn(
+ name: "ImplementerId",
+ table: "Orders");
+ }
+ }
+}
diff --git a/GarmentFactoryDatabaseImplement/Migrations/20240416174511_AddedImplementer_fix1.Designer.cs b/GarmentFactoryDatabaseImplement/Migrations/20240416174511_AddedImplementer_fix1.Designer.cs
new file mode 100644
index 0000000..cf08852
--- /dev/null
+++ b/GarmentFactoryDatabaseImplement/Migrations/20240416174511_AddedImplementer_fix1.Designer.cs
@@ -0,0 +1,257 @@
+//
+using System;
+using GarmentFactoryDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace GarmentFactoryDatabaseImplement.Migrations
+{
+ [DbContext(typeof(GarmentFactoryDatabase))]
+ [Migration("20240416174511_AddedImplementer_fix1")]
+ partial class AddedImplementer_fix1
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.17")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClientFIO")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Clients");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Cost")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.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("GarmentFactoryDatabaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClientId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("DateComplete")
+ .HasColumnType("datetime2");
+
+ b.Property("DateCreate")
+ .HasColumnType("datetime2");
+
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("Sum")
+ .HasColumnType("float");
+
+ b.Property("TextileId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("ImplementerId");
+
+ b.HasIndex("TextileId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Price")
+ .HasColumnType("float");
+
+ b.Property("TextileName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Textiles");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.TextileComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ComponentId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("TextileId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComponentId");
+
+ b.HasIndex("TextileId");
+
+ b.ToTable("TextileComponents");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Client", "Client")
+ .WithMany("Orders")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Order")
+ .HasForeignKey("ImplementerId");
+
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
+ .WithMany("Orders")
+ .HasForeignKey("TextileId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Client");
+
+ b.Navigation("Implementer");
+
+ b.Navigation("Textile");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.TextileComponent", b =>
+ {
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Component", "Component")
+ .WithMany("TextileComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
+ .WithMany("Components")
+ .HasForeignKey("TextileId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Textile");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Client", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Component", b =>
+ {
+ b.Navigation("TextileComponents");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Order");
+ });
+
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/GarmentFactoryDatabaseImplement/Migrations/20240416174511_AddedImplementer_fix1.cs b/GarmentFactoryDatabaseImplement/Migrations/20240416174511_AddedImplementer_fix1.cs
new file mode 100644
index 0000000..21b529f
--- /dev/null
+++ b/GarmentFactoryDatabaseImplement/Migrations/20240416174511_AddedImplementer_fix1.cs
@@ -0,0 +1,22 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace GarmentFactoryDatabaseImplement.Migrations
+{
+ ///
+ public partial class AddedImplementer_fix1 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+
+ }
+ }
+}
diff --git a/GarmentFactoryDatabaseImplement/Migrations/GarmentFactoryDatabaseModelSnapshot.cs b/GarmentFactoryDatabaseImplement/Migrations/GarmentFactoryDatabaseModelSnapshot.cs
index 1b5f678..3946c85 100644
--- a/GarmentFactoryDatabaseImplement/Migrations/GarmentFactoryDatabaseModelSnapshot.cs
+++ b/GarmentFactoryDatabaseImplement/Migrations/GarmentFactoryDatabaseModelSnapshot.cs
@@ -67,6 +67,33 @@ namespace GarmentFactoryDatabaseImplement.Migrations
b.ToTable("Components");
});
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.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("GarmentFactoryDatabaseImplement.Models.Order", b =>
{
b.Property("Id")
@@ -87,6 +114,9 @@ namespace GarmentFactoryDatabaseImplement.Migrations
b.Property("DateCreate")
.HasColumnType("datetime2");
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
b.Property("Status")
.HasColumnType("int");
@@ -100,6 +130,8 @@ namespace GarmentFactoryDatabaseImplement.Migrations
b.HasIndex("ClientId");
+ b.HasIndex("ImplementerId");
+
b.HasIndex("TextileId");
b.ToTable("Orders");
@@ -159,6 +191,10 @@ namespace GarmentFactoryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.HasOne("GarmentFactoryDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Order")
+ .HasForeignKey("ImplementerId");
+
b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
.WithMany("Orders")
.HasForeignKey("TextileId")
@@ -167,6 +203,8 @@ namespace GarmentFactoryDatabaseImplement.Migrations
b.Navigation("Client");
+ b.Navigation("Implementer");
+
b.Navigation("Textile");
});
@@ -199,6 +237,11 @@ namespace GarmentFactoryDatabaseImplement.Migrations
b.Navigation("TextileComponents");
});
+ modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Order");
+ });
+
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
{
b.Navigation("Components");
diff --git a/GarmentFactoryDatabaseImplement/Models/Implementer.cs b/GarmentFactoryDatabaseImplement/Models/Implementer.cs
new file mode 100644
index 0000000..d0acfb9
--- /dev/null
+++ b/GarmentFactoryDatabaseImplement/Models/Implementer.cs
@@ -0,0 +1,70 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.ViewModels;
+using GarmentFactoryDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryDatabaseImplement.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 Order { 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
+ };
+ }
+}
diff --git a/GarmentFactoryDatabaseImplement/Models/Order.cs b/GarmentFactoryDatabaseImplement/Models/Order.cs
index b20c872..2282b83 100644
--- a/GarmentFactoryDatabaseImplement/Models/Order.cs
+++ b/GarmentFactoryDatabaseImplement/Models/Order.cs
@@ -21,7 +21,9 @@ namespace GarmentFactoryDatabaseImplement.Models
[Required]
public int TextileId { get; private set; }
- [Required]
+ public int? ImplementerId { get; private set; }
+
+ [Required]
public int Count { get; set; }
[Required]
@@ -41,24 +43,28 @@ namespace GarmentFactoryDatabaseImplement.Models
// Для передачи ФИО клиента
public virtual Client Client { get; set; }
- public static Order? Create(OrderBindingModel model)
+ public virtual Implementer? Implementer { get; set; } = new();
+
+ public static Order? Create(OrderBindingModel model)
{
if (model == null)
{
return null;
}
-
- return new Order()
+ using var context = new GarmentFactoryDatabase();
+ return new Order()
{
Id = model.Id,
ClientId = model.ClientId,
TextileId = model.TextileId,
- Count = model.Count,
+ ImplementerId = model.ImplementerId,
+ Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => x.Id == model.ImplementerId) : null,
+ Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateComplete = model.DateComplete,
- };
+ };
}
public void Update(OrderBindingModel model)
@@ -67,9 +73,12 @@ namespace GarmentFactoryDatabaseImplement.Models
{
return;
}
-
- Status = model.Status;
+ using var context = new GarmentFactoryDatabase();
+ ImplementerId = model.ImplementerId;
+ Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => x.Id == model.ImplementerId) : null;
+ Status = model.Status;
DateComplete = model.DateComplete;
+ context.SaveChanges();
}
public OrderViewModel GetViewModel => new()
@@ -77,13 +86,15 @@ namespace GarmentFactoryDatabaseImplement.Models
Id = Id,
ClientId = ClientId,
TextileId = TextileId,
- Count = Count,
+ ImplementerId = ImplementerId,
+ Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateComplete = DateComplete,
TextileName = Textile.TextileName,
- ClientFIO = Client.ClientFIO
+ ClientFIO = Client.ClientFIO,
+ ImplementerFIO = Implementer?.ImplementerFIO,
};
}
}
diff --git a/GarmentFactoryFileImplement/DataFileSingleton.cs b/GarmentFactoryFileImplement/DataFileSingleton.cs
index 72833c4..eb98241 100644
--- a/GarmentFactoryFileImplement/DataFileSingleton.cs
+++ b/GarmentFactoryFileImplement/DataFileSingleton.cs
@@ -15,11 +15,13 @@ namespace GarmentFactoryFileImplement
private readonly string OrderFileName = "Order.xml";
private readonly string TextileFileName = "Textile.xml";
private readonly string ClientFileName = "Client.xml";
- public List Components { get; private set; }
+ private readonly string ImplementerFileName = "Implementer.xml";
+ public List Components { get; private set; }
public List Orders { get; private set; }
public List Textiles { get; private set; }
public List Clients { get; private set; }
- public static DataFileSingleton GetInstance()
+ public List Implementers { get; private set; }
+ public static DataFileSingleton GetInstance()
{
if (instance == null)
{
@@ -31,14 +33,16 @@ namespace GarmentFactoryFileImplement
public void SaveTextiles() => SaveData(Textiles, TextileFileName, "Textiles", 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()
+ private DataFileSingleton()
{
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
Textiles = LoadData(TextileFileName, "Textile", x => Textile.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/GarmentFactoryFileImplement/Implements/ImplementerStorage.cs b/GarmentFactoryFileImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..6277059
--- /dev/null
+++ b/GarmentFactoryFileImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,99 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.SearchModels;
+using GarmentFactoryContracts.StoragesContracts;
+using GarmentFactoryContracts.ViewModels;
+using GarmentFactoryFileImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryFileImplement.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 (model == null)
+ {
+ return new();
+ }
+ if (model.Id.HasValue)
+ {
+ var res = GetElement(model);
+ return res != null ? new() { res } : new();
+ }
+ if (model.ImplementerFIO != null)
+ {
+ return _source.Implementers
+ .Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO))
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return new();
+ }
+
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ if (model.Id.HasValue)
+ {
+ return _source.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
+ }
+ if (model.ImplementerFIO != null && model.Password != null)
+ {
+ return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))?.GetViewModel;
+ }
+ if (model.ImplementerFIO != null)
+ {
+ return _source.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel;
+ }
+ return null;
+ }
+
+ public ImplementerViewModel? Insert(ImplementerBindingModel model)
+ {
+ model.Id = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.Id) + 1 : 1;
+ var res = Implementer.Create(model);
+ if (res != null)
+ {
+ _source.Implementers.Add(res);
+ _source.SaveImplementers();
+ }
+ return res?.GetViewModel;
+ }
+
+ public ImplementerViewModel? Update(ImplementerBindingModel model)
+ {
+ var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id);
+ if (res != null)
+ {
+ res.Update(model);
+ _source.SaveImplementers();
+ }
+ return res?.GetViewModel;
+ }
+
+ public ImplementerViewModel? Delete(ImplementerBindingModel model)
+ {
+ var res = _source.Implementers.FirstOrDefault(x => x.Id == model.Id);
+ if (res != null)
+ {
+ _source.Implementers.Remove(res);
+ _source.SaveImplementers();
+ }
+ return res?.GetViewModel;
+ }
+ }
+}
diff --git a/GarmentFactoryFileImplement/Implements/OrderStorage.cs b/GarmentFactoryFileImplement/Implements/OrderStorage.cs
index 4b0e412..55eb7ae 100644
--- a/GarmentFactoryFileImplement/Implements/OrderStorage.cs
+++ b/GarmentFactoryFileImplement/Implements/OrderStorage.cs
@@ -18,22 +18,27 @@ namespace GarmentFactoryFileImplement.Implements
{
source = DataFileSingleton.GetInstance();
}
- public List GetFullList() => source.Orders.Select(x => AddTextileName(AddClientFIO(x.GetViewModel))).ToList();
+ public List GetFullList() => source.Orders.Select(x => AddTextileName(AddClientFIO(AddImplementerFIO(x.GetViewModel)))).ToList();
public List GetFilteredList(OrderSearchModel model)
{
if (model.Id.HasValue)
{
- return source.Orders.Where(x => x.Id == model.Id).Select(x => AddTextileName(AddClientFIO(x.GetViewModel))).ToList();
+ return source.Orders.Where(x => x.Id == model.Id).Select(x => AddTextileName(AddClientFIO(AddImplementerFIO(x.GetViewModel)))).ToList();
}
else if (model.DateFrom.HasValue)
{
- return source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => AddTextileName(AddClientFIO(x.GetViewModel))).ToList();
+ return source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => AddTextileName(AddClientFIO(AddImplementerFIO(x.GetViewModel)))).ToList();
}
else if (model.ClientId.HasValue)
{
- return source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => AddTextileName(AddClientFIO(x.GetViewModel))).ToList();
+ return source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => AddTextileName(AddClientFIO(AddImplementerFIO(x.GetViewModel)))).ToList();
}
- return new();
+ else if (model.ImplementerId.HasValue)
+ {
+ return source.Orders.Where(x => x.ImplementerId == model.ImplementerId).Select(x => AddTextileName(AddClientFIO(AddImplementerFIO(x.GetViewModel)))).ToList();
+
+ }
+ return new();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
@@ -41,7 +46,7 @@ namespace GarmentFactoryFileImplement.Implements
{
return new();
}
- return AddTextileName(AddClientFIO(source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel));
+ return AddTextileName(AddClientFIO(AddImplementerFIO(source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel)));
}
public OrderViewModel? Insert(OrderBindingModel model)
{
@@ -53,7 +58,7 @@ namespace GarmentFactoryFileImplement.Implements
}
source.Orders.Add(newOrder);
source.SaveOrders();
- return AddTextileName(AddClientFIO(newOrder.GetViewModel));
+ return AddTextileName(AddClientFIO(AddImplementerFIO(newOrder.GetViewModel)));
}
public OrderViewModel? Update(OrderBindingModel model)
{
@@ -64,7 +69,7 @@ namespace GarmentFactoryFileImplement.Implements
}
order.Update(model);
source.SaveOrders();
- return AddTextileName(AddClientFIO(order.GetViewModel));
+ return AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel)));
}
public OrderViewModel? Delete(OrderBindingModel model)
{
@@ -73,12 +78,26 @@ namespace GarmentFactoryFileImplement.Implements
{
source.Orders.Remove(order);
source.SaveOrders();
- return AddTextileName(AddClientFIO(order.GetViewModel));
+ return AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel)));
}
return null;
}
- private OrderViewModel? AddClientFIO(OrderViewModel? model)
+ private OrderViewModel? AddImplementerFIO(OrderViewModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId);
+ if (implementer != null)
+ {
+ model.ImplementerFIO = implementer.ImplementerFIO;
+ }
+ return model;
+ }
+
+ private OrderViewModel? AddClientFIO(OrderViewModel? model)
{
if (model == null)
{
diff --git a/GarmentFactoryFileImplement/Models/Implementer.cs b/GarmentFactoryFileImplement/Models/Implementer.cs
new file mode 100644
index 0000000..f2de17e
--- /dev/null
+++ b/GarmentFactoryFileImplement/Models/Implementer.cs
@@ -0,0 +1,85 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.ViewModels;
+using GarmentFactoryDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace GarmentFactoryFileImplement.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(XElement element)
+ {
+ if (element == null)
+ {
+ return null;
+ }
+ return new()
+ {
+ ImplementerFIO = element.Element("FIO")!.Value,
+ Password = element.Element("Password")!.Value,
+ Id = Convert.ToInt32(element.Attribute("Id")!.Value),
+ Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
+ WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value),
+ };
+ }
+
+ 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,
+ };
+
+ public XElement GetXElement => new("Client",
+ new XAttribute("Id", Id),
+ new XElement("Password", Password),
+ new XElement("FIO", ImplementerFIO),
+ new XElement("Qualification", Qualification),
+ new XElement("WorkExperience", WorkExperience)
+ );
+ }
+}
diff --git a/GarmentFactoryFileImplement/Models/Order.cs b/GarmentFactoryFileImplement/Models/Order.cs
index e2c5e90..68c53de 100644
--- a/GarmentFactoryFileImplement/Models/Order.cs
+++ b/GarmentFactoryFileImplement/Models/Order.cs
@@ -15,7 +15,8 @@ namespace GarmentFactoryFileImplement.Models
{
public int Id { get; private set; }
public int ClientId { get; private set; }
- public int TextileId { get; private set; }
+ public int? ImplementerId { get; set; }
+ public int TextileId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@@ -31,7 +32,8 @@ namespace GarmentFactoryFileImplement.Models
{
Id = model.Id,
ClientId = model.ClientId,
- TextileId = model.TextileId,
+ ImplementerId = model.ImplementerId,
+ TextileId = model.TextileId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@@ -51,7 +53,8 @@ namespace GarmentFactoryFileImplement.Models
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
TextileId = Convert.ToInt32(element.Element("TextileId")!.Value),
- Count = Convert.ToInt32(element.Element("Count")!.Value),
+ ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
+ Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)(Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value)),
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
@@ -75,7 +78,8 @@ namespace GarmentFactoryFileImplement.Models
Id = Id,
ClientId = ClientId,
TextileId = TextileId,
- Count = Count,
+ ImplementerId = ImplementerId,
+ Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
@@ -85,7 +89,8 @@ namespace GarmentFactoryFileImplement.Models
new XAttribute("Id", Id),
new XElement("ClientId", ClientId.ToString()),
new XElement("TextileId", TextileId.ToString()),
- new XElement("Count", Count.ToString()),
+ new XElement("ImplementerId", ImplementerId),
+ new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),
new XElement("DateCreate", DateCreate.ToString()),
diff --git a/GarmentFactoryListImplement/DataListSingleton.cs b/GarmentFactoryListImplement/DataListSingleton.cs
index 5eb05c3..13869f0 100644
--- a/GarmentFactoryListImplement/DataListSingleton.cs
+++ b/GarmentFactoryListImplement/DataListSingleton.cs
@@ -9,13 +9,15 @@ namespace GarmentFactoryListImplement
public List Orders { get; set; }
public List Textiles { get; set; }
public List Clients { get; set; }
+ public List Implementers { get; set; }
private DataListSingleton()
{
Components = new List();
Orders = new List();
Textiles = new List();
Clients = new List();
- }
+ Implementers = new List();
+ }
public static DataListSingleton GetInstance()
{
if (_instance == null)
diff --git a/GarmentFactoryListImplement/Implements/ImplementerStorage.cs b/GarmentFactoryListImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..ae416f3
--- /dev/null
+++ b/GarmentFactoryListImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,123 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.SearchModels;
+using GarmentFactoryContracts.StoragesContracts;
+using GarmentFactoryContracts.ViewModels;
+using GarmentFactoryListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryListImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ private readonly DataListSingleton _source;
+ public ImplementerStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ 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;
+ }
+
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ foreach (var x in _source.Implementers)
+ {
+ if (model.Id.HasValue && x.Id == model.Id)
+ {
+ return x.GetViewModel;
+ }
+ if (model.ImplementerFIO != null && model.Password != null && x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))
+ {
+ return x.GetViewModel;
+ }
+ if (model.ImplementerFIO != null && x.ImplementerFIO.Equals(model.ImplementerFIO))
+ {
+ return x.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ if (model == null)
+ {
+ return new();
+ }
+ if (model.Id.HasValue)
+ {
+ var res = GetElement(model);
+ return res != null ? new() { res } : new();
+ }
+
+ List result = new();
+ if (model.ImplementerFIO != null)
+ {
+ foreach (var implementer in _source.Implementers)
+ {
+ if (implementer.ImplementerFIO.Equals(model.ImplementerFIO))
+ {
+ result.Add(implementer.GetViewModel);
+ }
+ }
+ }
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var implementer in _source.Implementers)
+ {
+ result.Add(implementer.GetViewModel);
+ }
+ return result;
+ }
+
+ 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 res = Implementer.Create(model);
+ if (res != null)
+ {
+ _source.Implementers.Add(res);
+ }
+ return res?.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;
+ }
+ }
+}
diff --git a/GarmentFactoryListImplement/Implements/OrderStorage.cs b/GarmentFactoryListImplement/Implements/OrderStorage.cs
index 2a5d3ef..7bc2670 100644
--- a/GarmentFactoryListImplement/Implements/OrderStorage.cs
+++ b/GarmentFactoryListImplement/Implements/OrderStorage.cs
@@ -25,7 +25,7 @@ namespace GarmentFactoryListImplement.Implements
foreach (var order in _source.Orders)
{
- result.Add(AddTextileName(AddClientFIO(order.GetViewModel)));
+ result.Add(AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel))));
}
return result;
@@ -41,7 +41,7 @@ namespace GarmentFactoryListImplement.Implements
{
if (order.Id == model.Id)
{
- result.Add(AddTextileName(AddClientFIO(order.GetViewModel)));
+ result.Add(AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel))));
}
}
}
@@ -51,8 +51,8 @@ namespace GarmentFactoryListImplement.Implements
{
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
{
- result.Add(AddTextileName(AddClientFIO(order.GetViewModel)));
- }
+ result.Add(AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel))));
+ }
}
}
else if (model.ClientId.HasValue)
@@ -61,10 +61,20 @@ namespace GarmentFactoryListImplement.Implements
{
if (order.ClientId == model.ClientId)
{
- result.Add(AddTextileName(AddClientFIO(order.GetViewModel)));
- }
+ result.Add(AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel))));
+ }
}
}
+ else if (model.ImplementerId.HasValue)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.ImplementerId == model.ImplementerId)
+ {
+ result.Add(AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel))));
+ }
+ }
+ }
return result;
}
@@ -80,7 +90,7 @@ namespace GarmentFactoryListImplement.Implements
{
if (model.Id.HasValue && order.Id == model.Id)
{
- return AddTextileName(AddClientFIO(order.GetViewModel));
+ return AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel)));
}
}
@@ -108,8 +118,8 @@ namespace GarmentFactoryListImplement.Implements
_source.Orders.Add(newOrder);
- return AddTextileName(AddClientFIO(newOrder.GetViewModel));
- }
+ return AddTextileName(AddClientFIO(AddImplementerFIO(newOrder.GetViewModel)));
+ }
public OrderViewModel? Update(OrderBindingModel model)
{
@@ -118,8 +128,8 @@ namespace GarmentFactoryListImplement.Implements
if (order.Id == model.Id)
{
order.Update(model);
- return AddTextileName(AddClientFIO(order.GetViewModel));
- }
+ return AddTextileName(AddClientFIO(AddImplementerFIO(order.GetViewModel)));
+ }
}
return null;
@@ -133,13 +143,23 @@ namespace GarmentFactoryListImplement.Implements
{
var element = _source.Orders[i];
_source.Orders.RemoveAt(i);
- return AddTextileName(AddClientFIO(element.GetViewModel));
- }
+ return AddTextileName(AddClientFIO(AddImplementerFIO(element.GetViewModel)));
+ }
}
return null;
}
- private OrderViewModel AddClientFIO(OrderViewModel model)
+ private OrderViewModel AddImplementerFIO(OrderViewModel model)
+ {
+ var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ClientId);
+ if (implementer != null)
+ {
+ model.ImplementerFIO = implementer.ImplementerFIO;
+ }
+ return model;
+ }
+
+ private OrderViewModel AddClientFIO(OrderViewModel model)
{
var client = _source.Clients.FirstOrDefault(x => x.Id == model.ClientId);
if (client != null)
diff --git a/GarmentFactoryListImplement/Models/Implementer.cs b/GarmentFactoryListImplement/Models/Implementer.cs
new file mode 100644
index 0000000..98142fb
--- /dev/null
+++ b/GarmentFactoryListImplement/Models/Implementer.cs
@@ -0,0 +1,60 @@
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.ViewModels;
+using GarmentFactoryDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GarmentFactoryListImplement.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()
+ {
+ 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,
+ };
+ }
+}
diff --git a/GarmentFactoryListImplement/Models/Order.cs b/GarmentFactoryListImplement/Models/Order.cs
index 2ef2a4c..375a75e 100644
--- a/GarmentFactoryListImplement/Models/Order.cs
+++ b/GarmentFactoryListImplement/Models/Order.cs
@@ -5,6 +5,7 @@ using GarmentFactoryDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -15,7 +16,8 @@ namespace GarmentFactoryListImplement.Models
public int Id { get; private set; }
public int ClientId { get; private set; }
public int TextileId { get; private set; }
- public int Count { get; set; }
+ public int? ImplementerId { get; private set; }
+ public int Count { get; set; }
public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; set; } = DateTime.Now;
@@ -32,7 +34,8 @@ namespace GarmentFactoryListImplement.Models
Id = model.Id,
ClientId = model.ClientId,
TextileId = model.TextileId,
- Count = model.Count,
+ ImplementerId = model.ImplementerId,
+ Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
@@ -58,7 +61,8 @@ namespace GarmentFactoryListImplement.Models
Id = Id,
ClientId = ClientId,
TextileId = TextileId,
- Count = Count,
+ ImplementerId = ImplementerId,
+ Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
diff --git a/GarmentFactoryRestApi/Controllers/ImplementerController.cs b/GarmentFactoryRestApi/Controllers/ImplementerController.cs
new file mode 100644
index 0000000..aec1252
--- /dev/null
+++ b/GarmentFactoryRestApi/Controllers/ImplementerController.cs
@@ -0,0 +1,106 @@
+using DocumentFormat.OpenXml.Office2010.Excel;
+using GarmentFactoryContracts.BindingModels;
+using GarmentFactoryContracts.BusinessLogicsContracts;
+using GarmentFactoryContracts.SearchModels;
+using GarmentFactoryContracts.ViewModels;
+using GarmentFactoryDataModels.Enums;
+using Microsoft.AspNetCore.Mvc;
+
+namespace GarmentFactoryRestApi.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;
+ }
+ }
+ }
+}
diff --git a/GarmentFactoryRestApi/Program.cs b/GarmentFactoryRestApi/Program.cs
index 27ac76b..845dea3 100644
--- a/GarmentFactoryRestApi/Program.cs
+++ b/GarmentFactoryRestApi/Program.cs
@@ -10,10 +10,12 @@ builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
// Add services to the container.
+builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();