diff --git a/FishFactory/FishFactory/FormCreateOrder.cs b/FishFactory/FishFactory/FormCreateOrder.cs
index 263dcef..ae92afd 100644
--- a/FishFactory/FishFactory/FormCreateOrder.cs
+++ b/FishFactory/FishFactory/FormCreateOrder.cs
@@ -105,7 +105,7 @@ namespace FishFactoryView
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
- _logger.LogInformation("Создание заказа");
+ _logger.LogInformation("Создание заказа");
try
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
@@ -126,8 +126,7 @@ namespace FishFactoryView
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
diff --git a/FishFactory/FishFactory/FormImplementer.Designer.cs b/FishFactory/FishFactory/FormImplementer.Designer.cs
new file mode 100644
index 0000000..bb96438
--- /dev/null
+++ b/FishFactory/FishFactory/FormImplementer.Designer.cs
@@ -0,0 +1,181 @@
+namespace FishFactoryView
+{
+ 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.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.textBoxFio = new System.Windows.Forms.TextBox();
+ this.textBoxPassword = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.textBoxStage = new System.Windows.Forms.TextBox();
+ this.textBoxCval = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(7, 23);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(45, 20);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "ФИО:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(7, 61);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(65, 20);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Пароль:";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(7, 100);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(102, 20);
+ this.label3.TabIndex = 2;
+ this.label3.Text = "Стаж работы:";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(203, 100);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(114, 20);
+ this.label4.TabIndex = 3;
+ this.label4.Text = "Квалификация:";
+ //
+ // textBoxFio
+ //
+ this.textBoxFio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxFio.Location = new System.Drawing.Point(107, 12);
+ this.textBoxFio.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.textBoxFio.Name = "textBoxFio";
+ this.textBoxFio.Size = new System.Drawing.Size(339, 27);
+ this.textBoxFio.TabIndex = 4;
+ //
+ // textBoxPassword
+ //
+ this.textBoxPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxPassword.Location = new System.Drawing.Point(107, 51);
+ this.textBoxPassword.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.textBoxPassword.Name = "textBoxPassword";
+ this.textBoxPassword.PasswordChar = '*';
+ this.textBoxPassword.Size = new System.Drawing.Size(339, 27);
+ this.textBoxPassword.TabIndex = 5;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonCancel.Location = new System.Drawing.Point(345, 128);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(102, 44);
+ this.buttonCancel.TabIndex = 8;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonSave.Location = new System.Drawing.Point(237, 128);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(102, 44);
+ this.buttonSave.TabIndex = 9;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // textBoxStage
+ //
+ this.textBoxStage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxStage.Location = new System.Drawing.Point(107, 89);
+ this.textBoxStage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.textBoxStage.Name = "textBoxStage";
+ this.textBoxStage.Size = new System.Drawing.Size(81, 27);
+ this.textBoxStage.TabIndex = 10;
+ //
+ // textBoxCval
+ //
+ this.textBoxCval.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxCval.Location = new System.Drawing.Point(314, 89);
+ this.textBoxCval.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.textBoxCval.Name = "textBoxCval";
+ this.textBoxCval.Size = new System.Drawing.Size(132, 27);
+ this.textBoxCval.TabIndex = 11;
+ //
+ // FormImplementer
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSize = true;
+ this.ClientSize = new System.Drawing.Size(461, 232);
+ this.Controls.Add(this.textBoxCval);
+ this.Controls.Add(this.textBoxStage);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxPassword);
+ this.Controls.Add(this.textBoxFio);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.Name = "FormImplementer";
+ this.Text = "Исполнитель";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private Label label3;
+ private Label label4;
+ private TextBox textBoxFio;
+ private TextBox textBoxPassword;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private TextBox textBoxStage;
+ private TextBox textBoxCval;
+ }
+}
\ No newline at end of file
diff --git a/FishFactory/FishFactory/FormImplementer.cs b/FishFactory/FishFactory/FormImplementer.cs
new file mode 100644
index 0000000..0be8c4b
--- /dev/null
+++ b/FishFactory/FishFactory/FormImplementer.cs
@@ -0,0 +1,108 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.BusinessLogicsContracts;
+using FishFactoryContracts.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 FishFactoryView
+{
+ 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;
+ textBoxStage.Text = view.Qualification.ToString();
+ textBoxCval.Text = view.WorkExperience.ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения исполнителя");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(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,
+ WorkExperience = Convert.ToInt32(textBoxStage.Text),
+ Qualification = Convert.ToInt32(textBoxCval.Text),
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения исполнителя");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/FishFactory/FishFactory/FormImplementer.resx b/FishFactory/FishFactory/FormImplementer.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FishFactory/FishFactory/FormImplementer.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FishFactory/FishFactory/FormImplementers.Designer.cs b/FishFactory/FishFactory/FormImplementers.Designer.cs
new file mode 100644
index 0000000..0d5b67e
--- /dev/null
+++ b/FishFactory/FishFactory/FormImplementers.Designer.cs
@@ -0,0 +1,128 @@
+namespace FishFactoryView
+{
+ 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.buttonRef = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonRef
+ //
+ this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRef.Location = new System.Drawing.Point(657, 169);
+ this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(103, 49);
+ this.buttonRef.TabIndex = 9;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDel.Location = new System.Drawing.Point(657, 117);
+ this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(103, 44);
+ this.buttonDel.TabIndex = 8;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUpd.Location = new System.Drawing.Point(657, 64);
+ this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(103, 45);
+ this.buttonUpd.TabIndex = 7;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonAdd.Location = new System.Drawing.Point(657, 16);
+ this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(103, 40);
+ this.buttonAdd.TabIndex = 6;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(14, 16);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(637, 403);
+ this.dataGridView.TabIndex = 5;
+ //
+ // FormImplementers
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(774, 425);
+ this.Controls.Add(this.buttonRef);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ 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 buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/FishFactory/FishFactory/FormImplementers.cs b/FishFactory/FishFactory/FormImplementers.cs
new file mode 100644
index 0000000..141e142
--- /dev/null
+++ b/FishFactory/FishFactory/FormImplementers.cs
@@ -0,0 +1,112 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using ProjectFishFactory;
+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 FishFactoryView
+{
+ 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 ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
+ if (service is FormImplementer form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
+ if (service is FormImplementer form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление исполнителя");
+ try
+ {
+ if (!_logic.Delete(new ImplementerBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления исполнителя");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/FishFactory/FishFactory/FormImplementers.resx b/FishFactory/FishFactory/FormImplementers.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FishFactory/FishFactory/FormImplementers.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FishFactory/FishFactory/FormMain.Designer.cs b/FishFactory/FishFactory/FormMain.Designer.cs
index de191e5..210a313 100644
--- a/FishFactory/FishFactory/FormMain.Designer.cs
+++ b/FishFactory/FishFactory/FormMain.Designer.cs
@@ -30,8 +30,6 @@
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ButtonCreateOrder = new System.Windows.Forms.Button();
- this.ButtonTakeOrderInWork = new System.Windows.Forms.Button();
- this.ButtonOrderReady = new System.Windows.Forms.Button();
this.ButtonIssuedOrder = new System.Windows.Forms.Button();
this.ButtonRef = new System.Windows.Forms.Button();
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -43,6 +41,8 @@
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();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
@@ -50,48 +50,31 @@
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 32);
+ this.dataGridView.Location = new System.Drawing.Point(14, 43);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(768, 402);
+ this.dataGridView.Size = new System.Drawing.Size(988, 536);
this.dataGridView.TabIndex = 0;
//
// ButtonCreateOrder
//
- this.ButtonCreateOrder.Location = new System.Drawing.Point(786, 32);
+ this.ButtonCreateOrder.Location = new System.Drawing.Point(1008, 43);
+ this.ButtonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ButtonCreateOrder.Name = "ButtonCreateOrder";
- this.ButtonCreateOrder.Size = new System.Drawing.Size(186, 23);
+ this.ButtonCreateOrder.Size = new System.Drawing.Size(213, 31);
this.ButtonCreateOrder.TabIndex = 1;
this.ButtonCreateOrder.Text = "Создать заказ";
this.ButtonCreateOrder.UseVisualStyleBackColor = true;
this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
//
- // ButtonTakeOrderInWork
- //
- this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(786, 83);
- this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
- this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(186, 23);
- this.ButtonTakeOrderInWork.TabIndex = 2;
- this.ButtonTakeOrderInWork.Text = "Отдать на выполнение";
- this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
- this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
- //
- // ButtonOrderReady
- //
- this.ButtonOrderReady.Location = new System.Drawing.Point(786, 137);
- this.ButtonOrderReady.Name = "ButtonOrderReady";
- this.ButtonOrderReady.Size = new System.Drawing.Size(186, 23);
- this.ButtonOrderReady.TabIndex = 3;
- this.ButtonOrderReady.Text = "Заказ готов";
- this.ButtonOrderReady.UseVisualStyleBackColor = true;
- this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
- //
// ButtonIssuedOrder
//
- this.ButtonIssuedOrder.Location = new System.Drawing.Point(786, 194);
+ this.ButtonIssuedOrder.Location = new System.Drawing.Point(1008, 117);
+ this.ButtonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
- this.ButtonIssuedOrder.Size = new System.Drawing.Size(186, 23);
+ this.ButtonIssuedOrder.Size = new System.Drawing.Size(213, 31);
this.ButtonIssuedOrder.TabIndex = 4;
this.ButtonIssuedOrder.Text = "Заказ выдан";
this.ButtonIssuedOrder.UseVisualStyleBackColor = true;
@@ -99,9 +82,10 @@
//
// ButtonRef
//
- this.ButtonRef.Location = new System.Drawing.Point(786, 250);
+ this.ButtonRef.Location = new System.Drawing.Point(1008, 192);
+ this.ButtonRef.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.ButtonRef.Name = "ButtonRef";
- this.ButtonRef.Size = new System.Drawing.Size(186, 23);
+ this.ButtonRef.Size = new System.Drawing.Size(213, 31);
this.ButtonRef.TabIndex = 5;
this.ButtonRef.Text = "Обновить список";
this.ButtonRef.UseVisualStyleBackColor = true;
@@ -113,20 +97,20 @@
this.компонентыToolStripMenuItem1,
this.консервыToolStripMenuItem});
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
- this.изделияToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
+ this.изделияToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
this.изделияToolStripMenuItem.Text = "Справочники";
//
// компонентыToolStripMenuItem1
//
this.компонентыToolStripMenuItem1.Name = "компонентыToolStripMenuItem1";
- this.компонентыToolStripMenuItem1.Size = new System.Drawing.Size(145, 22);
+ this.компонентыToolStripMenuItem1.Size = new System.Drawing.Size(182, 26);
this.компонентыToolStripMenuItem1.Text = "Компоненты";
this.компонентыToolStripMenuItem1.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
//
// консервыToolStripMenuItem
//
this.консервыToolStripMenuItem.Name = "консервыToolStripMenuItem";
- this.консервыToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
+ this.консервыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
this.консервыToolStripMenuItem.Text = "Консервы";
this.консервыToolStripMenuItem.Click += new System.EventHandler(this.КонсервыToolStripMenuItem_Click);
//
@@ -136,11 +120,13 @@
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.изделияToolStripMenuItem,
this.отчетыToolStripMenuItem,
- this.клиентыToolStripMenuItem});
+ this.клиентыToolStripMenuItem,
+ this.исполнителиToolStripMenuItem,
+ this.запускРаботToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
- this.menuStrip1.Size = new System.Drawing.Size(978, 24);
+ this.menuStrip1.Padding = new System.Windows.Forms.Padding(6, 3, 0, 3);
+ this.menuStrip1.Size = new System.Drawing.Size(1233, 30);
this.menuStrip1.TabIndex = 6;
this.menuStrip1.Text = "menuStrip1";
//
@@ -151,50 +137,63 @@
this.компонентыПоИзделиямToolStripMenuItem,
this.списокЗаказовToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
- this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
+ this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
this.отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокКомпонентовToolStripMenuItem
//
this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
- this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
+ this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.списокКомпонентовToolStripMenuItem_Click_1);
//
// компонентыПоИзделиямToolStripMenuItem
//
this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem";
- this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
+ this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.компонентыПоИзделиямToolStripMenuItem_Click_1);
//
// списокЗаказовToolStripMenuItem
//
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
- this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
+ this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click_1);
//
// клиентыToolStripMenuItem
//
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
- this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(67, 20);
+ this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(83, 24);
this.клиентыToolStripMenuItem.Text = "Клиенты";
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
//
+ // исполнителиToolStripMenuItem
+ //
+ this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
+ this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(116, 24);
+ 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);
+ //
// FormMain
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(978, 446);
+ this.ClientSize = new System.Drawing.Size(1233, 595);
this.Controls.Add(this.ButtonRef);
this.Controls.Add(this.ButtonIssuedOrder);
- this.Controls.Add(this.ButtonOrderReady);
- this.Controls.Add(this.ButtonTakeOrderInWork);
this.Controls.Add(this.ButtonCreateOrder);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
+ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FormMain";
this.Text = "Рыбный завод";
this.Load += new System.EventHandler(this.FormMain_Load);
@@ -209,8 +208,6 @@
#endregion
private DataGridView dataGridView;
private Button ButtonCreateOrder;
- private Button ButtonTakeOrderInWork;
- private Button ButtonOrderReady;
private Button ButtonIssuedOrder;
private Button ButtonRef;
private ToolStripMenuItem изделияToolStripMenuItem;
@@ -222,5 +219,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/FishFactory/FishFactory/FormMain.cs b/FishFactory/FishFactory/FormMain.cs
index 61ef7fa..beee5cb 100644
--- a/FishFactory/FishFactory/FormMain.cs
+++ b/FishFactory/FishFactory/FormMain.cs
@@ -23,12 +23,14 @@ namespace FishFactoryView
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)
{
@@ -45,8 +47,10 @@ namespace FishFactoryView
dataGridView.DataSource = list;
dataGridView.Columns["CannedId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
+ dataGridView.Columns["ImplementerId"].Visible = false;
dataGridView.Columns["CannedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка заказов");
}
@@ -81,69 +85,7 @@ namespace FishFactoryView
LoadData();
}
}
- private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
-
- _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
- try{
- var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
- { Id = id
- /*CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
- *//*CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString,*//*
- Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
- Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
- Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
- DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),*/
- });
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка передачи заказа в работу");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonOrderReady_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
- try
- {
- var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
- {
- Id = id,
- CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
- /*CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString,*/
- Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
- Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
- Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
- DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
- });
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка отметки о готовности заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
@@ -157,7 +99,6 @@ namespace FishFactoryView
{
Id = id,
CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
- /*CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString,*/
Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
@@ -222,5 +163,20 @@ namespace FishFactoryView
form.ShowDialog();
}
}
+
+ private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
+ if (service is FormImplementers form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
+ MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
}
}
diff --git a/FishFactory/FishFactory/Program.cs b/FishFactory/FishFactory/Program.cs
index 3ae4266..aefabff 100644
--- a/FishFactory/FishFactory/Program.cs
+++ b/FishFactory/FishFactory/Program.cs
@@ -41,11 +41,15 @@ namespace ProjectFishFactory
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();
@@ -61,6 +65,8 @@ namespace ProjectFishFactory
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/FishFactory/FishFactoryBusinessLogic/BusinessLogic/ImplementerLogic.cs b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/ImplementerLogic.cs
new file mode 100644
index 0000000..556c2c4
--- /dev/null
+++ b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/ImplementerLogic.cs
@@ -0,0 +1,121 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.BusinessLogicsContracts;
+using FishFactoryContracts.SearchModels;
+using FishFactoryContracts.StoragesContracts;
+using FishFactoryContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryBusinessLogic.BusinessLogic
+{
+ 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 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. ImplementerFIO:{ImplementerFIO}. Id:{ Id}", model.ImplementerFIO, model.Id);
+ var element = _implementerStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+
+ public List? ReadList(ImplementerSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model?.ImplementerFIO, model?.Id);
+ var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ public bool Update(ImplementerBindingModel model)
+ {
+ CheckModel(model);
+ if (_implementerStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ImplementerBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
+ }
+ if (model.Qualification <= 0)
+ {
+ throw new ArgumentNullException("Квалификация не может быть меньше 0", nameof(model.Qualification));
+ }
+ if (model.WorkExperience <= 0)
+ {
+ throw new ArgumentNullException("Стаж работы не модет былть меньше 0", nameof(model.WorkExperience));
+ }
+ _logger.LogInformation("Implementer. ImplementerID:{Id}. ImplementerFIO: {ImplementerFIO}. Password: { Password}. Qualification: {Qualification}. WorkExperience: {WorkExperience}", model.Id, model.ImplementerFIO, model.Password, model.Qualification, model.WorkExperience);
+ var element = _implementerStorage.GetElement(new ImplementerSearchModel
+ {
+ ImplementerFIO = model.ImplementerFIO
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Такой исполнитель уже существует");
+ }
+
+ }
+ }
+}
diff --git a/FishFactory/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs
index 5ca9656..fe058e9 100644
--- a/FishFactory/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs
+++ b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs
@@ -52,6 +52,15 @@ namespace FishFactoryBusinessLogic.BusinessLogic
return false;
}
model.Status = newStatus;
+ model.DateCreate = viewModel.DateCreate;
+ model.Sum = viewModel.Sum;
+ model.Count = viewModel.Count;
+ model.DateImplement = viewModel.DateImplement;
+ model.CannedId = viewModel.CannedId;
+ if (viewModel.ImplementerId.HasValue)
+ {
+ model.ImplementerId = viewModel.ImplementerId;
+ }
if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
else
{
@@ -118,5 +127,21 @@ namespace FishFactoryBusinessLogic.BusinessLogic
nameof(model.Sum));
}
}
+ 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;
+ }
}
}
diff --git a/FishFactory/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs
new file mode 100644
index 0000000..8958ffd
--- /dev/null
+++ b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs
@@ -0,0 +1,157 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.BusinessLogicsContracts;
+using FishFactoryContracts.SearchModels;
+using FishFactoryContracts.ViewModels;
+using FishFactoryDataModels.Enums;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryBusinessLogic.BusinessLogic
+{
+ public class WorkModeling : IWorkProcess
+ {
+ private readonly ILogger _logger;
+
+ private readonly Random _rnd;
+
+ private IOrderLogic? _orderLogic;
+
+ public WorkModeling(ILogger logger)
+ {
+ _logger = logger;
+ _rnd = new Random(1000);
+ }
+
+ public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
+ {
+ _orderLogic = orderLogic;
+ var implementers = implementerLogic.ReadList(null);
+
+ if (implementers == null)
+ {
+ _logger.LogWarning("DoWork. Implementers is null");
+ return;
+ }
+
+ var orders = _orderLogic.ReadList(new OrderSearchModel
+ {
+ Status = OrderStatus.Принят
+ });
+
+ if (orders == null || orders.Count == 0)
+ {
+ _logger.LogWarning("DoWork. Orders is null or empty");
+ return;
+ }
+
+ _logger.LogDebug("DoWork for {Count} orders", orders.Count);
+ foreach (var implementer in implementers)
+ {
+ Task.Run(() => WorkerWorkAsync(implementer, orders));
+ }
+ }
+
+ // Иммитация работы исполнителя
+ private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders)
+ {
+ if (_orderLogic == null || implementer == null)
+ {
+ return;
+ }
+
+ await RunOrderInWork(implementer);
+
+ await Task.Run(() =>
+ {
+ foreach (var order in orders)
+ {
+ try
+ {
+ _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
+
+ // пытаемся назначить заказ на исполнителя
+ _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = order.Id,
+ ImplementerId = implementer.Id
+ });
+
+ // делаем работу
+ Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
+ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
+
+ _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = order.Id,
+ });
+ // отдыхаем
+ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
+ }
+ // кто-то мог уже перехватить заказ, игнорируем ошибку
+ catch (InvalidOperationException ex)
+ {
+ _logger.LogWarning(ex, "Error try get work");
+ }
+ // заканчиваем выполнение имитации в случае иной ошибки
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while do work");
+ throw;
+ }
+ }
+ });
+ }
+
+ //Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
+ private async Task RunOrderInWork(ImplementerViewModel implementer)
+ {
+ if (_orderLogic == null || implementer == null)
+ {
+ return;
+ }
+
+ try
+ {
+ var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
+ {
+ ImplementerId = implementer.Id,
+ Status = OrderStatus.Выполняется
+ }));
+
+ if (runOrder == null)
+ {
+ return;
+ }
+
+ _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
+
+ // доделываем работу
+ Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
+
+ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
+
+ _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = runOrder.Id
+ });
+ // отдыхаем
+ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
+ }
+ // заказа может не быть, просто игнорируем ошибку
+ catch (InvalidOperationException ex)
+ {
+ _logger.LogWarning(ex, "Error try get work");
+ }
+ // а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while do work");
+ throw;
+ }
+ }
+ }
+}
diff --git a/FishFactory/FishFactoryContracts/BindingModels/ImplementerBindingModel.cs b/FishFactory/FishFactoryContracts/BindingModels/ImplementerBindingModel.cs
new file mode 100644
index 0000000..1530f79
--- /dev/null
+++ b/FishFactory/FishFactoryContracts/BindingModels/ImplementerBindingModel.cs
@@ -0,0 +1,18 @@
+using FishFactoryDataModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryContracts.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/FishFactory/FishFactoryContracts/BindingModels/OrderBindingModel.cs b/FishFactory/FishFactoryContracts/BindingModels/OrderBindingModel.cs
index 73975ee..232dfe8 100644
--- a/FishFactory/FishFactoryContracts/BindingModels/OrderBindingModel.cs
+++ b/FishFactory/FishFactoryContracts/BindingModels/OrderBindingModel.cs
@@ -13,6 +13,7 @@ namespace FishFactoryContracts.BindingModels
public int Id { get; set; }
public int CannedId { 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/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IImplementerLogic.cs b/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IImplementerLogic.cs
new file mode 100644
index 0000000..4168a02
--- /dev/null
+++ b/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IImplementerLogic.cs
@@ -0,0 +1,20 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.SearchModels;
+using FishFactoryContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryContracts.BusinessLogicsContracts
+{
+ public interface IImplementerLogic
+ {
+ List? ReadList(ImplementerSearchModel? model);
+ ImplementerViewModel? ReadElement(ImplementerSearchModel model);
+ bool Create(ImplementerBindingModel model);
+ bool Update(ImplementerBindingModel model);
+ bool Delete(ImplementerBindingModel model);
+ }
+}
diff --git a/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs b/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs
index 0bd427b..e5854fe 100644
--- a/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs
+++ b/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -16,5 +16,6 @@ namespace FishFactoryContracts.BusinessLogicsContracts
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
+ OrderViewModel? ReadElement(OrderSearchModel model);
}
}
diff --git a/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IWorkProcess.cs b/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IWorkProcess.cs
new file mode 100644
index 0000000..cf878c0
--- /dev/null
+++ b/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IWorkProcess.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryContracts.BusinessLogicsContracts
+{
+ public interface IWorkProcess
+ {
+ void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
+ }
+}
diff --git a/FishFactory/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs b/FishFactory/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs
new file mode 100644
index 0000000..d097862
--- /dev/null
+++ b/FishFactory/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryContracts.SearchModels
+{
+ public class ImplementerSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ImplementerFIO { get; set; }
+ public string? Password { get; set; }
+ }
+}
diff --git a/FishFactory/FishFactoryContracts/SearchModels/OrderSearchModel.cs b/FishFactory/FishFactoryContracts/SearchModels/OrderSearchModel.cs
index ed03b0b..a9b781e 100644
--- a/FishFactory/FishFactoryContracts/SearchModels/OrderSearchModel.cs
+++ b/FishFactory/FishFactoryContracts/SearchModels/OrderSearchModel.cs
@@ -1,4 +1,5 @@
-using System;
+using FishFactoryDataModels.Enums;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -12,5 +13,7 @@ namespace FishFactoryContracts.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/FishFactory/FishFactoryContracts/StoragesContracts/IImplementerStorage.cs b/FishFactory/FishFactoryContracts/StoragesContracts/IImplementerStorage.cs
new file mode 100644
index 0000000..e5fe382
--- /dev/null
+++ b/FishFactory/FishFactoryContracts/StoragesContracts/IImplementerStorage.cs
@@ -0,0 +1,21 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.SearchModels;
+using FishFactoryContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryContracts.StoragesContracts
+{
+ public interface IImplementerStorage
+ {
+ List GetFullList();
+ List GetFilteredList(ImplementerSearchModel model);
+ ImplementerViewModel? GetElement(ImplementerSearchModel model);
+ ImplementerViewModel? Insert(ImplementerBindingModel model);
+ ImplementerViewModel? Update(ImplementerBindingModel model);
+ ImplementerViewModel? Delete(ImplementerBindingModel model);
+ }
+}
diff --git a/FishFactory/FishFactoryContracts/ViewModels/ImplementerViewModel.cs b/FishFactory/FishFactoryContracts/ViewModels/ImplementerViewModel.cs
new file mode 100644
index 0000000..a14a1ae
--- /dev/null
+++ b/FishFactory/FishFactoryContracts/ViewModels/ImplementerViewModel.cs
@@ -0,0 +1,27 @@
+using FishFactoryDataModels;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryContracts.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/FishFactory/FishFactoryContracts/ViewModels/OrderViewModel.cs b/FishFactory/FishFactoryContracts/ViewModels/OrderViewModel.cs
index e1d8711..4129795 100644
--- a/FishFactory/FishFactoryContracts/ViewModels/OrderViewModel.cs
+++ b/FishFactory/FishFactoryContracts/ViewModels/OrderViewModel.cs
@@ -30,5 +30,8 @@ namespace FishFactoryContracts.ViewModels
[DisplayName("Фамилия клиента")]
public string ClientFIO { get; set; } = string.Empty;
+ public int? ImplementerId { get; set; }
+ [DisplayName("Исполнитель")]
+ public string ImplementerFIO { get; set; } = string.Empty;
}
}
diff --git a/FishFactory/FishFactoryDataModels/IImplementerModel.cs b/FishFactory/FishFactoryDataModels/IImplementerModel.cs
new file mode 100644
index 0000000..dcc8dbc
--- /dev/null
+++ b/FishFactory/FishFactoryDataModels/IImplementerModel.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryDataModels
+{
+ public interface IImplementerModel : IId
+ {
+ string ImplementerFIO { get; }
+ string Password { get; }
+ int WorkExperience { get; }
+ int Qualification { get; }
+ }
+}
diff --git a/FishFactory/FishFactoryDataModels/IOrderModel.cs b/FishFactory/FishFactoryDataModels/IOrderModel.cs
index 583fcee..ff0fcad 100644
--- a/FishFactory/FishFactoryDataModels/IOrderModel.cs
+++ b/FishFactory/FishFactoryDataModels/IOrderModel.cs
@@ -12,6 +12,7 @@ namespace FishFactoryDataModels.Models
{
int CannedId { get; }
int ClientId { get; }
+ int? ImplementerId { get; }
int Count { get; }
double Sum { get; }
OrderStatus Status { get; }
diff --git a/FishFactory/FishFactoryDatabaseImplement/FishFactoryDatabase.cs b/FishFactory/FishFactoryDatabaseImplement/FishFactoryDatabase.cs
index 8f351d7..907f7b0 100644
--- a/FishFactory/FishFactoryDatabaseImplement/FishFactoryDatabase.cs
+++ b/FishFactory/FishFactoryDatabaseImplement/FishFactoryDatabase.cs
@@ -15,7 +15,7 @@ namespace FishFactoryDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
- optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=FishFactoryLab51;Username=postgres;Password=postgres");
+ optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=FishFactoryLab6;Username=postgres;Password=postgres");
}
base.OnConfiguring(optionsBuilder);
}
@@ -24,5 +24,6 @@ namespace FishFactoryDatabaseImplement
public virtual DbSet CannedComponents { set; get; }
public virtual DbSet Orders { set; get; }
public virtual DbSet Clients { set; get; }
+ public virtual DbSet Implementers { set; get; }
}
}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Implements/ImplementerStorage.cs b/FishFactory/FishFactoryDatabaseImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..18092cc
--- /dev/null
+++ b/FishFactory/FishFactoryDatabaseImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,106 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.SearchModels;
+using FishFactoryContracts.StoragesContracts;
+using FishFactoryContracts.ViewModels;
+using FishFactoryDatabaseImplement.Models;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryDatabaseImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ public ImplementerViewModel? Delete(ImplementerBindingModel model)
+ {
+ using var context = new FishFactoryDatabase();
+ var element = context.Implementers
+ .Include(x => x.Orders)
+ .FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ context.Implementers.Remove(element);
+ context.SaveChanges();
+ return element.GetViewModel;
+ }
+ return null;
+ }
+
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ using var context = new FishFactoryDatabase();
+ if (model.Id.HasValue)
+ {
+ return context.Implementers
+ .FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel;
+ }
+ else if (!string.IsNullOrEmpty(model.ImplementerFIO) && !string.IsNullOrEmpty(model.Password))
+ {
+ return context.Implementers
+ .FirstOrDefault(x => (x.ImplementerFIO == model.ImplementerFIO && x.Password == model.Password))?.GetViewModel;
+ }
+ else if (!string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ return context.Implementers
+ .FirstOrDefault(x => (x.ImplementerFIO == model.ImplementerFIO))?.GetViewModel;
+ }
+ return new();
+ }
+
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ if (model == null)
+ {
+ return new();
+ }
+ if (!string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ using var context = new FishFactoryDatabase();
+ return context.Implementers
+ .Include(x => x.Orders)
+ .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return new();
+ }
+
+ public List GetFullList()
+ {
+ using var context = new FishFactoryDatabase();
+ return context.Implementers
+ .Include(x => x.Orders)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+
+ public ImplementerViewModel? Insert(ImplementerBindingModel model)
+ {
+ var newImplementer = Implementer.Create(model);
+ if (newImplementer == null)
+ {
+ return null;
+ }
+ using var context = new FishFactoryDatabase();
+ context.Implementers.Add(newImplementer);
+ context.SaveChanges();
+ return newImplementer.GetViewModel;
+ }
+
+ public ImplementerViewModel? Update(ImplementerBindingModel model)
+ {
+ using var context = new FishFactoryDatabase();
+ var client = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
+ if (client == null)
+ {
+ return null;
+ }
+ client.Update(model);
+ context.SaveChanges();
+ return client.GetViewModel;
+ }
+ }
+}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Implements/OrderStorage.cs b/FishFactory/FishFactoryDatabaseImplement/Implements/OrderStorage.cs
index 91ac6ed..3b01bab 100644
--- a/FishFactory/FishFactoryDatabaseImplement/Implements/OrderStorage.cs
+++ b/FishFactory/FishFactoryDatabaseImplement/Implements/OrderStorage.cs
@@ -22,6 +22,8 @@ namespace FishFactoryDatabaseImplement.Implements
{
var deletedElement = context.Orders
.Include(x => x.Canned)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Orders.Remove(element);
@@ -43,7 +45,10 @@ namespace FishFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Canned)
.Include(x => x.Client)
- .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ .Include(x => x.Implementer)
+ .FirstOrDefault(x => (model.Status == null || model.Status != null && model.Status == x.Status) &&
+ model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId ||
+ model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
@@ -55,6 +60,7 @@ namespace FishFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Canned)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
@@ -64,6 +70,7 @@ namespace FishFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Canned)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
@@ -73,14 +80,28 @@ namespace FishFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Canned)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
- else
+ else if (model.ImplementerId.HasValue)
{
- return new();
+ return context.Orders
+ .Include(x => x.Canned)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .Where(x => x.ImplementerId == model.ImplementerId)
+ .Select(x => x.GetViewModel)
+ .ToList();
}
+ return context.Orders
+ .Include(x => x.Canned)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .Where(x => model.Status == x.Status)
+ .Select(x => x.GetViewModel)
+ .ToList();
}
public List GetFullList()
@@ -89,6 +110,7 @@ namespace FishFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Canned)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.Select(x => x.GetViewModel)
.ToList();
}
@@ -125,6 +147,7 @@ namespace FishFactoryDatabaseImplement.Implements
return context.Orders
.Include(x => x.Canned)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.Designer.cs b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.Designer.cs
new file mode 100644
index 0000000..fbc3d34
--- /dev/null
+++ b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.Designer.cs
@@ -0,0 +1,260 @@
+//
+using System;
+using FishFactoryDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace FishFactoryDatabaseImplement.Migrations
+{
+ [DbContext(typeof(FishFactoryDatabase))]
+ [Migration("20230411050354_Init")]
+ partial class Init
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.4")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("CannedName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.ToTable("Canneds");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("CannedId")
+ .HasColumnType("integer");
+
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CannedId");
+
+ b.HasIndex("ComponentId");
+
+ b.ToTable("CannedComponents");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClientFIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Clients");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Cost")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ImplementerFIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Qualification")
+ .HasColumnType("integer");
+
+ b.Property("WorkExperience")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.ToTable("Implementers");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("CannedId")
+ .HasColumnType("integer");
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("DateCreate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateImplement")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ImplementerId")
+ .IsRequired()
+ .HasColumnType("integer");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("Sum")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CannedId");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("ImplementerId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedComponent", b =>
+ {
+ b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
+ .WithMany("Components")
+ .HasForeignKey("CannedId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("FishFactoryDatabaseImplement.Models.Component", "Component")
+ .WithMany("CannedComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Canned");
+
+ b.Navigation("Component");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
+ .WithMany("Orders")
+ .HasForeignKey("CannedId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("FishFactoryDatabaseImplement.Models.Client", "Client")
+ .WithMany("Orders")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("FishFactoryDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Canned");
+
+ b.Navigation("Client");
+
+ b.Navigation("Implementer");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Client", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Component", b =>
+ {
+ b.Navigation("CannedComponents");
+ });
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.cs b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.cs
similarity index 81%
rename from FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.cs
rename to FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.cs
index 7d6f011..f03d01b 100644
--- a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.cs
+++ b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.cs
@@ -56,34 +56,19 @@ namespace FishFactoryDatabaseImplement.Migrations
});
migrationBuilder.CreateTable(
- name: "Orders",
+ name: "Implementers",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- CannedId = table.Column(type: "integer", nullable: false),
- ClientId = table.Column(type: "integer", nullable: false),
- Count = table.Column(type: "integer", nullable: false),
- Sum = table.Column(type: "double precision", nullable: false),
- Status = table.Column(type: "integer", nullable: false),
- DateCreate = table.Column(type: "timestamp with time zone", nullable: false),
- DateImplement = table.Column(type: "timestamp with time zone", nullable: true)
+ ImplementerFIO = table.Column(type: "text", nullable: false),
+ Password = table.Column(type: "text", nullable: false),
+ WorkExperience = table.Column(type: "integer", nullable: false),
+ Qualification = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
- table.PrimaryKey("PK_Orders", x => x.Id);
- table.ForeignKey(
- name: "FK_Orders_Canneds_CannedId",
- column: x => x.CannedId,
- principalTable: "Canneds",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_Orders_Clients_ClientId",
- column: x => x.ClientId,
- principalTable: "Clients",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
+ table.PrimaryKey("PK_Implementers", x => x.Id);
});
migrationBuilder.CreateTable(
@@ -113,6 +98,44 @@ namespace FishFactoryDatabaseImplement.Migrations
onDelete: ReferentialAction.Cascade);
});
+ migrationBuilder.CreateTable(
+ name: "Orders",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ CannedId = table.Column(type: "integer", nullable: false),
+ ClientId = table.Column(type: "integer", nullable: false),
+ ImplementerId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false),
+ Sum = table.Column(type: "double precision", nullable: false),
+ Status = table.Column(type: "integer", nullable: false),
+ DateCreate = table.Column(type: "timestamp with time zone", nullable: false),
+ DateImplement = table.Column(type: "timestamp with time zone", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Orders", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Orders_Canneds_CannedId",
+ column: x => x.CannedId,
+ principalTable: "Canneds",
+ 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",
+ onDelete: ReferentialAction.Cascade);
+ });
+
migrationBuilder.CreateIndex(
name: "IX_CannedComponents_CannedId",
table: "CannedComponents",
@@ -132,6 +155,11 @@ namespace FishFactoryDatabaseImplement.Migrations
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId");
}
///
@@ -151,6 +179,9 @@ namespace FishFactoryDatabaseImplement.Migrations
migrationBuilder.DropTable(
name: "Clients");
+
+ migrationBuilder.DropTable(
+ name: "Implementers");
}
}
}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.Designer.cs b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230422093015_Init2.Designer.cs
similarity index 82%
rename from FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.Designer.cs
rename to FishFactory/FishFactoryDatabaseImplement/Migrations/20230422093015_Init2.Designer.cs
index 551eb0c..97763ec 100644
--- a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.Designer.cs
+++ b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230422093015_Init2.Designer.cs
@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace FishFactoryDatabaseImplement.Migrations
{
[DbContext(typeof(FishFactoryDatabase))]
- [Migration("20230410133743_Init")]
- partial class Init
+ [Migration("20230422093015_Init2")]
+ partial class Init2
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -116,6 +116,33 @@ namespace FishFactoryDatabaseImplement.Migrations
b.ToTable("Components");
});
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ImplementerFIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Qualification")
+ .HasColumnType("integer");
+
+ b.Property("WorkExperience")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.ToTable("Implementers");
+ });
+
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
{
b.Property("Id")
@@ -139,6 +166,9 @@ namespace FishFactoryDatabaseImplement.Migrations
b.Property("DateImplement")
.HasColumnType("timestamp with time zone");
+ b.Property("ImplementerId")
+ .HasColumnType("integer");
+
b.Property("Status")
.HasColumnType("integer");
@@ -151,6 +181,8 @@ namespace FishFactoryDatabaseImplement.Migrations
b.HasIndex("ClientId");
+ b.HasIndex("ImplementerId");
+
b.ToTable("Orders");
});
@@ -187,9 +219,15 @@ namespace FishFactoryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.HasOne("FishFactoryDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
b.Navigation("Canned");
b.Navigation("Client");
+
+ b.Navigation("Implementer");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
@@ -208,6 +246,11 @@ namespace FishFactoryDatabaseImplement.Migrations
{
b.Navigation("CannedComponents");
});
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
#pragma warning restore 612, 618
}
}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230422093015_Init2.cs b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230422093015_Init2.cs
new file mode 100644
index 0000000..15632e6
--- /dev/null
+++ b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230422093015_Init2.cs
@@ -0,0 +1,59 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace FishFactoryDatabaseImplement.Migrations
+{
+ ///
+ public partial class Init2 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ table: "Orders");
+
+ migrationBuilder.AlterColumn(
+ name: "ImplementerId",
+ table: "Orders",
+ type: "integer",
+ nullable: true,
+ oldClrType: typeof(int),
+ oldType: "integer");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId",
+ principalTable: "Implementers",
+ principalColumn: "Id");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ table: "Orders");
+
+ migrationBuilder.AlterColumn(
+ name: "ImplementerId",
+ table: "Orders",
+ type: "integer",
+ nullable: false,
+ defaultValue: 0,
+ oldClrType: typeof(int),
+ oldType: "integer",
+ oldNullable: true);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId",
+ principalTable: "Implementers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+ }
+}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Migrations/FishFactoryDatabaseModelSnapshot.cs b/FishFactory/FishFactoryDatabaseImplement/Migrations/FishFactoryDatabaseModelSnapshot.cs
index a32e0af..1e95606 100644
--- a/FishFactory/FishFactoryDatabaseImplement/Migrations/FishFactoryDatabaseModelSnapshot.cs
+++ b/FishFactory/FishFactoryDatabaseImplement/Migrations/FishFactoryDatabaseModelSnapshot.cs
@@ -113,6 +113,33 @@ namespace FishFactoryDatabaseImplement.Migrations
b.ToTable("Components");
});
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ImplementerFIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Qualification")
+ .HasColumnType("integer");
+
+ b.Property("WorkExperience")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.ToTable("Implementers");
+ });
+
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
{
b.Property("Id")
@@ -136,6 +163,9 @@ namespace FishFactoryDatabaseImplement.Migrations
b.Property("DateImplement")
.HasColumnType("timestamp with time zone");
+ b.Property("ImplementerId")
+ .HasColumnType("integer");
+
b.Property("Status")
.HasColumnType("integer");
@@ -148,6 +178,8 @@ namespace FishFactoryDatabaseImplement.Migrations
b.HasIndex("ClientId");
+ b.HasIndex("ImplementerId");
+
b.ToTable("Orders");
});
@@ -184,9 +216,15 @@ namespace FishFactoryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.HasOne("FishFactoryDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
b.Navigation("Canned");
b.Navigation("Client");
+
+ b.Navigation("Implementer");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
@@ -205,6 +243,11 @@ namespace FishFactoryDatabaseImplement.Migrations
{
b.Navigation("CannedComponents");
});
+
+ modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
#pragma warning restore 612, 618
}
}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Models/Implementer.cs b/FishFactory/FishFactoryDatabaseImplement/Models/Implementer.cs
new file mode 100644
index 0000000..b628dc2
--- /dev/null
+++ b/FishFactory/FishFactoryDatabaseImplement/Models/Implementer.cs
@@ -0,0 +1,80 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.StoragesContracts;
+using FishFactoryContracts.ViewModels;
+using FishFactoryDataModels;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryDatabaseImplement.Models
+{
+ public class Implementer : IImplementerModel
+ {
+ public int Id { get; set; }
+
+ [Required]
+ public string ImplementerFIO { get; set; } = String.Empty;
+
+ [Required]
+ public string Password { get; set; } = String.Empty;
+
+ [Required]
+ public int WorkExperience { get; set; }
+
+ [Required]
+ public int Qualification { get; set; }
+
+ [ForeignKey("ImplementerId")]
+ public virtual List Orders { get; set; } = new();
+
+ public static Implementer? Create(ImplementerBindingModel model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Implementer()
+ {
+ Id = model.Id,
+ ImplementerFIO = model.ImplementerFIO,
+ Password = model.Password,
+ WorkExperience = model.WorkExperience,
+ Qualification = model.Qualification
+ };
+ }
+ public static Implementer Create(ImplementerViewModel model)
+ {
+ return new Implementer
+ {
+ Id = model.Id,
+ ImplementerFIO = model.ImplementerFIO,
+ Password = model.Password,
+ WorkExperience = model.WorkExperience,
+ Qualification = model.Qualification
+ };
+ }
+ public void Update(ImplementerBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ImplementerFIO = model.ImplementerFIO;
+ Password = model.Password;
+ WorkExperience = model.WorkExperience;
+ Qualification = model.Qualification;
+ }
+ public ImplementerViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ImplementerFIO = ImplementerFIO,
+ Password = Password,
+ WorkExperience = WorkExperience,
+ Qualification = Qualification
+ };
+ }
+}
diff --git a/FishFactory/FishFactoryDatabaseImplement/Models/Order.cs b/FishFactory/FishFactoryDatabaseImplement/Models/Order.cs
index cff5b55..4c54eea 100644
--- a/FishFactory/FishFactoryDatabaseImplement/Models/Order.cs
+++ b/FishFactory/FishFactoryDatabaseImplement/Models/Order.cs
@@ -19,6 +19,7 @@ namespace FishFactoryDatabaseImplement.Models
public int CannedId { get; set; }
[Required]
public int ClientId { get; set; }
+ public int? ImplementerId { get; set; }
[Required]
public int Count { get; set; }
[Required]
@@ -29,8 +30,9 @@ namespace FishFactoryDatabaseImplement.Models
public DateTime DateCreate { get; set; }
public DateTime? DateImplement { get; set; }
- public virtual Canned Canned { get; set; }
- public virtual Client Client { get; set; }
+ public virtual Canned? Canned { get; set; }
+ public virtual Implementer? Implementer { get; set; }
+ public virtual Client? Client { get; set; }
public int Id { get; set; }
public static Order? Create(OrderBindingModel model)
@@ -44,6 +46,7 @@ namespace FishFactoryDatabaseImplement.Models
Id = model.Id,
CannedId = model.CannedId,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@@ -59,6 +62,7 @@ namespace FishFactoryDatabaseImplement.Models
}
Status = model.Status;
DateImplement = model.DateImplement;
+ ImplementerId = model.ImplementerId;
}
public OrderViewModel GetViewModel => new()
{
@@ -66,6 +70,8 @@ namespace FishFactoryDatabaseImplement.Models
Id = Id,
CannedId = CannedId,
ClientId = ClientId,
+ ImplementerId = ImplementerId,
+ ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
ClientFIO = Client.ClientFIO,
Count = Count,
Sum = Sum,
diff --git a/FishFactory/FishFactoryFileImplement/Models/Order.cs b/FishFactory/FishFactoryFileImplement/Models/Order.cs
index 7e0ec53..4051894 100644
--- a/FishFactory/FishFactoryFileImplement/Models/Order.cs
+++ b/FishFactory/FishFactoryFileImplement/Models/Order.cs
@@ -26,6 +26,7 @@ namespace FishFactoryFileImplement.Models
public DateTime? DateImplement { get; private set; }
public int ClientId { get; private set; }
+ public int? ImplementerId { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
diff --git a/FishFactory/FishFactoryListImplement/DataListSingleton.cs b/FishFactory/FishFactoryListImplement/DataListSingleton.cs
index 8161db2..08c9428 100644
--- a/FishFactory/FishFactoryListImplement/DataListSingleton.cs
+++ b/FishFactory/FishFactoryListImplement/DataListSingleton.cs
@@ -14,12 +14,15 @@ namespace FishFactoryListImplement
public List Orders { get; set; }
public List Canneds { get; set; }
public List Clients { get; set; }
+ public List Implementers { get; set; }
+
private DataListSingleton()
{
Components = new List();
Orders = new List();
Canneds = new List();
Clients = new List();
+ Implementers = new List();
}
public static DataListSingleton GetInstance()
{
diff --git a/FishFactory/FishFactoryListImplement/Models/Implementer.cs b/FishFactory/FishFactoryListImplement/Models/Implementer.cs
new file mode 100644
index 0000000..d2a8edd
--- /dev/null
+++ b/FishFactory/FishFactoryListImplement/Models/Implementer.cs
@@ -0,0 +1,60 @@
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.ViewModels;
+using FishFactoryDataModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FishFactoryListImplement.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,
+ };
+ }
+}
\ No newline at end of file
diff --git a/FishFactory/FishFactoryListImplement/Models/Order.cs b/FishFactory/FishFactoryListImplement/Models/Order.cs
index c136e96..d47711f 100644
--- a/FishFactory/FishFactoryListImplement/Models/Order.cs
+++ b/FishFactory/FishFactoryListImplement/Models/Order.cs
@@ -27,6 +27,8 @@ namespace FishFactoryListImplement.Models
public int ClientId { get; private set; }
+ public int? ImplementerId { get; private set; }
+
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
diff --git a/FishFactory/FishFactoryRestApi/Controllers/ImplementerController.cs b/FishFactory/FishFactoryRestApi/Controllers/ImplementerController.cs
new file mode 100644
index 0000000..409d3d5
--- /dev/null
+++ b/FishFactory/FishFactoryRestApi/Controllers/ImplementerController.cs
@@ -0,0 +1,102 @@
+using DocumentFormat.OpenXml.Office2010.Excel;
+using FishFactoryContracts.BindingModels;
+using FishFactoryContracts.BusinessLogicsContracts;
+using FishFactoryContracts.SearchModels;
+using FishFactoryContracts.ViewModels;
+using FishFactoryDataModels.Enums;
+using Microsoft.AspNetCore.Mvc;
+
+namespace FishFactoryRestApi.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;
+ }
+ }
+ }
+
+}