diff --git a/Shipyard/Shipyard/FormImplementer.Designer.cs b/Shipyard/Shipyard/FormImplementer.Designer.cs
new file mode 100644
index 0000000..a6d2712
--- /dev/null
+++ b/Shipyard/Shipyard/FormImplementer.Designer.cs
@@ -0,0 +1,163 @@
+namespace ShipyardView
+{
+ 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.labelExperience = 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.textBoxExperience = new System.Windows.Forms.TextBox();
+ this.textBoxQualification = new System.Windows.Forms.TextBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelFIO
+ //
+ this.labelFIO.AutoSize = true;
+ this.labelFIO.Location = new System.Drawing.Point(32, 9);
+ this.labelFIO.Name = "labelFIO";
+ this.labelFIO.Size = new System.Drawing.Size(45, 20);
+ this.labelFIO.TabIndex = 0;
+ this.labelFIO.Text = "ФИО:";
+ //
+ // labelPassword
+ //
+ this.labelPassword.AutoSize = true;
+ this.labelPassword.Location = new System.Drawing.Point(32, 50);
+ this.labelPassword.Name = "labelPassword";
+ this.labelPassword.Size = new System.Drawing.Size(65, 20);
+ this.labelPassword.TabIndex = 1;
+ this.labelPassword.Text = "Пароль:";
+ //
+ // labelExperience
+ //
+ this.labelExperience.AutoSize = true;
+ this.labelExperience.Location = new System.Drawing.Point(32, 105);
+ this.labelExperience.Name = "labelExperience";
+ this.labelExperience.Size = new System.Drawing.Size(102, 20);
+ this.labelExperience.TabIndex = 2;
+ this.labelExperience.Text = "Стаж работы:";
+ //
+ // labelQualification
+ //
+ this.labelQualification.AutoSize = true;
+ this.labelQualification.Location = new System.Drawing.Point(270, 105);
+ 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(102, 6);
+ this.textBoxFIO.Name = "textBoxFIO";
+ this.textBoxFIO.Size = new System.Drawing.Size(282, 27);
+ this.textBoxFIO.TabIndex = 4;
+ //
+ // textBoxPassword
+ //
+ this.textBoxPassword.Location = new System.Drawing.Point(103, 50);
+ this.textBoxPassword.Name = "textBoxPassword";
+ this.textBoxPassword.Size = new System.Drawing.Size(281, 27);
+ this.textBoxPassword.TabIndex = 5;
+ //
+ // textBoxExperience
+ //
+ this.textBoxExperience.Location = new System.Drawing.Point(140, 105);
+ this.textBoxExperience.Name = "textBoxExperience";
+ this.textBoxExperience.Size = new System.Drawing.Size(124, 27);
+ this.textBoxExperience.TabIndex = 6;
+ //
+ // textBoxQualification
+ //
+ this.textBoxQualification.Location = new System.Drawing.Point(390, 105);
+ this.textBoxQualification.Name = "textBoxQualification";
+ this.textBoxQualification.Size = new System.Drawing.Size(96, 27);
+ this.textBoxQualification.TabIndex = 7;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(270, 157);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(94, 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(392, 157);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(94, 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(498, 202);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxQualification);
+ this.Controls.Add(this.textBoxExperience);
+ this.Controls.Add(this.textBoxPassword);
+ this.Controls.Add(this.textBoxFIO);
+ this.Controls.Add(this.labelQualification);
+ this.Controls.Add(this.labelExperience);
+ this.Controls.Add(this.labelPassword);
+ this.Controls.Add(this.labelFIO);
+ this.Name = "FormImplementer";
+ this.Text = "Исполнитель";
+ this.Load += new System.EventHandler(this.FormImplementer_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelFIO;
+ private Label labelPassword;
+ private Label labelExperience;
+ private Label labelQualification;
+ private TextBox textBoxFIO;
+ private TextBox textBoxPassword;
+ private TextBox textBoxExperience;
+ private TextBox textBoxQualification;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/Shipyard/Shipyard/FormImplementer.cs b/Shipyard/Shipyard/FormImplementer.cs
new file mode 100644
index 0000000..4f947f6
--- /dev/null
+++ b/Shipyard/Shipyard/FormImplementer.cs
@@ -0,0 +1,100 @@
+using Microsoft.Extensions.Logging;
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.BusinessLogicsContracts;
+using ShipyardContracts.SearchModels;
+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 ShipyardView
+{
+ 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;
+ textBoxExperience.Text = view.WorkExperience.ToString();
+ textBoxPassword.Text = view.Password;
+ textBoxQualification.Text = view.Qualification.ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения исполнителя");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxFIO.Text))
+ {
+ MessageBox.Show("Заполните ФИО", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение исполнителя");
+ try
+ {
+ var model = new ImplementerBindingModel
+ {
+ Id = _id ?? 0,
+ ImplementerFIO = textBoxFIO.Text,
+ Password = textBoxPassword.Text,
+ WorkExperience = Convert.ToInt32(textBoxExperience.Text),
+ Qualification = Convert.ToInt32(textBoxQualification.Text),
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) :
+ _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения компонента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/Shipyard/Shipyard/FormImplementer.resx b/Shipyard/Shipyard/FormImplementer.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Shipyard/Shipyard/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/Shipyard/Shipyard/FormImplementers.Designer.cs b/Shipyard/Shipyard/FormImplementers.Designer.cs
new file mode 100644
index 0000000..3868ca4
--- /dev/null
+++ b/Shipyard/Shipyard/FormImplementers.Designer.cs
@@ -0,0 +1,116 @@
+namespace ShipyardView
+{
+ 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.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ this.buttonRef = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
+ this.dataGridView.Location = new System.Drawing.Point(0, 0);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(564, 450);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(637, 37);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(94, 29);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(637, 100);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(94, 29);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(637, 164);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(94, 29);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(637, 228);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(94, 29);
+ this.buttonRef.TabIndex = 4;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // 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.buttonRef);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormImplementers";
+ this.Text = "Исполнители";
+ this.Load += new System.EventHandler(this.FormImplementers_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonUpd;
+ private Button buttonDel;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/Shipyard/Shipyard/FormImplementers.cs b/Shipyard/Shipyard/FormImplementers.cs
new file mode 100644
index 0000000..83903a1
--- /dev/null
+++ b/Shipyard/Shipyard/FormImplementers.cs
@@ -0,0 +1,115 @@
+using Microsoft.Extensions.Logging;
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.BusinessLogicsContracts;
+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 ShipyardView
+{
+ 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;
+ dataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["WorkExperience"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["Qualification"].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/Shipyard/Shipyard/FormImplementers.resx b/Shipyard/Shipyard/FormImplementers.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Shipyard/Shipyard/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/Shipyard/Shipyard/FormMain.Designer.cs b/Shipyard/Shipyard/FormMain.Designer.cs
index 6b15ead..f22d685 100644
--- a/Shipyard/Shipyard/FormMain.Designer.cs
+++ b/Shipyard/Shipyard/FormMain.Designer.cs
@@ -29,20 +29,20 @@
private void InitializeComponent()
{
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.menuStrip1 = 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.ShipsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shipsDetailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView();
- this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.запускаРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
@@ -58,32 +58,10 @@
this.ButtonCreateOrder.UseVisualStyleBackColor = true;
this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
//
- // ButtonTakeOrderInWork
- //
- this.ButtonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(961, 125);
- this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
- this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(187, 29);
- this.ButtonTakeOrderInWork.TabIndex = 1;
- this.ButtonTakeOrderInWork.Text = "Отдать на выполнение";
- this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
- this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
- //
- // ButtonOrderReady
- //
- this.ButtonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.ButtonOrderReady.Location = new System.Drawing.Point(961, 194);
- this.ButtonOrderReady.Name = "ButtonOrderReady";
- this.ButtonOrderReady.Size = new System.Drawing.Size(187, 29);
- this.ButtonOrderReady.TabIndex = 2;
- this.ButtonOrderReady.Text = "Заказ готов";
- this.ButtonOrderReady.UseVisualStyleBackColor = true;
- this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
- //
// ButtonIssuedOrder
//
this.ButtonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.ButtonIssuedOrder.Location = new System.Drawing.Point(961, 256);
+ this.ButtonIssuedOrder.Location = new System.Drawing.Point(961, 131);
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
this.ButtonIssuedOrder.Size = new System.Drawing.Size(187, 29);
this.ButtonIssuedOrder.TabIndex = 3;
@@ -94,7 +72,7 @@
// ButtonRef
//
this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.ButtonRef.Location = new System.Drawing.Point(961, 324);
+ this.ButtonRef.Location = new System.Drawing.Point(961, 196);
this.ButtonRef.Name = "ButtonRef";
this.ButtonRef.Size = new System.Drawing.Size(187, 29);
this.ButtonRef.TabIndex = 4;
@@ -107,7 +85,8 @@
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
- this.отчетыToolStripMenuItem});
+ this.отчетыToolStripMenuItem,
+ this.запускаРаботToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1160, 28);
@@ -119,7 +98,8 @@
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ДеталиToolStripMenuItem,
this.КораблиToolStripMenuItem,
- this.клиентыToolStripMenuItem});
+ this.клиентыToolStripMenuItem,
+ this.исполнителиToolStripMenuItem});
this.ToolStripMenuItem.Name = "ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
this.ToolStripMenuItem.Text = "Справочники";
@@ -127,17 +107,31 @@
// ДеталиToolStripMenuItem
//
this.ДеталиToolStripMenuItem.Name = "ДеталиToolStripMenuItem";
- this.ДеталиToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ 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(224, 26);
+ 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[] {
@@ -180,12 +174,12 @@
this.dataGridView.Size = new System.Drawing.Size(933, 446);
this.dataGridView.TabIndex = 6;
//
- // клиентыToolStripMenuItem
+ // запускаРаботToolStripMenuItem
//
- this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
- this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
- this.клиентыToolStripMenuItem.Text = "Клиенты";
- this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.КлиентыToolStripMenuItem_Click);
+ 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
//
@@ -195,8 +189,6 @@
this.Controls.Add(this.dataGridView);
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.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
@@ -214,8 +206,6 @@
#endregion
private Button ButtonCreateOrder;
- private Button ButtonTakeOrderInWork;
- private Button ButtonOrderReady;
private Button ButtonIssuedOrder;
private Button ButtonRef;
private MenuStrip menuStrip1;
@@ -228,5 +218,7 @@
private ToolStripMenuItem shipsDetailsToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem;
+ private ToolStripMenuItem исполнителиToolStripMenuItem;
+ private ToolStripMenuItem запускаРаботToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/Shipyard/Shipyard/FormMain.cs b/Shipyard/Shipyard/FormMain.cs
index cad1c14..5fd1d43 100644
--- a/Shipyard/Shipyard/FormMain.cs
+++ b/Shipyard/Shipyard/FormMain.cs
@@ -19,13 +19,14 @@ namespace ShipyardView
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)
@@ -43,6 +44,7 @@ namespace ShipyardView
dataGridView.DataSource = list;
dataGridView.Columns["ShipId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
+ dataGridView.Columns["ImplementerId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов");
}
@@ -194,5 +196,23 @@ namespace ShipyardView
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/Shipyard/Shipyard/Program.cs b/Shipyard/Shipyard/Program.cs
index b497bc7..d222948 100644
--- a/Shipyard/Shipyard/Program.cs
+++ b/Shipyard/Shipyard/Program.cs
@@ -43,12 +43,15 @@ namespace ShipyardView
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();
@@ -58,6 +61,8 @@ namespace ShipyardView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
diff --git a/Shipyard/ShipyardBusinessLogic/BusinessLogics/ImplementerLogic.cs b/Shipyard/ShipyardBusinessLogic/BusinessLogics/ImplementerLogic.cs
new file mode 100644
index 0000000..f02f4ad
--- /dev/null
+++ b/Shipyard/ShipyardBusinessLogic/BusinessLogics/ImplementerLogic.cs
@@ -0,0 +1,121 @@
+using Microsoft.Extensions.Logging;
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.BusinessLogicsContracts;
+using ShipyardContracts.SearchModels;
+using ShipyardContracts.StoragesContracts;
+using ShipyardContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardBusinessLogic.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 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/Shipyard/ShipyardBusinessLogic/BusinessLogics/OrderLogic.cs b/Shipyard/ShipyardBusinessLogic/BusinessLogics/OrderLogic.cs
index 5b6312e..422364a 100644
--- a/Shipyard/ShipyardBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/Shipyard/ShipyardBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -83,6 +83,10 @@ namespace ShipyardBusinessLogic.BusinessLogics
return false;
}
model.Status = newStatus;
+ if (viewModel.ImplementerId.HasValue)
+ {
+ model.ImplementerId = viewModel.ImplementerId;
+ }
if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now;
else
{
@@ -113,5 +117,22 @@ namespace ShipyardBusinessLogic.BusinessLogics
{
return StatusUpdate(model, OrderStatus.Готов);
}
+
+ 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/Shipyard/ShipyardBusinessLogic/BusinessLogics/WorkModeling.cs b/Shipyard/ShipyardBusinessLogic/BusinessLogics/WorkModeling.cs
new file mode 100644
index 0000000..e530caf
--- /dev/null
+++ b/Shipyard/ShipyardBusinessLogic/BusinessLogics/WorkModeling.cs
@@ -0,0 +1,160 @@
+using Microsoft.Extensions.Logging;
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.BusinessLogicsContracts;
+using ShipyardContracts.SearchModels;
+using ShipyardContracts.ViewModels;
+using ShipyardDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardBusinessLogic.BusinessLogics
+{
+ public class WorkModeling : IWorkProcess
+ {
+ private readonly ILogger _logger;
+
+ private readonly Random _rnd;
+
+ private IOrderLogic? _orderLogic;
+
+ public WorkModeling(ILogger logger)
+ {
+ _logger = logger;
+ _rnd = new Random(1000);
+ }
+
+ public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
+ {
+ _orderLogic = orderLogic;
+ var implementers = implementerLogic.ReadList(null);
+
+ if (implementers == null)
+ {
+ _logger.LogWarning("DoWork. Implementers is null");
+ return;
+ }
+
+ var orders = _orderLogic.ReadList(new OrderSearchModel
+ {
+ Status = OrderStatus.Принят
+ });
+
+ if (orders == null || orders.Count == 0)
+ {
+ _logger.LogWarning("DoWork. Orders is null or empty");
+ return;
+ }
+
+ _logger.LogDebug("DoWork for {Count} orders", orders.Count);
+ foreach (var implementer in implementers)
+ {
+ Task.Run(() => WorkerWorkAsync(implementer, orders));
+ }
+ }
+
+ // Иммитация работы исполнителя
+ private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders)
+ {
+ if (_orderLogic == null || implementer == null)
+ {
+ return;
+ }
+
+ await RunOrderInWork(implementer);
+
+ await Task.Run(() =>
+ {
+ foreach (var order in orders)
+ {
+ try
+ {
+ _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
+
+ // пытаемся назначить заказ на исполнителя
+ _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = order.Id,
+ ImplementerId = implementer.Id
+ });
+
+ // делаем работу
+ Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
+ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
+
+ _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = order.Id,
+ });
+ // отдыхаем
+ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
+ }
+ // кто-то мог уже перехватить заказ, игнорируем ошибку
+ catch (InvalidOperationException ex)
+ {
+ _logger.LogWarning(ex, "Error try get work");
+ }
+ // заканчиваем выполнение имитации в случае иной ошибки
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while do work");
+ throw;
+ }
+
+
+ }
+ });
+ }
+
+ //Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
+ private async Task RunOrderInWork(ImplementerViewModel implementer)
+ {
+ if (_orderLogic == null || implementer == null)
+ {
+ return;
+ }
+
+ try
+ {
+ var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
+ {
+ ImplementerId = implementer.Id,
+ Status = OrderStatus.Выполняется
+ }));
+
+ if (runOrder == null)
+ {
+ return;
+ }
+
+ _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
+
+ // доделываем работу
+ Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
+
+ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
+
+ _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = runOrder.Id
+ });
+
+ // отдыхаем
+ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
+ }
+ // заказа может не быть, просто игнорируем ошибку
+ catch (InvalidOperationException ex)
+ {
+ _logger.LogWarning(ex, "Error try get work");
+ }
+ // а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error while do work");
+ throw;
+ }
+ }
+ }
+}
diff --git a/Shipyard/ShipyardContracts/BindingModels/ImplementerBindingModel.cs b/Shipyard/ShipyardContracts/BindingModels/ImplementerBindingModel.cs
new file mode 100644
index 0000000..100f755
--- /dev/null
+++ b/Shipyard/ShipyardContracts/BindingModels/ImplementerBindingModel.cs
@@ -0,0 +1,22 @@
+using ShipyardDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardContracts.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/Shipyard/ShipyardContracts/BindingModels/OrderBindingModel.cs b/Shipyard/ShipyardContracts/BindingModels/OrderBindingModel.cs
index 8968f7f..7a3edae 100644
--- a/Shipyard/ShipyardContracts/BindingModels/OrderBindingModel.cs
+++ b/Shipyard/ShipyardContracts/BindingModels/OrderBindingModel.cs
@@ -13,6 +13,7 @@ namespace ShipyardContracts.BindingModels
public int Id { get; set; }
public int ShipId { 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/Shipyard/ShipyardContracts/BusinessLogicsContracts/IImplementerLogic.cs b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IImplementerLogic.cs
new file mode 100644
index 0000000..9be4bad
--- /dev/null
+++ b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IImplementerLogic.cs
@@ -0,0 +1,24 @@
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.SearchModels;
+using ShipyardContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardContracts.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/Shipyard/ShipyardContracts/BusinessLogicsContracts/IOrderLogic.cs b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IOrderLogic.cs
index 584b926..26a8b34 100644
--- a/Shipyard/ShipyardContracts/BusinessLogicsContracts/IOrderLogic.cs
+++ b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -15,6 +15,7 @@ namespace ShipyardContracts.BusinessLogicsContracts
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
+ OrderViewModel? ReadElement(OrderSearchModel model);
bool DeliveryOrder(OrderBindingModel model);
}
}
diff --git a/Shipyard/ShipyardContracts/BusinessLogicsContracts/IWorkProcess.cs b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IWorkProcess.cs
new file mode 100644
index 0000000..78cda2a
--- /dev/null
+++ b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IWorkProcess.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardContracts.BusinessLogicsContracts
+{
+ public interface IWorkProcess
+ {
+ void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
+ }
+}
diff --git a/Shipyard/ShipyardContracts/SearchModels/ImplementerSearchModel.cs b/Shipyard/ShipyardContracts/SearchModels/ImplementerSearchModel.cs
new file mode 100644
index 0000000..2235cd4
--- /dev/null
+++ b/Shipyard/ShipyardContracts/SearchModels/ImplementerSearchModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardContracts.SearchModels
+{
+ public class ImplementerSearchModel
+ {
+ public int? Id { get; set; }
+
+ public string? ImplementerFIO { get; set; }
+
+ public string? Password { get; set; }
+ }
+}
diff --git a/Shipyard/ShipyardContracts/SearchModels/OrderSearchModel.cs b/Shipyard/ShipyardContracts/SearchModels/OrderSearchModel.cs
index 318117e..77cb7c0 100644
--- a/Shipyard/ShipyardContracts/SearchModels/OrderSearchModel.cs
+++ b/Shipyard/ShipyardContracts/SearchModels/OrderSearchModel.cs
@@ -1,4 +1,5 @@
-using System;
+using ShipyardDataModels.Enums;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -10,8 +11,10 @@ namespace ShipyardContracts.SearchModels
{
public int? Id { get; set; }
public int? ClientId { get; set; }
+ public int? ImplementerId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
+ public OrderStatus? Status { get; set; }
}
}
diff --git a/Shipyard/ShipyardContracts/StoragesContracts/IImplementerStorage.cs b/Shipyard/ShipyardContracts/StoragesContracts/IImplementerStorage.cs
new file mode 100644
index 0000000..7544f5c
--- /dev/null
+++ b/Shipyard/ShipyardContracts/StoragesContracts/IImplementerStorage.cs
@@ -0,0 +1,26 @@
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.SearchModels;
+using ShipyardContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardContracts.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/Shipyard/ShipyardContracts/ViewModels/ImplementerViewModel.cs b/Shipyard/ShipyardContracts/ViewModels/ImplementerViewModel.cs
new file mode 100644
index 0000000..dac2447
--- /dev/null
+++ b/Shipyard/ShipyardContracts/ViewModels/ImplementerViewModel.cs
@@ -0,0 +1,27 @@
+using ShipyardDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardContracts.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/Shipyard/ShipyardContracts/ViewModels/OrderViewModel.cs b/Shipyard/ShipyardContracts/ViewModels/OrderViewModel.cs
index 76a5663..5cc48f0 100644
--- a/Shipyard/ShipyardContracts/ViewModels/OrderViewModel.cs
+++ b/Shipyard/ShipyardContracts/ViewModels/OrderViewModel.cs
@@ -19,6 +19,9 @@ namespace ShipyardContracts.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; }
[DisplayName("Сумма")]
diff --git a/Shipyard/ShipyardDataBaseImplement/Implements/ImplementerStorage.cs b/Shipyard/ShipyardDataBaseImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..e0f7c4f
--- /dev/null
+++ b/Shipyard/ShipyardDataBaseImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,106 @@
+using Microsoft.EntityFrameworkCore;
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.SearchModels;
+using ShipyardContracts.StoragesContracts;
+using ShipyardContracts.ViewModels;
+using ShipyardDataBaseImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardDataBaseImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ public ImplementerViewModel? Delete(ImplementerBindingModel model)
+ {
+ using var context = new ShipyardDataBase();
+ 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 ShipyardDataBase();
+ 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 ShipyardDataBase();
+ 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 ShipyardDataBase();
+ 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 ShipyardDataBase();
+ context.Implementers.Add(newImplementer);
+ context.SaveChanges();
+ return newImplementer.GetViewModel;
+ }
+
+ public ImplementerViewModel? Update(ImplementerBindingModel model)
+ {
+ using var context = new ShipyardDataBase();
+ 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/Shipyard/ShipyardDataBaseImplement/Implements/OrderStorage.cs b/Shipyard/ShipyardDataBaseImplement/Implements/OrderStorage.cs
index 738c2b7..29a526a 100644
--- a/Shipyard/ShipyardDataBaseImplement/Implements/OrderStorage.cs
+++ b/Shipyard/ShipyardDataBaseImplement/Implements/OrderStorage.cs
@@ -24,6 +24,7 @@ namespace ShipyardDataBaseImplement.Implements
var deletedElement = context.Orders
.Include(x => x.Ship)
.Include(x => x.Client)
+ .Include(x => x.Implementer)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Orders.Remove(element);
@@ -35,14 +36,33 @@ namespace ShipyardDataBaseImplement.Implements
public OrderViewModel? GetElement(OrderSearchModel model)
{
+ using var context = new ShipyardDataBase();
+ if (model.ImplementerId.HasValue && model.Status.HasValue)
+ {
+ return context.Orders
+ .Include(x => x.Ship)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status)
+ ?.GetViewModel;
+ }
+ if (model.ImplementerId.HasValue)
+ {
+ return context.Orders
+ .Include(x => x.Ship)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
+ .FirstOrDefault(x => x.ImplementerId == model.ImplementerId)
+ ?.GetViewModel;
+ }
if (!model.Id.HasValue)
{
return null;
}
- using var context = new ShipyardDataBase();
return context.Orders
- .Include(x=>x.Ship)
- .Include(x=>x.Client)
+ .Include(x => x.Ship)
+ .Include(x => x.Client)
+ .Include(x => x.Implementer)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
@@ -50,37 +70,37 @@ namespace ShipyardDataBaseImplement.Implements
public List GetFilteredList(OrderSearchModel model)
{
using var context = new ShipyardDataBase();
- if (model.Id.HasValue)
+ if (model.DateFrom.HasValue && model.DateTo.HasValue)
{
return context.Orders
- .Include(x => x.Ship)
- .Include(x => x.Client)
- .Where(x => x.Id == model.Id)
- .Select(x => x.GetViewModel)
- .ToList();
- }
- else if (model.DateFrom != null && model.DateTo != null)
- {
- return context.Orders
- .Include(x => x.Ship)
- .Include(x => x.Client)
- .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
- .Select(x => x.GetViewModel)
- .ToList();
+ .Include(x => x.Ship)
+ .Include(x => x.Client).Include(x => x.Implementer)
+ .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
+ .Select(x => x.GetViewModel)
+ .ToList();
}
else if (model.ClientId.HasValue)
- {
return context.Orders
.Include(x => x.Ship)
- .Include(x => x.Client)
+ .Include(x => x.Client).Include(x => x.Implementer)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
- }
- else
- {
- return new();
- }
+ else if (model.Status.HasValue)
+ return context.Orders
+ .Include(x => x.Ship)
+ .Include(x => x.Client).Include(x => x.Implementer)
+ .Where(x => x.Status == model.Status)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ else if (model.Id.HasValue)
+ return context.Orders
+ .Include(x => x.Ship)
+ .Include(x => x.Client).Include(x => x.Implementer)
+ .Where(x => x.Id == model.Id)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ return new();
}
public List GetFullList()
@@ -89,6 +109,7 @@ namespace ShipyardDataBaseImplement.Implements
return context.Orders
.Include(x => x.Ship)
.Include(x=>x.Client)
+ .Include(x => x.Implementer)
.Select(x => x.GetViewModel)
.ToList();
}
@@ -106,6 +127,7 @@ namespace ShipyardDataBaseImplement.Implements
return context.Orders
.Include(x => x.Ship)
.Include(x=>x.Client)
+ .Include(x => x.Implementer)
.FirstOrDefault(x => x.Id == newOrder.Id)
?.GetViewModel;
}
@@ -123,6 +145,7 @@ namespace ShipyardDataBaseImplement.Implements
return context.Orders
.Include(x => x.Ship)
.Include(x=>x.Client)
+ .Include(x => x.Implementer)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
diff --git a/Shipyard/ShipyardDataBaseImplement/Migrations/20230406114131_ImPlementer.Designer.cs b/Shipyard/ShipyardDataBaseImplement/Migrations/20230406114131_ImPlementer.Designer.cs
new file mode 100644
index 0000000..76da566
--- /dev/null
+++ b/Shipyard/ShipyardDataBaseImplement/Migrations/20230406114131_ImPlementer.Designer.cs
@@ -0,0 +1,257 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using ShipyardDataBaseImplement;
+
+#nullable disable
+
+namespace ShipyardDataBaseImplement.Migrations
+{
+ [DbContext(typeof(ShipyardDataBase))]
+ [Migration("20230406114131_ImPlementer")]
+ partial class ImPlementer
+ {
+ ///
+ 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("ShipyardDataBaseImplement.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("ShipyardDataBaseImplement.Models.Detail", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Cost")
+ .HasColumnType("float");
+
+ b.Property("DetailName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Details");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.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("ShipyardDataBaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClientId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("DateCreate")
+ .HasColumnType("datetime2");
+
+ b.Property("DateImplement")
+ .HasColumnType("datetime2");
+
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
+ b.Property("ShipId")
+ .HasColumnType("int");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("Sum")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("ImplementerId");
+
+ b.HasIndex("ShipId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Price")
+ .HasColumnType("float");
+
+ b.Property("ShipName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Ships");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShipDetail", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("DetailId")
+ .HasColumnType("int");
+
+ b.Property("ShipId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DetailId");
+
+ b.HasIndex("ShipId");
+
+ b.ToTable("ShipDetails");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.Order", b =>
+ {
+ b.HasOne("ShipyardDataBaseImplement.Models.Client", "Client")
+ .WithMany("Orders")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ShipyardDataBaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
+ b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship")
+ .WithMany("Orders")
+ .HasForeignKey("ShipId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Client");
+
+ b.Navigation("Implementer");
+
+ b.Navigation("Ship");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShipDetail", b =>
+ {
+ b.HasOne("ShipyardDataBaseImplement.Models.Detail", "Detail")
+ .WithMany("ShipDetails")
+ .HasForeignKey("DetailId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship")
+ .WithMany("Details")
+ .HasForeignKey("ShipId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Detail");
+
+ b.Navigation("Ship");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.Client", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.Detail", b =>
+ {
+ b.Navigation("ShipDetails");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b =>
+ {
+ b.Navigation("Details");
+
+ b.Navigation("Orders");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Shipyard/ShipyardDataBaseImplement/Migrations/20230406114131_ImPlementer.cs b/Shipyard/ShipyardDataBaseImplement/Migrations/20230406114131_ImPlementer.cs
new file mode 100644
index 0000000..fe1d135
--- /dev/null
+++ b/Shipyard/ShipyardDataBaseImplement/Migrations/20230406114131_ImPlementer.cs
@@ -0,0 +1,67 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace ShipyardDataBaseImplement.Migrations
+{
+ ///
+ public partial class ImPlementer : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "ImplementerId",
+ table: "Orders",
+ type: "int",
+ nullable: true);
+
+ migrationBuilder.CreateTable(
+ name: "Implementers",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false),
+ Password = table.Column(type: "nvarchar(max)", nullable: false),
+ WorkExperience = table.Column(type: "int", nullable: false),
+ Qualification = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Implementers", x => x.Id);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ table: "Orders",
+ column: "ImplementerId",
+ principalTable: "Implementers",
+ principalColumn: "Id");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Orders_Implementers_ImplementerId",
+ table: "Orders");
+
+ migrationBuilder.DropTable(
+ name: "Implementers");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Orders_ImplementerId",
+ table: "Orders");
+
+ migrationBuilder.DropColumn(
+ name: "ImplementerId",
+ table: "Orders");
+ }
+ }
+}
diff --git a/Shipyard/ShipyardDataBaseImplement/Migrations/ShipyardDataBaseModelSnapshot.cs b/Shipyard/ShipyardDataBaseImplement/Migrations/ShipyardDataBaseModelSnapshot.cs
index 220858d..5476258 100644
--- a/Shipyard/ShipyardDataBaseImplement/Migrations/ShipyardDataBaseModelSnapshot.cs
+++ b/Shipyard/ShipyardDataBaseImplement/Migrations/ShipyardDataBaseModelSnapshot.cs
@@ -67,6 +67,33 @@ namespace ShipyardDataBaseImplement.Migrations
b.ToTable("Details");
});
+ modelBuilder.Entity("ShipyardDataBaseImplement.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("ShipyardDataBaseImplement.Models.Order", b =>
{
b.Property("Id")
@@ -87,6 +114,9 @@ namespace ShipyardDataBaseImplement.Migrations
b.Property("DateImplement")
.HasColumnType("datetime2");
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
b.Property("ShipId")
.HasColumnType("int");
@@ -100,6 +130,8 @@ namespace ShipyardDataBaseImplement.Migrations
b.HasIndex("ClientId");
+ b.HasIndex("ImplementerId");
+
b.HasIndex("ShipId");
b.ToTable("Orders");
@@ -159,6 +191,10 @@ namespace ShipyardDataBaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+ b.HasOne("ShipyardDataBaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship")
.WithMany("Orders")
.HasForeignKey("ShipId")
@@ -167,6 +203,8 @@ namespace ShipyardDataBaseImplement.Migrations
b.Navigation("Client");
+ b.Navigation("Implementer");
+
b.Navigation("Ship");
});
@@ -199,6 +237,11 @@ namespace ShipyardDataBaseImplement.Migrations
b.Navigation("ShipDetails");
});
+ modelBuilder.Entity("ShipyardDataBaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
+
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b =>
{
b.Navigation("Details");
diff --git a/Shipyard/ShipyardDataBaseImplement/Models/Implementer.cs b/Shipyard/ShipyardDataBaseImplement/Models/Implementer.cs
new file mode 100644
index 0000000..75e0517
--- /dev/null
+++ b/Shipyard/ShipyardDataBaseImplement/Models/Implementer.cs
@@ -0,0 +1,80 @@
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.ViewModels;
+using ShipyardDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardDataBaseImplement.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/Shipyard/ShipyardDataBaseImplement/Models/Order.cs b/Shipyard/ShipyardDataBaseImplement/Models/Order.cs
index d67c4c9..5d535eb 100644
--- a/Shipyard/ShipyardDataBaseImplement/Models/Order.cs
+++ b/Shipyard/ShipyardDataBaseImplement/Models/Order.cs
@@ -17,6 +17,7 @@ namespace ShipyardDataBaseImplement.Models
public int ShipId { get; set; }
[Required]
public int ClientId { get; set; }
+ public int? ImplementerId { get; set; }
[Required]
public int Count { get; set; }
[Required]
@@ -31,6 +32,7 @@ namespace ShipyardDataBaseImplement.Models
public int Id { get; set; }
public virtual Ship Ship { get; set; }
public virtual Client Client { get; set; }
+ public virtual Implementer? Implementer { get; set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
@@ -42,6 +44,7 @@ namespace ShipyardDataBaseImplement.Models
Id = model.Id,
ShipId = model.ShipId,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@@ -58,6 +61,7 @@ namespace ShipyardDataBaseImplement.Models
}
Status = model.Status;
DateImplement = model.DateImplement;
+ ImplementerId = model.ImplementerId;
}
public OrderViewModel GetViewModel => new()
@@ -65,7 +69,9 @@ namespace ShipyardDataBaseImplement.Models
Id = Id,
ShipId = ShipId,
ClientId=ClientId,
- ClientFIO=Client.ClientFIO,
+ ImplementerId = ImplementerId,
+ ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
+ ClientFIO =Client.ClientFIO,
Count = Count,
Sum = Sum,
Status = Status,
diff --git a/Shipyard/ShipyardDataBaseImplement/ShipyardDataBase.cs b/Shipyard/ShipyardDataBaseImplement/ShipyardDataBase.cs
index 13ca744..227a4e4 100644
--- a/Shipyard/ShipyardDataBaseImplement/ShipyardDataBase.cs
+++ b/Shipyard/ShipyardDataBaseImplement/ShipyardDataBase.cs
@@ -24,6 +24,8 @@ namespace ShipyardDataBaseImplement
public virtual DbSet ShipDetails { set; get; }
public virtual DbSet Orders { set; get; }
public virtual DbSet Clients { set; get; }
+
+ public virtual DbSet Implementers { set; get; }
}
}
diff --git a/Shipyard/ShipyardDataModels/Models/IImplementerModel.cs b/Shipyard/ShipyardDataModels/Models/IImplementerModel.cs
new file mode 100644
index 0000000..0e38361
--- /dev/null
+++ b/Shipyard/ShipyardDataModels/Models/IImplementerModel.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardDataModels.Models
+{
+ public interface IImplementerModel : IId
+ {
+ string ImplementerFIO { get; }
+
+ string Password { get; }
+
+ int WorkExperience { get; }
+
+ int Qualification { get; }
+ }
+}
diff --git a/Shipyard/ShipyardDataModels/Models/IOrderModel.cs b/Shipyard/ShipyardDataModels/Models/IOrderModel.cs
index 0ad1d49..59b3e9a 100644
--- a/Shipyard/ShipyardDataModels/Models/IOrderModel.cs
+++ b/Shipyard/ShipyardDataModels/Models/IOrderModel.cs
@@ -11,6 +11,7 @@ namespace ShipyardDataModels.Models
{
int ShipId { get; }
int ClientId { get; }
+ int? ImplementerId { get; }
int Count { get; }
double Sum { get; }
OrderStatus Status { get; }
diff --git a/Shipyard/ShipyardFileImplement/DataFileSingleton.cs b/Shipyard/ShipyardFileImplement/DataFileSingleton.cs
index ffad238..43a3da0 100644
--- a/Shipyard/ShipyardFileImplement/DataFileSingleton.cs
+++ b/Shipyard/ShipyardFileImplement/DataFileSingleton.cs
@@ -16,10 +16,13 @@ namespace ShipyardFileImplement
private readonly string OrderFileName = "Order.xml";
private readonly string ShipFileName = "Ship.xml";
private readonly string ClientFileName = "Client.xml";
+ private readonly string ImplementerFileName = "Implementer.xml";
+
public List Details { get; private set; }
public List Orders { get; private set; }
public List Ships { get; private set; }
public List Clients { get; private set; }
+ public List Implementers { get; private set; }
public static DataFileSingleton GetInstance()
{
if (instance == null)
@@ -32,12 +35,14 @@ namespace ShipyardFileImplement
public void SaveShips() => SaveData(Ships, ShipFileName,"Ships", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x=> x.GetXElement);
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
+ public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
private DataFileSingleton()
{
Details = LoadData(DetailFileName, "Detail", x => Detail.Create(x)!)!;
Ships = LoadData(ShipFileName, "Ship", x => Ship.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
+ Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
}
private static List? LoadData(string filename, string xmlNodeName,
Func selectFunction)
diff --git a/Shipyard/ShipyardFileImplement/Implements/ImplementerStorage.cs b/Shipyard/ShipyardFileImplement/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..7968fe4
--- /dev/null
+++ b/Shipyard/ShipyardFileImplement/Implements/ImplementerStorage.cs
@@ -0,0 +1,88 @@
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.SearchModels;
+using ShipyardContracts.StoragesContracts;
+using ShipyardContracts.ViewModels;
+using ShipyardFileImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardFileImplement.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ private readonly DataFileSingleton source;
+ public ImplementerStorage()
+ {
+ source = DataFileSingleton.GetInstance();
+ }
+ public ImplementerViewModel? Delete(ImplementerBindingModel model)
+ {
+ var element = source.Implementers.FirstOrDefault(x => x.Id == model.Id);
+ if (element != null)
+ {
+ source.Implementers.Remove(element);
+ source.SaveImplementers();
+ return element.GetViewModel;
+ }
+ return null;
+ }
+
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ if (model.Id.HasValue)
+ {
+ return source.Implementers
+ .FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel;
+ }
+ else if (!string.IsNullOrEmpty(model.ImplementerFIO) && !string.IsNullOrEmpty(model.Password))
+ {
+ return source.Implementers
+ .FirstOrDefault(x => (x.ImplementerFIO == model.ImplementerFIO && x.Password == model.Password))?.GetViewModel;
+ }
+ return new();
+ }
+
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ return new();
+ }
+ return source.Implementers.Where(x =>
+ x.ImplementerFIO.Contains(model.ImplementerFIO)).Select(x => x.GetViewModel).ToList();
+ }
+
+ public 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 newImplementer = Implementer.Create(model);
+ if (newImplementer == null)
+ {
+ return null;
+ }
+ source.Implementers.Add(newImplementer);
+ source.SaveImplementers();
+ return newImplementer.GetViewModel;
+ }
+
+ public ImplementerViewModel? Update(ImplementerBindingModel model)
+ {
+ var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.Id);
+ if (implementer == null)
+ {
+ return null;
+ }
+ implementer.Update(model);
+ source.SaveImplementers();
+ return implementer.GetViewModel;
+ }
+ }
+}
diff --git a/Shipyard/ShipyardFileImplement/Implements/OrderStorage.cs b/Shipyard/ShipyardFileImplement/Implements/OrderStorage.cs
index 3e95b78..73e916a 100644
--- a/Shipyard/ShipyardFileImplement/Implements/OrderStorage.cs
+++ b/Shipyard/ShipyardFileImplement/Implements/OrderStorage.cs
@@ -47,18 +47,30 @@ namespace ShipyardFileImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
+ else if (model.ImplementerId.HasValue)
+ {
+ return source.Orders
+ .Where(x => x.ImplementerId == model.ImplementerId)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
return new();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
- if (!model.Id.HasValue)
+ if (model.Id.HasValue)
{
- return null;
- }
-
- return source.Orders.FirstOrDefault(x =>
+ return source.Orders.FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
+ }
+ else if (model.ImplementerId.HasValue)
+ {
+ return source.Orders.FirstOrDefault(x =>
+ (x.ImplementerId == model.ImplementerId))?.GetViewModel;
+ }
+ return null;
+
}
private OrderViewModel GetViewModel(Order order)
{
diff --git a/Shipyard/ShipyardFileImplement/Models/Implementer.cs b/Shipyard/ShipyardFileImplement/Models/Implementer.cs
new file mode 100644
index 0000000..a21a45a
--- /dev/null
+++ b/Shipyard/ShipyardFileImplement/Models/Implementer.cs
@@ -0,0 +1,81 @@
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.ViewModels;
+using ShipyardDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace ShipyardFileImplement.Models
+{
+ public class Implementer : IImplementerModel
+ {
+ public string ImplementerFIO { get; set; } = String.Empty;
+
+ public string Password { get; set; } = String.Empty;
+
+ public int WorkExperience { get; set; }
+
+ public int Qualification { get; set; }
+
+ public int Id { get; set; }
+
+ public static Implementer? Create(ImplementerBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Implementer()
+ {
+ Id = model.Id,
+ ImplementerFIO = model.ImplementerFIO,
+ Password = model.Password,
+ WorkExperience = model.WorkExperience,
+ Qualification = model.Qualification
+ };
+ }
+ public static Implementer? Create(XElement element)
+ {
+ if (element == null)
+ {
+ return null;
+ }
+ return new Implementer()
+ {
+ Id = Convert.ToInt32(element.Attribute("Id")!.Value),
+ ImplementerFIO = element.Element("ImplementerFIO")!.Value,
+ Password = element.Element("Password")!.Value,
+ WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value),
+ Qualification = Convert.ToInt32(element.Element("Qualification")!.Value)
+ };
+ }
+ public void Update(ImplementerBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ImplementerFIO = model.ImplementerFIO;
+ Password = model.Password;
+ WorkExperience = model.WorkExperience;
+ Qualification = model.Qualification;
+ }
+ public ImplementerViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ImplementerFIO = ImplementerFIO,
+ Password = Password,
+ WorkExperience = WorkExperience,
+ Qualification = Qualification
+ };
+ public XElement GetXElement => new("Implementer",
+ new XAttribute("Id", Id),
+ new XElement("ImplementerFIO", ImplementerFIO),
+ new XElement("Password", Password),
+ new XElement("WorkExperience", WorkExperience),
+ new XElement("Qualification", Qualification));
+ }
+}
diff --git a/Shipyard/ShipyardFileImplement/Models/Order.cs b/Shipyard/ShipyardFileImplement/Models/Order.cs
index d978be9..a780a0e 100644
--- a/Shipyard/ShipyardFileImplement/Models/Order.cs
+++ b/Shipyard/ShipyardFileImplement/Models/Order.cs
@@ -11,6 +11,7 @@ namespace ShipyardFileImplement.Models
public int Id { get; private set; }
public int ShipId { get; private set; }
public int ClientId { get; private set; }
+ public int? ImplementerId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@@ -27,6 +28,7 @@ namespace ShipyardFileImplement.Models
Id = model.Id,
ShipId = model.ShipId,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@@ -46,6 +48,7 @@ namespace ShipyardFileImplement.Models
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ShipId = Convert.ToInt32(element.Element("ShipId")!.Value),
ClientId=Convert.ToInt32(element.Element("ClientId")!.Value),
+ ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
@@ -75,6 +78,7 @@ namespace ShipyardFileImplement.Models
{
ShipId = ShipId,
ClientId = ClientId,
+ ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
DateCreate = DateCreate,
@@ -87,11 +91,14 @@ namespace ShipyardFileImplement.Models
new XAttribute("Id", Id),
new XElement("ShipId", ShipId),
new XElement("ClientId", ClientId),
+ new XElement("ImplementerId", ImplementerId),
new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),
new XElement("DateCreate", DateCreate.ToString()),
new XElement("DateImplement", DateImplement.ToString()));
+
+
}
}
diff --git a/Shipyard/ShipyardListImplement»/DataListSingleton.cs b/Shipyard/ShipyardListImplement»/DataListSingleton.cs
index 17f99c8..7e12966 100644
--- a/Shipyard/ShipyardListImplement»/DataListSingleton.cs
+++ b/Shipyard/ShipyardListImplement»/DataListSingleton.cs
@@ -1,4 +1,5 @@
using ShipyardListImplement.Models;
+using ShipyardListImplement_.Models;
namespace ShipyardListImplement
{
@@ -9,12 +10,15 @@ namespace ShipyardListImplement
public List Orders { get; set; }
public List Ships { get; set; }
public List Clients { get; set; }
+
+ public List Implementers { get; set; }
private DataListSingleton()
{
Details = new List();
Orders = new List();
Ships = new List();
Clients = new List();
+ Implementers = new List();
}
public static DataListSingleton GetInstance()
{
diff --git a/Shipyard/ShipyardListImplement»/Implements/ImplementerStorage.cs b/Shipyard/ShipyardListImplement»/Implements/ImplementerStorage.cs
new file mode 100644
index 0000000..bdbab84
--- /dev/null
+++ b/Shipyard/ShipyardListImplement»/Implements/ImplementerStorage.cs
@@ -0,0 +1,122 @@
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.SearchModels;
+using ShipyardContracts.StoragesContracts;
+using ShipyardContracts.ViewModels;
+using ShipyardListImplement;
+using ShipyardListImplement.Models;
+using ShipyardListImplement_.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShipyardListImplement_.Implements
+{
+ public class ImplementerStorage : IImplementerStorage
+ {
+ private readonly DataListSingleton _source;
+ public ImplementerStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public ImplementerViewModel? Delete(ImplementerBindingModel model)
+ {
+ for (int i = 0; i < _source.Implementers.Count; ++i)
+ {
+ if (_source.Implementers[i].Id == model.Id)
+ {
+ var element = _source.Implementers[i];
+ _source.Implementers.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public ImplementerViewModel? GetElement(ImplementerSearchModel model)
+ {
+ if (model.Id.HasValue)
+ {
+ foreach (var implementer in _source.Implementers)
+ {
+ if (implementer.Id == model.Id)
+ {
+ return implementer.GetViewModel;
+ }
+ }
+ }
+ else if (!string.IsNullOrEmpty(model.ImplementerFIO) && !string.IsNullOrEmpty(model.Password))
+ {
+ foreach (var implementer in _source.Implementers)
+ {
+ if (implementer.ImplementerFIO == model.ImplementerFIO && implementer.Password == model.Password)
+ {
+ return implementer.GetViewModel;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public List GetFilteredList(ImplementerSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ImplementerFIO))
+ {
+ return result;
+ }
+ foreach (var implementer in _source.Implementers)
+ {
+ if (implementer.ImplementerFIO.Contains(model.ImplementerFIO))
+ {
+ result.Add(implementer.GetViewModel);
+ }
+ }
+ return result;
+ }
+
+ public 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 newImplementer = Implementer.Create(model);
+ if (newImplementer == null)
+ {
+ return null;
+ }
+ _source.Implementers.Add(newImplementer);
+ return newImplementer.GetViewModel;
+ }
+
+ public ImplementerViewModel? Update(ImplementerBindingModel model)
+ {
+ foreach (var implementer in _source.Implementers)
+ {
+ if (implementer.Id == model.Id)
+ {
+ implementer.Update(model);
+ return implementer.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/Shipyard/ShipyardListImplement»/Implements/OrderStorage.cs b/Shipyard/ShipyardListImplement»/Implements/OrderStorage.cs
index 0c605f5..ca1fd53 100644
--- a/Shipyard/ShipyardListImplement»/Implements/OrderStorage.cs
+++ b/Shipyard/ShipyardListImplement»/Implements/OrderStorage.cs
@@ -61,7 +61,17 @@ namespace ShipyardListImplement.Implements
}
}
}
-
+ else if (model.ImplementerId.HasValue)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.ImplementerId == model.ImplementerId)
+ {
+ result.Add(GetViewModel(order));
+ }
+ }
+ }
+
return result;
}
public OrderViewModel? GetElement(OrderSearchModel model)
@@ -76,6 +86,10 @@ namespace ShipyardListImplement.Implements
{
return GetViewModel(order);
}
+ else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId)
+ {
+ return GetViewModel(order);
+ }
}
return null;
}
diff --git a/Shipyard/ShipyardListImplement»/Models/Implementer.cs b/Shipyard/ShipyardListImplement»/Models/Implementer.cs
new file mode 100644
index 0000000..1f51406
--- /dev/null
+++ b/Shipyard/ShipyardListImplement»/Models/Implementer.cs
@@ -0,0 +1,62 @@
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.ViewModels;
+using ShipyardDataModels.Models;
+using ShipyardListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace ShipyardListImplement_.Models
+{
+ public class Implementer : IImplementerModel
+ {
+ public string ImplementerFIO { get; set; } = String.Empty;
+
+ public string Password { get; set; } = String.Empty;
+
+ public int WorkExperience { get; set; }
+
+ public int Qualification { get; set; }
+
+ public int Id { get; set; }
+ public static Implementer? Create(ImplementerBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Implementer()
+ {
+ Id = model.Id,
+ ImplementerFIO = model.ImplementerFIO,
+ Password = model.Password,
+ WorkExperience = model.WorkExperience,
+ Qualification = model.Qualification
+ };
+ }
+
+ public void Update(ImplementerBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ImplementerFIO = model.ImplementerFIO;
+ Password = model.Password;
+ WorkExperience = model.WorkExperience;
+ Qualification = model.Qualification;
+ }
+ public ImplementerViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ImplementerFIO = ImplementerFIO,
+ Password = Password,
+ WorkExperience = WorkExperience,
+ Qualification = Qualification
+ };
+
+ }
+}
diff --git a/Shipyard/ShipyardListImplement»/Models/Order.cs b/Shipyard/ShipyardListImplement»/Models/Order.cs
index b2ab133..69bb7a5 100644
--- a/Shipyard/ShipyardListImplement»/Models/Order.cs
+++ b/Shipyard/ShipyardListImplement»/Models/Order.cs
@@ -17,6 +17,7 @@ namespace ShipyardListImplement.Models
public int Id { get; private set; }
public int ShipId { get; private set; }
public int ClientId {get; private set; }
+ public int? ImplementerId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@@ -34,6 +35,7 @@ namespace ShipyardListImplement.Models
Id = model.Id,
ShipId = model.ShipId,
ClientId = model.ClientId,
+ ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@@ -55,6 +57,7 @@ namespace ShipyardListImplement.Models
Id = Id,
ShipId = ShipId,
ClientId = ClientId,
+ ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
Status = Status,
diff --git a/Shipyard/ShipyardRestApi/Controllers/ImplementerController.cs b/Shipyard/ShipyardRestApi/Controllers/ImplementerController.cs
new file mode 100644
index 0000000..78a3003
--- /dev/null
+++ b/Shipyard/ShipyardRestApi/Controllers/ImplementerController.cs
@@ -0,0 +1,106 @@
+using Microsoft.AspNetCore.Mvc;
+using ShipyardContracts.BindingModels;
+using ShipyardContracts.BusinessLogicsContracts;
+using ShipyardContracts.SearchModels;
+using ShipyardContracts.ViewModels;
+
+namespace ShipyardRestApi.Controllers
+{
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ public class ImplementerController : Controller
+ {
+ private readonly ILogger _logger;
+
+ private readonly IOrderLogic _order;
+
+ private readonly IImplementerLogic _logic;
+
+ public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger logger)
+ {
+ _logger = logger;
+ _order = order;
+ _logic = logic;
+ }
+
+ [HttpGet]
+ public ImplementerViewModel? Login(string login, string password)
+ {
+ try
+ {
+ return _logic.ReadElement(new ImplementerSearchModel
+ {
+ ImplementerFIO = login,
+ Password = password
+ });
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка авторизации сотрудника");
+ throw;
+ }
+ }
+
+ [HttpGet]
+ public List? GetNewOrders()
+ {
+ try
+ {
+ return _order.ReadList(new OrderSearchModel
+ {
+ //Status = OrderStatus.Принят
+ });
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения новых заказов");
+ throw;
+ }
+ }
+
+ [HttpGet]
+ public OrderViewModel? GetImplementerOrder(int implementerId)
+ {
+ try
+ {
+ return _order.ReadElement(new OrderSearchModel
+ {
+ //ImplementerId = implementerId
+ });
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
+ throw;
+ }
+ }
+
+ [HttpPost]
+ public void TakeOrderInWork(OrderBindingModel model)
+ {
+ try
+ {
+ _order.TakeOrderInWork(model);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу", model.Id);
+ throw;
+ }
+ }
+
+ [HttpPost]
+ public void FinishOrder(OrderBindingModel model)
+ {
+ try
+ {
+ _order.FinishOrder(model);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа с №{Id}", model.Id);
+ throw;
+ }
+ }
+ }
+}
diff --git a/Shipyard/ShipyardRestApi/Program.cs b/Shipyard/ShipyardRestApi/Program.cs
index 367b05a..13042fc 100644
--- a/Shipyard/ShipyardRestApi/Program.cs
+++ b/Shipyard/ShipyardRestApi/Program.cs
@@ -13,10 +13,13 @@ builder.Logging.AddLog4Net("log4net.config");
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
+
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();