diff --git a/AutomobilePlant/FormImplementer.Designer.cs b/AutomobilePlant/FormImplementer.Designer.cs
new file mode 100644
index 0000000..1e73842
--- /dev/null
+++ b/AutomobilePlant/FormImplementer.Designer.cs
@@ -0,0 +1,167 @@
+namespace AutomobilePlant
+{
+ 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.labelFIO = new System.Windows.Forms.Label();
+ this.labelPassword = new System.Windows.Forms.Label();
+ this.labelWorkExp = new System.Windows.Forms.Label();
+ this.labelQualification = new System.Windows.Forms.Label();
+ this.textBoxFIO = new System.Windows.Forms.TextBox();
+ this.textBoxPassword = new System.Windows.Forms.TextBox();
+ this.numericUpDownWorkExp = new System.Windows.Forms.NumericUpDown();
+ this.numericUpDownQualification = new System.Windows.Forms.NumericUpDown();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExp)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).BeginInit();
+ this.SuspendLayout();
+ //
+ // labelFIO
+ //
+ this.labelFIO.AutoSize = true;
+ this.labelFIO.Location = new System.Drawing.Point(24, 47);
+ this.labelFIO.Name = "labelFIO";
+ this.labelFIO.Size = new System.Drawing.Size(49, 20);
+ this.labelFIO.TabIndex = 0;
+ this.labelFIO.Text = "ФИО: ";
+ //
+ // labelPassword
+ //
+ this.labelPassword.AutoSize = true;
+ this.labelPassword.Location = new System.Drawing.Point(24, 92);
+ this.labelPassword.Name = "labelPassword";
+ this.labelPassword.Size = new System.Drawing.Size(65, 20);
+ this.labelPassword.TabIndex = 1;
+ this.labelPassword.Text = "Пароль:";
+ //
+ // labelWorkExp
+ //
+ this.labelWorkExp.AutoSize = true;
+ this.labelWorkExp.Location = new System.Drawing.Point(24, 134);
+ this.labelWorkExp.Name = "labelWorkExp";
+ this.labelWorkExp.Size = new System.Drawing.Size(102, 20);
+ this.labelWorkExp.TabIndex = 2;
+ this.labelWorkExp.Text = "Стаж работы:";
+ //
+ // labelQualification
+ //
+ this.labelQualification.AutoSize = true;
+ this.labelQualification.Location = new System.Drawing.Point(24, 177);
+ this.labelQualification.Name = "labelQualification";
+ this.labelQualification.Size = new System.Drawing.Size(114, 20);
+ this.labelQualification.TabIndex = 3;
+ this.labelQualification.Text = "Квалификация:";
+ //
+ // textBoxFIO
+ //
+ this.textBoxFIO.Location = new System.Drawing.Point(155, 47);
+ this.textBoxFIO.Name = "textBoxFIO";
+ this.textBoxFIO.Size = new System.Drawing.Size(371, 27);
+ this.textBoxFIO.TabIndex = 4;
+ //
+ // textBoxPassword
+ //
+ this.textBoxPassword.Location = new System.Drawing.Point(155, 85);
+ this.textBoxPassword.Name = "textBoxPassword";
+ this.textBoxPassword.Size = new System.Drawing.Size(182, 27);
+ this.textBoxPassword.TabIndex = 5;
+ //
+ // numericUpDownWorkExp
+ //
+ this.numericUpDownWorkExp.Location = new System.Drawing.Point(155, 132);
+ this.numericUpDownWorkExp.Name = "numericUpDownWorkExp";
+ this.numericUpDownWorkExp.Size = new System.Drawing.Size(182, 27);
+ this.numericUpDownWorkExp.TabIndex = 6;
+ //
+ // numericUpDownQualification
+ //
+ this.numericUpDownQualification.Location = new System.Drawing.Point(155, 175);
+ this.numericUpDownQualification.Name = "numericUpDownQualification";
+ this.numericUpDownQualification.Size = new System.Drawing.Size(182, 27);
+ this.numericUpDownQualification.TabIndex = 7;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(324, 233);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(103, 29);
+ this.buttonSave.TabIndex = 8;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(433, 233);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(106, 29);
+ this.buttonCancel.TabIndex = 9;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // FormImplementer
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(551, 274);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.numericUpDownQualification);
+ this.Controls.Add(this.numericUpDownWorkExp);
+ this.Controls.Add(this.textBoxPassword);
+ this.Controls.Add(this.textBoxFIO);
+ this.Controls.Add(this.labelQualification);
+ this.Controls.Add(this.labelWorkExp);
+ this.Controls.Add(this.labelPassword);
+ this.Controls.Add(this.labelFIO);
+ this.Name = "FormImplementer";
+ this.Text = "Исполнитель";
+ this.Load += new System.EventHandler(this.FormImplementer_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExp)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelFIO;
+ private Label labelPassword;
+ private Label labelWorkExp;
+ private Label labelQualification;
+ private TextBox textBoxFIO;
+ private TextBox textBoxPassword;
+ private NumericUpDown numericUpDownWorkExp;
+ private NumericUpDown numericUpDownQualification;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/AutomobilePlant/FormImplementer.cs b/AutomobilePlant/FormImplementer.cs
new file mode 100644
index 0000000..2785248
--- /dev/null
+++ b/AutomobilePlant/FormImplementer.cs
@@ -0,0 +1,101 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicContracts;
+using AutomobilePlantContracts.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 AutomobilePlant
+{
+ 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;
+ numericUpDownQualification.Value = view.Qualification;
+ numericUpDownWorkExp.Value = view.WorkExperience;
+ }
+ }
+ 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(textBoxPassword.Text))
+ {
+ MessageBox.Show("Заполните пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(textBoxFIO.Text))
+ {
+ MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение исполнителя");
+ try
+ {
+ var model = new ImplementerBindingModel
+ {
+ Id = _id ?? 0,
+ ImplementerFIO = textBoxFIO.Text,
+ Password = textBoxPassword.Text,
+ Qualification = (int)numericUpDownQualification.Value,
+ WorkExperience = (int)numericUpDownWorkExp.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/AutomobilePlant/FormImplementer.resx b/AutomobilePlant/FormImplementer.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/AutomobilePlant/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/AutomobilePlant/FormImplementers.Designer.cs b/AutomobilePlant/FormImplementers.Designer.cs
new file mode 100644
index 0000000..d08423a
--- /dev/null
+++ b/AutomobilePlant/FormImplementers.Designer.cs
@@ -0,0 +1,114 @@
+namespace AutomobilePlant
+{
+ 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()
+ {
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.buttonEdit = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonRefresh = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.Location = new System.Drawing.Point(667, 12);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(121, 29);
+ this.buttonCreate.TabIndex = 0;
+ this.buttonCreate.Text = "Добавить";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(667, 47);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(121, 29);
+ this.buttonEdit.TabIndex = 1;
+ this.buttonEdit.Text = "Изменить";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(667, 82);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(121, 29);
+ this.buttonDelete.TabIndex = 2;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
+ //
+ // buttonRefresh
+ //
+ this.buttonRefresh.Location = new System.Drawing.Point(667, 117);
+ this.buttonRefresh.Name = "buttonRefresh";
+ this.buttonRefresh.Size = new System.Drawing.Size(121, 29);
+ this.buttonRefresh.TabIndex = 3;
+ this.buttonRefresh.Text = "Обновить";
+ this.buttonRefresh.UseVisualStyleBackColor = true;
+ this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 12);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(649, 426);
+ this.dataGridView.TabIndex = 4;
+ //
+ // FormImplementers
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.buttonRefresh);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonEdit);
+ this.Controls.Add(this.buttonCreate);
+ this.Name = "FormImplementers";
+ this.Text = "Исполнители";
+ this.Load += new System.EventHandler(this.FormImplementers_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonCreate;
+ private Button buttonEdit;
+ private Button buttonDelete;
+ private Button buttonRefresh;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/AutomobilePlant/FormImplementers.cs b/AutomobilePlant/FormImplementers.cs
new file mode 100644
index 0000000..b29b12b
--- /dev/null
+++ b/AutomobilePlant/FormImplementers.cs
@@ -0,0 +1,114 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicContracts;
+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 AutomobilePlant
+{
+ public partial class FormImplementers : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IImplementerLogic _logic;
+ public FormImplementers(ILogger logger, IImplementerLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormImplementers_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+ if (list != null)
+ {
+ 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 buttonCreate_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 buttonEdit_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/AutomobilePlant/FormImplementers.resx b/AutomobilePlant/FormImplementers.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/AutomobilePlant/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/AutomobilePlant/FormMain.Designer.cs b/AutomobilePlant/FormMain.Designer.cs
index e2fcb85..038e381 100644
--- a/AutomobilePlant/FormMain.Designer.cs
+++ b/AutomobilePlant/FormMain.Designer.cs
@@ -28,180 +28,174 @@
///
private void InitializeComponent()
{
- this.menuStrip = new System.Windows.Forms.MenuStrip();
- this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.автомобилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.списокАвтомобилейToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.компонентыПоАвтомобилямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- this.buttonCreateOrder = new System.Windows.Forms.Button();
- this.buttonSetToWork = new System.Windows.Forms.Button();
- this.buttonSetToDone = new System.Windows.Forms.Button();
- this.buttonSetToFinish = new System.Windows.Forms.Button();
- this.buttonUpdate = new System.Windows.Forms.Button();
- this.menuStrip.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // menuStrip
- //
- this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.menuStrip = new System.Windows.Forms.MenuStrip();
+ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.автомобилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.списокАвтомобилейToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.компонентыПоАвтомобилямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonCreateOrder = new System.Windows.Forms.Button();
+ this.buttonSetToFinish = new System.Windows.Forms.Button();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ this.menuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // menuStrip
+ //
+ this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem,
- this.отчетыToolStripMenuItem});
- this.menuStrip.Location = new System.Drawing.Point(0, 0);
- this.menuStrip.Name = "menuStrip";
- this.menuStrip.Size = new System.Drawing.Size(1436, 28);
- this.menuStrip.TabIndex = 0;
- this.menuStrip.Text = "Справочники";
- //
- // справочникиToolStripMenuItem
- //
- this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.отчетыToolStripMenuItem,
+ this.запускРаботToolStripMenuItem});
+ this.menuStrip.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip.Name = "menuStrip";
+ this.menuStrip.Size = new System.Drawing.Size(1436, 28);
+ this.menuStrip.TabIndex = 0;
+ this.menuStrip.Text = "Справочники";
+ //
+ // справочникиToolStripMenuItem
+ //
+ this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.компонентыToolStripMenuItem,
this.автомобилиToolStripMenuItem,
- this.клиентыToolStripMenuItem});
- this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
- this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
- this.справочникиToolStripMenuItem.Text = "Справочники";
- //
- // компонентыToolStripMenuItem
- //
- this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
- this.компонентыToolStripMenuItem.Text = "Компоненты";
- this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
- //
- // автомобилиToolStripMenuItem
- //
- this.автомобилиToolStripMenuItem.Name = "автомобилиToolStripMenuItem";
- this.автомобилиToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
- this.автомобилиToolStripMenuItem.Text = "Автомобили";
- this.автомобилиToolStripMenuItem.Click += new System.EventHandler(this.автомобилиToolStripMenuItem_Click);
- //
- // клиентыToolStripMenuItem
- //
- this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
- this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
- this.клиентыToolStripMenuItem.Text = "Клиенты";
- this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
- //
- // отчетыToolStripMenuItem
- //
- this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.клиентыToolStripMenuItem,
+ this.исполнителиToolStripMenuItem});
+ this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
+ this.справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // компонентыToolStripMenuItem
+ //
+ this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
+ this.компонентыToolStripMenuItem.Text = "Компоненты";
+ this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
+ //
+ // автомобилиToolStripMenuItem
+ //
+ this.автомобилиToolStripMenuItem.Name = "автомобилиToolStripMenuItem";
+ this.автомобилиToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
+ this.автомобилиToolStripMenuItem.Text = "Автомобили";
+ this.автомобилиToolStripMenuItem.Click += new System.EventHandler(this.автомобилиToolStripMenuItem_Click);
+ //
+ // клиентыToolStripMenuItem
+ //
+ this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
+ this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
+ this.клиентыToolStripMenuItem.Text = "Клиенты";
+ this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
+ //
+ // исполнителиToolStripMenuItem
+ //
+ this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
+ this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
+ this.исполнителиToolStripMenuItem.Text = "Исполнители";
+ this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click);
+ //
+ // отчетыToolStripMenuItem
+ //
+ this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.списокАвтомобилейToolStripMenuItem,
this.компонентыПоАвтомобилямToolStripMenuItem,
this.списокЗаказовToolStripMenuItem});
- this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
- this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
- this.отчетыToolStripMenuItem.Text = "Отчеты";
- //
- // списокАвтомобилейToolStripMenuItem
- //
- this.списокАвтомобилейToolStripMenuItem.Name = "списокАвтомобилейToolStripMenuItem";
- this.списокАвтомобилейToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
- this.списокАвтомобилейToolStripMenuItem.Text = "Список автомобилей";
- this.списокАвтомобилейToolStripMenuItem.Click += new System.EventHandler(this.списокАвтомобилейToolStripMenuItem_Click);
- //
- // компонентыПоАвтомобилямToolStripMenuItem
- //
- this.компонентыПоАвтомобилямToolStripMenuItem.Name = "компонентыПоАвтомобилямToolStripMenuItem";
- this.компонентыПоАвтомобилямToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
- this.компонентыПоАвтомобилямToolStripMenuItem.Text = "Компоненты по автомобилям";
- this.компонентыПоАвтомобилямToolStripMenuItem.Click += new System.EventHandler(this.компонентыПоАвтомобилямToolStripMenuItem_Click);
- //
- // списокЗаказовToolStripMenuItem
- //
- this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
- this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
- this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
- this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
- //
- // dataGridView
- //
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 31);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowHeadersWidth = 51;
- this.dataGridView.RowTemplate.Height = 29;
- this.dataGridView.Size = new System.Drawing.Size(1188, 407);
- this.dataGridView.TabIndex = 1;
- //
- // buttonCreateOrder
- //
- this.buttonCreateOrder.Location = new System.Drawing.Point(1220, 42);
- this.buttonCreateOrder.Name = "buttonCreateOrder";
- this.buttonCreateOrder.Size = new System.Drawing.Size(194, 29);
- this.buttonCreateOrder.TabIndex = 2;
- this.buttonCreateOrder.Text = "Создать заказ";
- this.buttonCreateOrder.UseVisualStyleBackColor = true;
- this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
- //
- // buttonSetToWork
- //
- this.buttonSetToWork.Location = new System.Drawing.Point(1220, 77);
- this.buttonSetToWork.Name = "buttonSetToWork";
- this.buttonSetToWork.Size = new System.Drawing.Size(194, 29);
- this.buttonSetToWork.TabIndex = 3;
- this.buttonSetToWork.Text = "Отдать на выполнение";
- this.buttonSetToWork.UseVisualStyleBackColor = true;
- this.buttonSetToWork.Click += new System.EventHandler(this.ButtonSetToWork_Click);
- //
- // buttonSetToDone
- //
- this.buttonSetToDone.Location = new System.Drawing.Point(1220, 112);
- this.buttonSetToDone.Name = "buttonSetToDone";
- this.buttonSetToDone.Size = new System.Drawing.Size(194, 29);
- this.buttonSetToDone.TabIndex = 4;
- this.buttonSetToDone.Text = "Заказ готов";
- this.buttonSetToDone.UseVisualStyleBackColor = true;
- this.buttonSetToDone.Click += new System.EventHandler(this.ButtonSetToDone_Click);
- //
- // buttonSetToFinish
- //
- this.buttonSetToFinish.Location = new System.Drawing.Point(1220, 147);
- this.buttonSetToFinish.Name = "buttonSetToFinish";
- this.buttonSetToFinish.Size = new System.Drawing.Size(194, 29);
- this.buttonSetToFinish.TabIndex = 5;
- this.buttonSetToFinish.Text = "Заказ выдан";
- this.buttonSetToFinish.UseVisualStyleBackColor = true;
- this.buttonSetToFinish.Click += new System.EventHandler(this.ButtonSetToFinish_Click);
- //
- // buttonUpdate
- //
- this.buttonUpdate.Location = new System.Drawing.Point(1220, 409);
- this.buttonUpdate.Name = "buttonUpdate";
- this.buttonUpdate.Size = new System.Drawing.Size(194, 29);
- this.buttonUpdate.TabIndex = 6;
- this.buttonUpdate.Text = "Обновить";
- this.buttonUpdate.UseVisualStyleBackColor = true;
- this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
- //
- // FormMain
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1436, 450);
- this.Controls.Add(this.buttonUpdate);
- this.Controls.Add(this.buttonSetToFinish);
- this.Controls.Add(this.buttonSetToDone);
- this.Controls.Add(this.buttonSetToWork);
- this.Controls.Add(this.buttonCreateOrder);
- this.Controls.Add(this.dataGridView);
- this.Controls.Add(this.menuStrip);
- this.MainMenuStrip = this.menuStrip;
- this.Name = "FormMain";
- this.Text = "Автомобильный завод";
- this.Load += new System.EventHandler(this.FormMain_Load);
- this.menuStrip.ResumeLayout(false);
- this.menuStrip.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
+ this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
+ this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
+ this.отчетыToolStripMenuItem.Text = "Отчеты";
+ //
+ // списокАвтомобилейToolStripMenuItem
+ //
+ this.списокАвтомобилейToolStripMenuItem.Name = "списокАвтомобилейToolStripMenuItem";
+ this.списокАвтомобилейToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
+ this.списокАвтомобилейToolStripMenuItem.Text = "Список автомобилей";
+ this.списокАвтомобилейToolStripMenuItem.Click += new System.EventHandler(this.списокАвтомобилейToolStripMenuItem_Click);
+ //
+ // компонентыПоАвтомобилямToolStripMenuItem
+ //
+ this.компонентыПоАвтомобилямToolStripMenuItem.Name = "компонентыПоАвтомобилямToolStripMenuItem";
+ this.компонентыПоАвтомобилямToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
+ this.компонентыПоАвтомобилямToolStripMenuItem.Text = "Компоненты по автомобилям";
+ this.компонентыПоАвтомобилямToolStripMenuItem.Click += new System.EventHandler(this.компонентыПоАвтомобилямToolStripMenuItem_Click);
+ //
+ // списокЗаказовToolStripMenuItem
+ //
+ this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
+ this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
+ this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
+ this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
+ //
+ // запускРаботToolStripMenuItem
+ //
+ this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
+ this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
+ this.запускРаботToolStripMenuItem.Text = "Запуск работ";
+ this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 31);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(1188, 407);
+ this.dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ this.buttonCreateOrder.Location = new System.Drawing.Point(1220, 42);
+ this.buttonCreateOrder.Name = "buttonCreateOrder";
+ this.buttonCreateOrder.Size = new System.Drawing.Size(194, 29);
+ this.buttonCreateOrder.TabIndex = 2;
+ this.buttonCreateOrder.Text = "Создать заказ";
+ this.buttonCreateOrder.UseVisualStyleBackColor = true;
+ this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
+ //
+ // buttonSetToFinish
+ //
+ this.buttonSetToFinish.Location = new System.Drawing.Point(1220, 147);
+ this.buttonSetToFinish.Name = "buttonSetToFinish";
+ this.buttonSetToFinish.Size = new System.Drawing.Size(194, 29);
+ this.buttonSetToFinish.TabIndex = 5;
+ this.buttonSetToFinish.Text = "Заказ выдан";
+ this.buttonSetToFinish.UseVisualStyleBackColor = true;
+ this.buttonSetToFinish.Click += new System.EventHandler(this.ButtonSetToFinish_Click);
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(1220, 409);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(194, 29);
+ this.buttonUpdate.TabIndex = 6;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1436, 450);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonSetToFinish);
+ this.Controls.Add(this.buttonCreateOrder);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
+ this.Name = "FormMain";
+ this.Text = "Автомобильный завод";
+ this.Load += new System.EventHandler(this.FormMain_Load);
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
}
@@ -213,8 +207,6 @@
private ToolStripMenuItem автомобилиToolStripMenuItem;
private DataGridView dataGridView;
private Button buttonCreateOrder;
- private Button buttonSetToWork;
- private Button buttonSetToDone;
private Button buttonSetToFinish;
private Button buttonUpdate;
private ToolStripMenuItem отчетыToolStripMenuItem;
@@ -222,5 +214,7 @@
private ToolStripMenuItem компонентыПоАвтомобилямToolStripMenuItem;
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem;
+ private ToolStripMenuItem исполнителиToolStripMenuItem;
+ private ToolStripMenuItem запускРаботToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/AutomobilePlant/FormMain.cs b/AutomobilePlant/FormMain.cs
index edb931c..9dcd31e 100644
--- a/AutomobilePlant/FormMain.cs
+++ b/AutomobilePlant/FormMain.cs
@@ -20,12 +20,14 @@ namespace AutomobilePlant
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic)
+ private readonly IWorkProcess _workProcess;
+ public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
+ _workProcess = workProcess;
}
private void FormMain_Load(object sender, EventArgs e)
@@ -44,6 +46,7 @@ namespace AutomobilePlant
dataGridView.DataSource = list;
dataGridView.Columns["CarId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
+ dataGridView.Columns["ImplementerId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов");
@@ -82,6 +85,15 @@ namespace AutomobilePlant
}
}
+ 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)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportCarComponents));
@@ -124,59 +136,6 @@ namespace AutomobilePlant
}
}
- private void ButtonSetToWork_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 ButtonSetToDone_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("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка отметки о готовности заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
-
private void ButtonSetToFinish_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
@@ -208,5 +167,12 @@ namespace AutomobilePlant
{
LoadData();
}
+
+ 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/AutomobilePlant/Program.cs b/AutomobilePlant/Program.cs
index e9be6c5..25492f3 100644
--- a/AutomobilePlant/Program.cs
+++ b/AutomobilePlant/Program.cs
@@ -36,12 +36,15 @@ namespace AutomobilePlant
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();
@@ -57,6 +60,8 @@ namespace AutomobilePlant
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/AutomobilePlantBusinessLogic/BusinessLogics/ImplementerLogic.cs b/AutomobilePlantBusinessLogic/BusinessLogics/ImplementerLogic.cs
new file mode 100644
index 0000000..860d60e
--- /dev/null
+++ b/AutomobilePlantBusinessLogic/BusinessLogics/ImplementerLogic.cs
@@ -0,0 +1,126 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicContracts;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StorageContracts;
+using AutomobilePlantContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantBusinessLogic.BusinessLogics
+{
+ public class ImplementerLogic : IImplementerLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IImplementerStorage _implementerStorage;
+ public ImplementerLogic(ILogger logger, IImplementerStorage implementerStorage)
+ {
+ _logger = logger;
+ _implementerStorage = implementerStorage;
+ }
+
+ 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;
+ }
+
+ public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. FIO:{FIO}.Id:{ Id}", model.ImplementerFIO, model.Id);
+ var element = _implementerStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+
+ public List? ReadList(ImplementerSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. FIO:{FIO}.Id:{ Id} ", model?.ImplementerFIO, model?.Id);
+ var list = (model == null) ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ private void CheckModel(ImplementerBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (model.WorkExperience < 0)
+ {
+ throw new ArgumentException("Стаж работы не может быть меньше нуля", nameof(model.WorkExperience));
+ }
+ if (model.Qualification < 0)
+ {
+ throw new ArgumentException("Квалификация не должна быть меньше нуля", nameof(model.Qualification));
+ }
+ if (string.IsNullOrEmpty(model.Password))
+ {
+ throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.ImplementerFIO));
+ }
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
+ }
+ _logger.LogInformation("Implementer. Id: {Id}, FIO: {FIO}", model.Id, model.ImplementerFIO);
+ var element = _implementerStorage.GetElement(new ImplementerSearchModel
+ {
+ ImplementerFIO = model.ImplementerFIO,
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
+ }
+ }
+ }
+}
diff --git a/AutomobilePlantBusinessLogic/BusinessLogics/OrderLogic.cs b/AutomobilePlantBusinessLogic/BusinessLogics/OrderLogic.cs
index f351853..6eae62d 100644
--- a/AutomobilePlantBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/AutomobilePlantBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -4,6 +4,7 @@ using AutomobilePlantContracts.SearchModels;
using AutomobilePlantContracts.StorageContracts;
using AutomobilePlantContracts.ViewModels;
using AutomobilePlantDataModels.Enums;
+using DocumentFormat.OpenXml.EMMA;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@@ -18,6 +19,8 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
+ static readonly object locker = new();
+
public OrderLogic(ILogger logger, IOrderStorage orderStorage)
{
_logger = logger;
@@ -63,8 +66,14 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
DateCreate = viewModel.DateCreate,
DateImplement = viewModel.DateImplement,
Count = viewModel.Count,
- Sum = viewModel.Sum
- };
+ Sum = viewModel.Sum,
+ ImplementerId = viewModel.ImplementerId
+ };
+
+ if (rawModel.ImplementerId.HasValue)
+ {
+ model.ImplementerId = rawModel.ImplementerId;
+ }
CheckModel(model, false);
if (model.Status + 1 != newStatus)
@@ -85,10 +94,13 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
public bool TakeOrderInWork(OrderBindingModel model)
{
- return StatusUpdate(model, OrderStatus.Выполняется);
+ lock (locker)
+ {
+ return StatusUpdate(model, OrderStatus.Выполняется);
+ }
}
-
- public bool DeliveryOrder(OrderBindingModel model)
+
+ public bool DeliveryOrder(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Готов);
}
@@ -111,6 +123,23 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
return list;
}
+ public OrderViewModel? ReadElement(OrderSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
+ var element = _orderStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
diff --git a/AutomobilePlantBusinessLogic/BusinessLogics/WorkModeling.cs b/AutomobilePlantBusinessLogic/BusinessLogics/WorkModeling.cs
new file mode 100644
index 0000000..417b9e9
--- /dev/null
+++ b/AutomobilePlantBusinessLogic/BusinessLogics/WorkModeling.cs
@@ -0,0 +1,142 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicContracts;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Enums;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantBusinessLogic.BusinessLogics
+{
+ public class WorkModeling : IWorkProcess
+ {
+ private readonly ILogger _logger;
+
+ private readonly Random _rnd;
+
+ private IOrderLogic? _orderLogic;
+
+ public WorkModeling(ILogger logger)
+ {
+ _logger = logger;
+ _rnd = new Random(1000);
+ }
+
+ public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
+ {
+ _orderLogic = orderLogic;
+ var implementers = implementerLogic.ReadList(null);
+ if (implementers == null)
+ {
+ _logger.LogWarning("DoWork. Implementers is null");
+ return;
+ }
+ var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
+ if (orders == null || orders.Count == 0)
+ {
+ _logger.LogWarning("DoWork. Orders is null or empty");
+ return;
+ }
+ _logger.LogDebug("DoWork for {Count} orders", orders.Count);
+ foreach (var implementer in implementers)
+ {
+ Task.Run(() => WorkerWorkAsync(implementer, orders));
+ }
+ }
+
+ private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders)
+ {
+ if (_orderLogic == null || implementer == null)
+ {
+ return;
+ }
+ await RunOrderInWork(implementer);
+
+ await Task.Run(() =>
+ {
+ foreach (var order in orders)
+ {
+ try
+ {
+ _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
+ // пытаемся назначить заказ на исполнителя
+ if (_orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = order.Id,
+ ImplementerId = implementer.Id
+ }))
+ {
+ // делаем работу
+ Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
+ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
+ _orderLogic.DeliveryOrder(new OrderBindingModel
+ {
+ Id = order.Id,
+ ImplementerId = implementer.Id
+ });
+ // отдыхаем
+ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
+ }
+
+ }
+ // кто-то мог уже перехватить заказ, игнорируем ошибку
+ catch (InvalidOperationException ex)
+ {
+ _logger.LogWarning(ex, "Error try get work");
+ }
+ // заканчиваем выполнение имитации в случае иной ошибки
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while do work");
+ throw;
+ }
+ }
+ });
+ }
+
+ private async Task RunOrderInWork(ImplementerViewModel implementer)
+ {
+ if (_orderLogic == null || implementer == null)
+ {
+ return;
+ }
+ try
+ {
+ var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
+ {
+ ImplementerId = implementer.Id,
+ Status = OrderStatus.Выполняется
+ }));
+ if (runOrder == null)
+ {
+ return;
+ }
+ _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
+ // доделываем работу
+ Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
+ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
+ _orderLogic.DeliveryOrder(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;
+ }
+ }
+ }
+}
diff --git a/AutomobilePlantClientApp/Views/Shared/_Layout.cshtml b/AutomobilePlantClientApp/Views/Shared/_Layout.cshtml
index 5577c90..52aec19 100644
--- a/AutomobilePlantClientApp/Views/Shared/_Layout.cshtml
+++ b/AutomobilePlantClientApp/Views/Shared/_Layout.cshtml
@@ -45,7 +45,7 @@
diff --git a/AutomobilePlantContracts/BindingModels/ImplementerBindingModel.cs b/AutomobilePlantContracts/BindingModels/ImplementerBindingModel.cs
new file mode 100644
index 0000000..f9d8331
--- /dev/null
+++ b/AutomobilePlantContracts/BindingModels/ImplementerBindingModel.cs
@@ -0,0 +1,22 @@
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.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/AutomobilePlantContracts/BindingModels/OrderBindingModel.cs b/AutomobilePlantContracts/BindingModels/OrderBindingModel.cs
index 505eb51..2819d77 100644
--- a/AutomobilePlantContracts/BindingModels/OrderBindingModel.cs
+++ b/AutomobilePlantContracts/BindingModels/OrderBindingModel.cs
@@ -13,6 +13,7 @@ namespace AutomobilePlantContracts.BindingModels
public int Id { get; set; }
public int CarId { get; set; }
public int ClientId { get; set; }
+ public int? ImplementerId { get; set; }
public int Count { get; set; }
public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
diff --git a/AutomobilePlantContracts/BusinessLogicContracts/IImplementerLogic.cs b/AutomobilePlantContracts/BusinessLogicContracts/IImplementerLogic.cs
new file mode 100644
index 0000000..1704510
--- /dev/null
+++ b/AutomobilePlantContracts/BusinessLogicContracts/IImplementerLogic.cs
@@ -0,0 +1,24 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.BusinessLogicContracts
+{
+ 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/AutomobilePlantContracts/BusinessLogicContracts/IOrderLogic.cs b/AutomobilePlantContracts/BusinessLogicContracts/IOrderLogic.cs
index c5bc886..a6d1ecf 100644
--- a/AutomobilePlantContracts/BusinessLogicContracts/IOrderLogic.cs
+++ b/AutomobilePlantContracts/BusinessLogicContracts/IOrderLogic.cs
@@ -12,6 +12,7 @@ namespace AutomobilePlantContracts.BusinessLogicContracts
public interface IOrderLogic
{
List? ReadList(OrderSearchModel? model);
+ OrderViewModel? ReadElement(OrderSearchModel model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
diff --git a/AutomobilePlantContracts/BusinessLogicContracts/IWorkProcess.cs b/AutomobilePlantContracts/BusinessLogicContracts/IWorkProcess.cs
new file mode 100644
index 0000000..d668ce0
--- /dev/null
+++ b/AutomobilePlantContracts/BusinessLogicContracts/IWorkProcess.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.BusinessLogicContracts
+{
+ public interface IWorkProcess
+ {
+ void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
+ }
+}
diff --git a/AutomobilePlantContracts/SearchModels/ImplementerSearchModel.cs b/AutomobilePlantContracts/SearchModels/ImplementerSearchModel.cs
new file mode 100644
index 0000000..82a2c0a
--- /dev/null
+++ b/AutomobilePlantContracts/SearchModels/ImplementerSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.SearchModels
+{
+ public class ImplementerSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ImplementerFIO { get; set; }
+ public string? Password { get; set; }
+ }
+}
diff --git a/AutomobilePlantContracts/SearchModels/OrderSearchModel.cs b/AutomobilePlantContracts/SearchModels/OrderSearchModel.cs
index 7852946..2fddd21 100644
--- a/AutomobilePlantContracts/SearchModels/OrderSearchModel.cs
+++ b/AutomobilePlantContracts/SearchModels/OrderSearchModel.cs
@@ -1,4 +1,5 @@
-using System;
+using AutomobilePlantDataModels.Enums;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -12,5 +13,7 @@ namespace AutomobilePlantContracts.SearchModels
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public int? ClientId { get; set; }
- }
+ public int? ImplementerId { get; set; }
+ public OrderStatus? Status { get; set; }
+ }
}
diff --git a/AutomobilePlantContracts/StorageContracts/IImplementerStorage.cs b/AutomobilePlantContracts/StorageContracts/IImplementerStorage.cs
new file mode 100644
index 0000000..88d8362
--- /dev/null
+++ b/AutomobilePlantContracts/StorageContracts/IImplementerStorage.cs
@@ -0,0 +1,26 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.StorageContracts
+{
+ 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/AutomobilePlantContracts/ViewModels/ImplementerViewModel.cs b/AutomobilePlantContracts/ViewModels/ImplementerViewModel.cs
new file mode 100644
index 0000000..3fa40fc
--- /dev/null
+++ b/AutomobilePlantContracts/ViewModels/ImplementerViewModel.cs
@@ -0,0 +1,27 @@
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantContracts.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/AutomobilePlantContracts/ViewModels/OrderViewModel.cs b/AutomobilePlantContracts/ViewModels/OrderViewModel.cs
index 3f6ad9f..c2280f3 100644
--- a/AutomobilePlantContracts/ViewModels/OrderViewModel.cs
+++ b/AutomobilePlantContracts/ViewModels/OrderViewModel.cs
@@ -19,6 +19,9 @@ namespace AutomobilePlantContracts.ViewModels
public int ClientId { get; set; }
[DisplayName("ФИО клиента")]
public string ClientFIO { get; set; } = string.Empty;
+ public int? ImplementerId { get; set; }
+ [DisplayName("ФИО исполнителя")]
+ public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Количество")]
public int Count { get; set; }
diff --git a/AutomobilePlantDataModels/Models/IImplementerModel.cs b/AutomobilePlantDataModels/Models/IImplementerModel.cs
new file mode 100644
index 0000000..5514a6f
--- /dev/null
+++ b/AutomobilePlantDataModels/Models/IImplementerModel.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantDataModels.Models
+{
+ public interface IImplementerModel : IId
+ {
+ string ImplementerFIO { get; }
+ string Password { get; }
+ int WorkExperience { get; }
+ int Qualification { get; }
+ }
+}
diff --git a/AutomobilePlantDataModels/Models/IOrderModel.cs b/AutomobilePlantDataModels/Models/IOrderModel.cs
index cbfaf43..19b1c72 100644
--- a/AutomobilePlantDataModels/Models/IOrderModel.cs
+++ b/AutomobilePlantDataModels/Models/IOrderModel.cs
@@ -12,6 +12,7 @@ namespace AutomobilePlantDataModels.Models
{
int CarId { get; }
int ClientId { get; }
+ int? ImplementerId { get; }
int Count { get; }
double Sum { get; }
OrderStatus Status { get; }
diff --git a/AutomobilePlantDatabaseImplement/AutomobilePlantDatabase.cs b/AutomobilePlantDatabaseImplement/AutomobilePlantDatabase.cs
index b3996d4..d849bab 100644
--- a/AutomobilePlantDatabaseImplement/AutomobilePlantDatabase.cs
+++ b/AutomobilePlantDatabaseImplement/AutomobilePlantDatabase.cs
@@ -16,7 +16,7 @@ namespace AutomobilePlantDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
- optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-50UQ1O1\MSSQLSERVER01;Initial Catalog=RenovationWorkDatabase1;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
+ optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-50UQ1O1\MSSQLSERVER01;Initial Catalog=RenovationWorkDatabase3;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
@@ -25,5 +25,6 @@ namespace AutomobilePlantDatabaseImplement
public virtual DbSet CarComponents { set; get; }
public virtual DbSet Orders { set; get; }
public virtual DbSet Clients { set; get; }
+ public virtual DbSet Implementers { set; get; }
}
}
diff --git a/AutomobilePlantDatabaseImplement/Implements/ImplementerStorage.cs b/AutomobilePlantDatabaseImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..5df55bf
--- /dev/null
+++ b/AutomobilePlantDatabaseImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,84 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StorageContracts;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDatabaseImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantDatabaseImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ using var context = new AutomobilePlantDatabase();
+ if (model.Id.HasValue) return context.Implementers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
+ if (model.ImplementerFIO != null && model.Password != null) return context.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))?.GetViewModel;
+ if (model.ImplementerFIO != null) return context.Implementers.FirstOrDefault(x => x.ImplementerFIO.Equals(model.ImplementerFIO))?.GetViewModel;
+ return null;
+ }
+
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ if (model == null)
+ {
+ return new();
+ }
+ if (model.ImplementerFIO != null)
+ {
+ using var context = new AutomobilePlantDatabase();
+ return context.Implementers
+ .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return new();
+ }
+
+ public List GetFullList()
+ {
+ using var context = new AutomobilePlantDatabase();
+ return context.Implementers.Select(x => x.GetViewModel).ToList();
+ }
+
+ public ImplementerViewModel? Insert(ImplementerBindingModel model)
+ {
+ using var context = new AutomobilePlantDatabase();
+ var res = Implementer.Create(model);
+ if (res != null)
+ {
+ context.Implementers.Add(res);
+ context.SaveChanges();
+ }
+ return res?.GetViewModel;
+ }
+
+ public ImplementerViewModel? Update(ImplementerBindingModel model)
+ {
+ using var context = new AutomobilePlantDatabase();
+ var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
+ if (res != null)
+ {
+ res.Update(model);
+ context.SaveChanges();
+ }
+ return res?.GetViewModel;
+ }
+
+ public ImplementerViewModel? Delete(ImplementerBindingModel model)
+ {
+ using var context = new AutomobilePlantDatabase();
+ var res = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
+ if (res != null)
+ {
+ context.Implementers.Remove(res);
+ context.SaveChanges();
+ }
+ return res?.GetViewModel;
+ }
+ }
+}
diff --git a/AutomobilePlantDatabaseImplement/Implements/OrderStorage.cs b/AutomobilePlantDatabaseImplement/Implements/OrderStorage.cs
index 0e0928c..4f7ce35 100644
--- a/AutomobilePlantDatabaseImplement/Implements/OrderStorage.cs
+++ b/AutomobilePlantDatabaseImplement/Implements/OrderStorage.cs
@@ -16,43 +16,58 @@ namespace AutomobilePlantDatabaseImplement.Implements
{
public OrderViewModel? GetElement(OrderSearchModel model)
{
- if (!model.Id.HasValue)
- {
- return null;
- }
using var context = new AutomobilePlantDatabase();
- return context.Orders.Include(x => x.Car).Include(x => x.Client).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
- }
+ return context.Orders
+ .Include(x => x.Car)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .FirstOrDefault(x =>
+ (model.Status == null || model.Status != null && model.Status.Equals(x.Status)) &&
+ model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId ||
+ model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
+ }
public List GetFilteredList(OrderSearchModel model)
{
- if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
- {
+ if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
+ {
return new();
}
using var context = new AutomobilePlantDatabase();
if (model.ClientId.HasValue)
{
return context.Orders
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
.Include(x => x.Car)
- .Include(x => x.Client)
- .Where(x => x.ClientId == model.ClientId)
+ .Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
+ }
+ if (model.Status != null)
+ {
+ return context.Orders
+ .Include(x => x.Car)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .Where(x => model.Status.Equals(x.Status))
+ .Select(x => x.GetViewModel)
+ .ToList();
}
return context.Orders
- .Include(x => x.Client)
- .Include(x => x.Car)
- .Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
- .Select(x => x.GetViewModel)
- .ToList();
+ .Include(x => x.Car)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
+ .Select(x => x.GetViewModel)
+ .ToList();
}
public List GetFullList()
{
using var context = new AutomobilePlantDatabase();
- return context.Orders.Include(x => x.Car).Include(x => x.Client).Select(x => x.GetViewModel).ToList();
- }
+ return context.Orders.Include(x => x.Car).Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
+ }
public OrderViewModel? Insert(OrderBindingModel model)
{
@@ -64,7 +79,7 @@ namespace AutomobilePlantDatabaseImplement.Implements
using var context = new AutomobilePlantDatabase();
context.Orders.Add(newOrder);
context.SaveChanges();
- return context.Orders.Include(x => x.Car).Include(x => x.Client).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
+ return context.Orders.Include(x => x.Car).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
@@ -77,12 +92,16 @@ namespace AutomobilePlantDatabaseImplement.Implements
}
order.Update(model);
context.SaveChanges();
- return context.Orders.Include(x => x.Car).Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
- }
+ return context.Orders.Include(x => x.Car).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
+ }
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new AutomobilePlantDatabase();
- var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
+ var element = context.Orders
+ .Include(x => x.Car)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
context.Orders.Remove(element);
diff --git a/AutomobilePlantDatabaseImplement/Migrations/20240515070446_InitialCreate.Designer.cs b/AutomobilePlantDatabaseImplement/Migrations/20240515070446_InitialCreate.Designer.cs
new file mode 100644
index 0000000..fa7c414
--- /dev/null
+++ b/AutomobilePlantDatabaseImplement/Migrations/20240515070446_InitialCreate.Designer.cs
@@ -0,0 +1,257 @@
+//
+using System;
+using AutomobilePlantDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace AutomobilePlantDatabaseImplement.Migrations
+{
+ [DbContext(typeof(AutomobilePlantDatabase))]
+ [Migration("20240515070446_InitialCreate")]
+ partial class InitialCreate
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Car", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("CarName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Price")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.ToTable("Cars");
+ });
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.CarComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("CarId")
+ .HasColumnType("int");
+
+ b.Property("ComponentId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CarId");
+
+ b.HasIndex("ComponentId");
+
+ b.ToTable("CarComponents");
+ });
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.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("AutomobilePlantDatabaseImplement.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("AutomobilePlantDatabaseImplement.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("AutomobilePlantDatabaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("CarId")
+ .HasColumnType("int");
+
+ b.Property("ClientId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("DateCreate")
+ .HasColumnType("datetime2");
+
+ b.Property("DateImplement")
+ .HasColumnType("datetime2");
+
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("Sum")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CarId");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("ImplementerId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.CarComponent", b =>
+ {
+ b.HasOne("AutomobilePlantDatabaseImplement.Models.Car", "Car")
+ .WithMany("Components")
+ .HasForeignKey("CarId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AutomobilePlantDatabaseImplement.Models.Component", "Component")
+ .WithMany("CarComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Car");
+
+ b.Navigation("Component");
+ });
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("AutomobilePlantDatabaseImplement.Models.Car", "Car")
+ .WithMany("Orders")
+ .HasForeignKey("CarId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AutomobilePlantDatabaseImplement.Models.Client", "Client")
+ .WithMany("Orders")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AutomobilePlantDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
+ b.Navigation("Car");
+
+ b.Navigation("Client");
+
+ b.Navigation("Implementer");
+ });
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Car", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Client", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Component", b =>
+ {
+ b.Navigation("CarComponents");
+ });
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/AutomobilePlantDatabaseImplement/Migrations/20240515070446_InitialCreate.cs b/AutomobilePlantDatabaseImplement/Migrations/20240515070446_InitialCreate.cs
new file mode 100644
index 0000000..185611f
--- /dev/null
+++ b/AutomobilePlantDatabaseImplement/Migrations/20240515070446_InitialCreate.cs
@@ -0,0 +1,185 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace AutomobilePlantDatabaseImplement.Migrations
+{
+ ///
+ public partial class InitialCreate : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Cars",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ CarName = table.Column(type: "nvarchar(max)", nullable: false),
+ Price = table.Column(type: "float", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Cars", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Clients",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ClientFIO = table.Column(type: "nvarchar(max)", nullable: false),
+ Email = table.Column(type: "nvarchar(max)", nullable: false),
+ Password = table.Column(type: "nvarchar(max)", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Clients", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Components",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ComponentName = table.Column(type: "nvarchar(max)", nullable: false),
+ Cost = table.Column(type: "float", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Components", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Implementers",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false),
+ Password = table.Column(type: "nvarchar(max)", nullable: false),
+ WorkExperience = table.Column(type: "int", nullable: false),
+ Qualification = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Implementers", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "CarComponents",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ CarId = table.Column(type: "int", nullable: false),
+ ComponentId = table.Column(type: "int", nullable: false),
+ Count = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_CarComponents", x => x.Id);
+ table.ForeignKey(
+ name: "FK_CarComponents_Cars_CarId",
+ column: x => x.CarId,
+ principalTable: "Cars",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_CarComponents_Components_ComponentId",
+ column: x => x.ComponentId,
+ principalTable: "Components",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Orders",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ CarId = table.Column(type: "int", nullable: false),
+ ClientId = table.Column(type: "int", nullable: false),
+ ImplementerId = table.Column(type: "int", nullable: true),
+ Count = table.Column(type: "int", nullable: false),
+ Sum = table.Column(type: "float", nullable: false),
+ Status = table.Column(type: "int", nullable: false),
+ DateCreate = table.Column(type: "datetime2", nullable: false),
+ DateImplement = table.Column(type: "datetime2", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Orders", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Orders_Cars_CarId",
+ column: x => x.CarId,
+ principalTable: "Cars",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Orders_Clients_ClientId",
+ column: x => x.ClientId,
+ principalTable: "Clients",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ column: x => x.ImplementerId,
+ principalTable: "Implementers",
+ principalColumn: "Id");
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_CarComponents_CarId",
+ table: "CarComponents",
+ column: "CarId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_CarComponents_ComponentId",
+ table: "CarComponents",
+ column: "ComponentId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_CarId",
+ table: "Orders",
+ column: "CarId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_ClientId",
+ table: "Orders",
+ column: "ClientId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "CarComponents");
+
+ migrationBuilder.DropTable(
+ name: "Orders");
+
+ migrationBuilder.DropTable(
+ name: "Components");
+
+ migrationBuilder.DropTable(
+ name: "Cars");
+
+ migrationBuilder.DropTable(
+ name: "Clients");
+
+ migrationBuilder.DropTable(
+ name: "Implementers");
+ }
+ }
+}
diff --git a/AutomobilePlantDatabaseImplement/Migrations/AutomobilePlantDatabaseModelSnapshot.cs b/AutomobilePlantDatabaseImplement/Migrations/AutomobilePlantDatabaseModelSnapshot.cs
index 776efb3..62892a7 100644
--- a/AutomobilePlantDatabaseImplement/Migrations/AutomobilePlantDatabaseModelSnapshot.cs
+++ b/AutomobilePlantDatabaseImplement/Migrations/AutomobilePlantDatabaseModelSnapshot.cs
@@ -113,6 +113,33 @@ namespace AutomobilePlantDatabaseImplement.Migrations
b.ToTable("Components");
});
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.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("AutomobilePlantDatabaseImplement.Models.Order", b =>
{
b.Property("Id")
@@ -136,6 +163,9 @@ namespace AutomobilePlantDatabaseImplement.Migrations
b.Property("DateImplement")
.HasColumnType("datetime2");
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
b.Property("Status")
.HasColumnType("int");
@@ -148,6 +178,8 @@ namespace AutomobilePlantDatabaseImplement.Migrations
b.HasIndex("ClientId");
+ b.HasIndex("ImplementerId");
+
b.ToTable("Orders");
});
@@ -184,9 +216,15 @@ namespace AutomobilePlantDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.HasOne("AutomobilePlantDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
b.Navigation("Car");
b.Navigation("Client");
+
+ b.Navigation("Implementer");
});
modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Car", b =>
@@ -205,6 +243,11 @@ namespace AutomobilePlantDatabaseImplement.Migrations
{
b.Navigation("CarComponents");
});
+
+ modelBuilder.Entity("AutomobilePlantDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
#pragma warning restore 612, 618
}
}
diff --git a/AutomobilePlantDatabaseImplement/Models/Implementer.cs b/AutomobilePlantDatabaseImplement/Models/Implementer.cs
new file mode 100644
index 0000000..03130c4
--- /dev/null
+++ b/AutomobilePlantDatabaseImplement/Models/Implementer.cs
@@ -0,0 +1,65 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantDatabaseImplement.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; }
+
+ [ForeignKey("ImplementerId")]
+ public virtual List Orders { get; private set; } = new();
+
+ public static Implementer? Create(ImplementerBindingModel model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new()
+ {
+ Id = model.Id,
+ ImplementerFIO = model.ImplementerFIO,
+ Password = model.Password,
+ Qualification = model.Qualification,
+ WorkExperience = model.WorkExperience,
+ };
+ }
+
+ public void Update(ImplementerBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ImplementerFIO = model.ImplementerFIO;
+ Password = model.Password;
+ Qualification = model.Qualification;
+ WorkExperience = model.WorkExperience;
+ }
+
+ public ImplementerViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ImplementerFIO = ImplementerFIO,
+ Password = Password,
+ Qualification = Qualification,
+ WorkExperience = WorkExperience,
+ };
+ }
+}
diff --git a/AutomobilePlantDatabaseImplement/Models/Order.cs b/AutomobilePlantDatabaseImplement/Models/Order.cs
index 58593c0..ac02953 100644
--- a/AutomobilePlantDatabaseImplement/Models/Order.cs
+++ b/AutomobilePlantDatabaseImplement/Models/Order.cs
@@ -21,6 +21,7 @@ namespace AutomobilePlantDatabaseImplement.Models
[Required]
public int ClientId { get; private set; }
+ public int? ImplementerId { get; private set; }
[Required]
public int Count { get; private set; }
[Required]
@@ -33,6 +34,7 @@ namespace AutomobilePlantDatabaseImplement.Models
public DateTime? DateImplement { get; private set; }
public virtual Car Car { get; private set; }
public virtual Client Client { get; set; }
+ public Implementer? Implementer { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
@@ -44,6 +46,7 @@ namespace AutomobilePlantDatabaseImplement.Models
{
CarId = model.CarId,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@@ -61,6 +64,7 @@ namespace AutomobilePlantDatabaseImplement.Models
}
Status = model.Status;
DateImplement = model.DateImplement;
+ ImplementerId = model.ImplementerId;
}
public OrderViewModel GetViewModel
@@ -72,15 +76,17 @@ namespace AutomobilePlantDatabaseImplement.Models
CarId = CarId,
ClientId = ClientId,
+ ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
DateCreate = DateCreate,
DateImplement = DateImplement,
Id = Id,
Status = Status,
- CarName = Car.CarName,
- ClientFIO = Client.ClientFIO
- };
+ CarName = Car?.CarName ?? string.Empty,
+ ClientFIO = Client?.ClientFIO ?? string.Empty,
+ ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
+ };
}
}
}
diff --git a/AutomobilePlantFileImplement/DataFileSingleton.cs b/AutomobilePlantFileImplement/DataFileSingleton.cs
index cb0aa57..d32c775 100644
--- a/AutomobilePlantFileImplement/DataFileSingleton.cs
+++ b/AutomobilePlantFileImplement/DataFileSingleton.cs
@@ -17,10 +17,12 @@ namespace AutomobilePlantFileImplement
private readonly string OrderFileName = "Order.xml";
private readonly string CarFileName = "Car.xml";
private readonly string ClientFileName = "Client.xml";
+ private readonly string ImplementerFileName = "Implementer.xml";
public List Components { get; private set; }
public List Orders { get; private set; }
public List Cars { get; private set; }
public List Clients { get; private set; }
+ public List Implementers { get; private set; }
public static DataFileSingleton GetInstance()
{
if (instance == null)
@@ -33,12 +35,14 @@ namespace AutomobilePlantFileImplement
public void SaveCars() => SaveData(Cars, CarFileName, "Cars", 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(Orders, ImplementerFileName, "Implementers", x => x.GetXElement);
private DataFileSingleton()
{
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
Cars = LoadData(CarFileName, "Car", x => Car.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
+ Implementers = LoadData(ImplementerFileName, "Impleneter", x => Implementer.Create(x)!)!;
}
private static List? LoadData(string filename, string xmlNodeName, Func selectFunction)
{
diff --git a/AutomobilePlantFileImplement/Implements/ImplementerStorage.cs b/AutomobilePlantFileImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..c9bc28b
--- /dev/null
+++ b/AutomobilePlantFileImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,84 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StorageContracts;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantFileImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantFileImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ private readonly DataFileSingleton _source;
+ public ImplementerStorage()
+ {
+ _source = DataFileSingleton.GetInstance();
+ }
+ 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 List GetFilteredList(ImplementerSearchModel model)
+ {
+ if (model == null)
+ {
+ return new();
+ }
+ if (model.ImplementerFIO != null)
+ {
+ return _source.Implementers
+ .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return new();
+ }
+
+ public List GetFullList()
+ {
+ return _source.Implementers.Select(x => x.GetViewModel).ToList();
+ }
+
+ 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/AutomobilePlantFileImplement/Implements/OrderStorage.cs b/AutomobilePlantFileImplement/Implements/OrderStorage.cs
index dd45167..57688b5 100644
--- a/AutomobilePlantFileImplement/Implements/OrderStorage.cs
+++ b/AutomobilePlantFileImplement/Implements/OrderStorage.cs
@@ -22,18 +22,22 @@ namespace AutomobilePlantFileImplement.Implements
public OrderViewModel? GetElement(OrderSearchModel model)
{
+ if (model.ImplementerId.HasValue && model.Status != null) return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Status.Equals(x.Status))?.GetViewModel;
+ if (model.ImplementerId.HasValue)
+ {
+ return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
+ }
if (!model.Id.HasValue)
{
return null;
}
- return GetViewModel(source.Orders
- .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
+ return GetViewModel(source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
}
public List GetFilteredList(OrderSearchModel model)
{
- if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
- {
+ if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
+ {
return new();
}
if (model.ClientId.HasValue)
@@ -42,6 +46,13 @@ namespace AutomobilePlantFileImplement.Implements
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
+ }
+ if (model.Status != null)
+ {
+ return source.Orders
+ .Where(x => model.Status.Equals(x.Status))
+ .Select(x => x.GetViewModel)
+ .ToList();
}
return source.Orders
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
diff --git a/AutomobilePlantFileImplement/Models/Implementer.cs b/AutomobilePlantFileImplement/Models/Implementer.cs
new file mode 100644
index 0000000..efb1577
--- /dev/null
+++ b/AutomobilePlantFileImplement/Models/Implementer.cs
@@ -0,0 +1,85 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace AutomobilePlantFileImplement.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()
+ {
+ Id = Convert.ToInt32(element.Attribute("Id")!.Value),
+ ImplementerFIO = element.Element("FIO")!.Value,
+ Password = element.Element("Password")!.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,
+ ImplementerFIO = model.ImplementerFIO,
+ Password = model.Password,
+ Qualification = model.Qualification,
+ WorkExperience = model.WorkExperience,
+ };
+ }
+
+ public void Update(ImplementerBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ImplementerFIO = model.ImplementerFIO;
+ Password = model.Password;
+ Qualification = model.Qualification;
+ WorkExperience = model.WorkExperience;
+ }
+
+ public ImplementerViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ImplementerFIO = ImplementerFIO,
+ Password = Password,
+ Qualification = Qualification,
+ };
+
+ public XElement GetXElement => new("Client",
+ new XAttribute("Id", Id),
+ new XElement("FIO", ImplementerFIO),
+ new XElement("Password", Password),
+ new XElement("Qualification", Qualification),
+ new XElement("WorkExperience", WorkExperience)
+ );
+ }
+}
diff --git a/AutomobilePlantFileImplement/Models/Order.cs b/AutomobilePlantFileImplement/Models/Order.cs
index 4ebebc1..5e179aa 100644
--- a/AutomobilePlantFileImplement/Models/Order.cs
+++ b/AutomobilePlantFileImplement/Models/Order.cs
@@ -15,6 +15,7 @@ namespace AutomobilePlantFileImplement.Models
{
public int CarId { get; private set; }
public int ClientId { get; set; }
+ public int? ImplementerId { get; set; }
public int Count { get; private set; }
@@ -38,6 +39,7 @@ namespace AutomobilePlantFileImplement.Models
{
CarId = model.CarId,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@@ -58,6 +60,7 @@ namespace AutomobilePlantFileImplement.Models
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
CarId = Convert.ToInt32(element.Element("CarId")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
+ ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
@@ -74,12 +77,15 @@ namespace AutomobilePlantFileImplement.Models
}
Status = model.Status;
DateImplement = model.DateImplement;
+ ImplementerId = model.ImplementerId;
}
public OrderViewModel GetViewModel => new()
{
CarId = CarId,
ClientId = ClientId,
+ ImplementerId = ImplementerId,
+ ImplementerFIO = DataFileSingleton.GetInstance().Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
Count = Count,
Sum = Sum,
DateCreate = DateCreate,
@@ -93,6 +99,7 @@ namespace AutomobilePlantFileImplement.Models
new XAttribute("Id", Id),
new XElement("CarId", CarId.ToString()),
new XElement("ClientId", ClientId),
+ new XElement("ImplementerId", ImplementerId),
new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),
diff --git a/AutomobilePlantListImplements/DataListSingleton.cs b/AutomobilePlantListImplements/DataListSingleton.cs
index 1fc9010..6bfd6a5 100644
--- a/AutomobilePlantListImplements/DataListSingleton.cs
+++ b/AutomobilePlantListImplements/DataListSingleton.cs
@@ -9,12 +9,14 @@ namespace AutomobilePlantListImplements
public List Orders { get; set; }
public List Cars { get; set; }
public List Clients { get; set; }
+ public List Implementers { get; set; }
private DataListSingleton()
{
Components = new List();
Orders = new List();
Cars = new List();
Clients = new List();
+ Implementers = new List();
}
public static DataListSingleton GetInstance()
{
diff --git a/AutomobilePlantListImplements/Implements/ImplementerStorage.cs b/AutomobilePlantListImplements/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..890e5f3
--- /dev/null
+++ b/AutomobilePlantListImplements/Implements/ImplementerStorage.cs
@@ -0,0 +1,111 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.StorageContracts;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantListImplements.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplements.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ private readonly DataListSingleton _source;
+ public ImplementerStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ 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();
+ }
+ List list = new();
+ if (model.ImplementerFIO != null)
+ {
+ foreach (var implementer in _source.Implementers)
+ {
+ if (implementer.ImplementerFIO.Contains(model.ImplementerFIO))
+ {
+ list.Add(implementer.GetViewModel);
+ }
+ }
+ }
+ return list;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+ }
+}
diff --git a/AutomobilePlantListImplements/Implements/OrderStorage.cs b/AutomobilePlantListImplements/Implements/OrderStorage.cs
index 384d578..ea89bd9 100644
--- a/AutomobilePlantListImplements/Implements/OrderStorage.cs
+++ b/AutomobilePlantListImplements/Implements/OrderStorage.cs
@@ -29,6 +29,14 @@ namespace AutomobilePlantListImplements.Implements
foreach (var order in _source.Orders)
{
if (model.Id.HasValue && order.Id == model.Id)
+ {
+ return GetViewModel(order);
+ }
+ else if (model.ImplementerId.HasValue && model.Status != null && order.ImplementerId == model.ImplementerId && model.Status.Equals(order.Status))
+ {
+ return GetViewModel(order);
+ }
+ else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId)
{
return GetViewModel(order);
}
@@ -59,6 +67,26 @@ namespace AutomobilePlantListImplements.Implements
}
}
}
+ if (model.ImplementerId.HasValue)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.ImplementerId == model.ImplementerId)
+ {
+ result.Add(GetViewModel(order));
+ }
+ }
+ }
+ if (model.Status != null)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (model.Status.Equals(order.Status))
+ {
+ result.Add(GetViewModel(order));
+ }
+ }
+ }
return result;
}
diff --git a/AutomobilePlantListImplements/Models/Implementer.cs b/AutomobilePlantListImplements/Models/Implementer.cs
new file mode 100644
index 0000000..2fc589e
--- /dev/null
+++ b/AutomobilePlantListImplements/Models/Implementer.cs
@@ -0,0 +1,60 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AutomobilePlantListImplements.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/AutomobilePlantListImplements/Models/Order.cs b/AutomobilePlantListImplements/Models/Order.cs
index 3a07c82..8b375e2 100644
--- a/AutomobilePlantListImplements/Models/Order.cs
+++ b/AutomobilePlantListImplements/Models/Order.cs
@@ -14,6 +14,7 @@ namespace AutomobilePlantListImplements.Models
{
public int CarId { get; private set; }
public int ClientId { get; private set; }
+ public int? ImplementerId { get; private set; }
public int Count { get; private set; }
@@ -37,6 +38,7 @@ namespace AutomobilePlantListImplements.Models
{
CarId = model.CarId,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@@ -54,6 +56,7 @@ namespace AutomobilePlantListImplements.Models
}
Status = model.Status;
DateImplement = model.DateImplement;
+ ImplementerId = model.ImplementerId;
}
public OrderViewModel GetViewModel => new()
@@ -64,6 +67,8 @@ namespace AutomobilePlantListImplements.Models
Sum = Sum,
DateCreate = DateCreate,
DateImplement = DateImplement,
+ ImplementerId = ImplementerId,
+ ImplementerFIO = DataListSingleton.GetInstance().Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
Id = Id,
Status = Status,
};
diff --git a/AutomobilePlantRestApi/Controllers/ImplementerController.cs b/AutomobilePlantRestApi/Controllers/ImplementerController.cs
new file mode 100644
index 0000000..81b68bd
--- /dev/null
+++ b/AutomobilePlantRestApi/Controllers/ImplementerController.cs
@@ -0,0 +1,106 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicContracts;
+using AutomobilePlantContracts.SearchModels;
+using AutomobilePlantContracts.ViewModels;
+using AutomobilePlantDataModels.Enums;
+using Microsoft.AspNetCore.Mvc;
+
+namespace AutomobilePlantRestApi.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;
+ }
+ }
+ }
+}