diff --git a/FurnitureAssembly/Form1.Designer.cs b/FurnitureAssembly/Form1.Designer.cs
deleted file mode 100644
index 83ebd63..0000000
--- a/FurnitureAssembly/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace FurnitureAssembly
-{
- partial class Form1
- {
- ///
- /// 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.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/FurnitureAssembly/Form1.cs b/FurnitureAssembly/Form1.cs
deleted file mode 100644
index c186dd4..0000000
--- a/FurnitureAssembly/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace FurnitureAssembly
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/FurnitureAssembly/FormComponent.Designer.cs b/FurnitureAssembly/FormComponent.Designer.cs
new file mode 100644
index 0000000..1e7f2ab
--- /dev/null
+++ b/FurnitureAssembly/FormComponent.Designer.cs
@@ -0,0 +1,127 @@
+namespace FurnitureAssembly
+{
+ partial class FormComponent
+ {
+ ///
+ /// 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.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.labelName = new System.Windows.Forms.Label();
+ this.textBoxCost = new System.Windows.Forms.TextBox();
+ this.labelCost = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(257, 71);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(88, 27);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(162, 71);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(88, 27);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(91, 7);
+ this.textBoxName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(252, 23);
+ this.textBoxName.TabIndex = 1;
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(14, 10);
+ this.labelName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(62, 15);
+ this.labelName.TabIndex = 0;
+ this.labelName.Text = "Название:";
+ //
+ // textBoxCost
+ //
+ this.textBoxCost.Location = new System.Drawing.Point(91, 36);
+ this.textBoxCost.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.textBoxCost.Name = "textBoxCost";
+ this.textBoxCost.Size = new System.Drawing.Size(129, 23);
+ this.textBoxCost.TabIndex = 3;
+ //
+ // labelCost
+ //
+ this.labelCost.AutoSize = true;
+ this.labelCost.Location = new System.Drawing.Point(14, 39);
+ this.labelCost.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.labelCost.Name = "labelCost";
+ this.labelCost.Size = new System.Drawing.Size(38, 15);
+ this.labelCost.TabIndex = 2;
+ this.labelCost.Text = "Цена:";
+ //
+ // FormComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(360, 110);
+ this.Controls.Add(this.textBoxCost);
+ this.Controls.Add(this.labelCost);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelName);
+ this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.Name = "FormComponent";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Компонент";
+ this.Load += new System.EventHandler(this.FormComponent_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button buttonCancel;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.TextBox textBoxName;
+ private System.Windows.Forms.Label labelName;
+ private TextBox textBoxCost;
+ private Label labelCost;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FormComponent.cs b/FurnitureAssembly/FormComponent.cs
new file mode 100644
index 0000000..3de89e9
--- /dev/null
+++ b/FurnitureAssembly/FormComponent.cs
@@ -0,0 +1,94 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.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 FurnitureAssembly
+{
+ public partial class FormComponent : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IComponentLogic _logic;
+
+ private int? _id;
+
+ public int Id { set { _id = value; } }
+
+ public FormComponent(ILogger logger, IComponentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormComponent_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение компонента");
+ var view = _logic.ReadElement(new ComponentSearchModel { Id = _id.Value });
+ if (view != null)
+ {
+ textBoxName.Text = view.ComponentName;
+ textBoxCost.Text = view.Cost.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(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение компонента");
+ try
+ {
+ var model = new ComponentBindingModel
+ {
+ Id = _id ?? 0,
+ ComponentName = textBoxName.Text,
+ Cost = Convert.ToDouble(textBoxCost.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/FurnitureAssembly/FormComponent.resx b/FurnitureAssembly/FormComponent.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FurnitureAssembly/FormComponent.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FormComponents.Designer.cs b/FurnitureAssembly/FormComponents.Designer.cs
new file mode 100644
index 0000000..d88031b
--- /dev/null
+++ b/FurnitureAssembly/FormComponents.Designer.cs
@@ -0,0 +1,122 @@
+namespace FurnitureAssembly
+{
+ partial class FormComponents
+ {
+ ///
+ /// 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.Location = new System.Drawing.Point(370, 132);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(75, 23);
+ this.buttonRef.TabIndex = 4;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(370, 91);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(75, 23);
+ this.buttonDel.TabIndex = 3;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Location = new System.Drawing.Point(370, 50);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(75, 23);
+ this.buttonUpd.TabIndex = 2;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(370, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(75, 23);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.AllowUserToAddRows = false;
+ this.dataGridView.AllowUserToDeleteRows = false;
+ this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
+ 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.MultiSelect = false;
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.ReadOnly = true;
+ this.dataGridView.RowHeadersVisible = false;
+ this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this.dataGridView.Size = new System.Drawing.Size(350, 312);
+ this.dataGridView.TabIndex = 0;
+ //
+ // FormComponents
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(464, 312);
+ 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 = "FormComponents";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Компоненты";
+ this.Load += new System.EventHandler(this.FormComponents_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button buttonRef;
+ private System.Windows.Forms.Button buttonDel;
+ private System.Windows.Forms.Button buttonUpd;
+ private System.Windows.Forms.Button buttonAdd;
+ private System.Windows.Forms.DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FormComponents.cs b/FurnitureAssembly/FormComponents.cs
new file mode 100644
index 0000000..637d24a
--- /dev/null
+++ b/FurnitureAssembly/FormComponents.cs
@@ -0,0 +1,112 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FurnitureAssembly
+{
+ public partial class FormComponents : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IComponentLogic _logic;
+
+ public FormComponents(ILogger logger, IComponentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormComponents_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["ComponentName"].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(FormComponent));
+ if (service is FormComponent 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(FormComponent));
+ if (service is FormComponent 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 ComponentBindingModel { 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/FurnitureAssembly/FormComponents.resx b/FurnitureAssembly/FormComponents.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FurnitureAssembly/FormComponents.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FormCreateOrder.Designer.cs b/FurnitureAssembly/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..1fa37ba
--- /dev/null
+++ b/FurnitureAssembly/FormCreateOrder.Designer.cs
@@ -0,0 +1,146 @@
+namespace FurnitureAssembly
+{
+ partial class FormCreateOrder
+ {
+ ///
+ /// 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.labelCount = new System.Windows.Forms.Label();
+ this.comboBoxProduct = new System.Windows.Forms.ComboBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.labelProduct = new System.Windows.Forms.Label();
+ this.labelSum = new System.Windows.Forms.Label();
+ this.textBoxSum = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(12, 36);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(69, 13);
+ this.labelCount.TabIndex = 2;
+ this.labelCount.Text = "Количество:";
+ //
+ // comboBoxProduct
+ //
+ this.comboBoxProduct.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxProduct.FormattingEnabled = true;
+ this.comboBoxProduct.Location = new System.Drawing.Point(87, 6);
+ this.comboBoxProduct.Name = "comboBoxProduct";
+ this.comboBoxProduct.Size = new System.Drawing.Size(217, 21);
+ this.comboBoxProduct.TabIndex = 1;
+ this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ProductComboBox_SelectedIndexChanged);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(219, 85);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 7;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(138, 85);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.SaveButton_Click);
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(87, 33);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(217, 20);
+ this.textBoxCount.TabIndex = 3;
+ this.textBoxCount.TextChanged += new System.EventHandler(this.CountTextBox_TextChanged);
+ //
+ // labelProduct
+ //
+ this.labelProduct.AutoSize = true;
+ this.labelProduct.Location = new System.Drawing.Point(12, 9);
+ this.labelProduct.Name = "labelProduct";
+ this.labelProduct.Size = new System.Drawing.Size(54, 13);
+ this.labelProduct.TabIndex = 0;
+ this.labelProduct.Text = "Изделие:";
+ //
+ // labelSum
+ //
+ this.labelSum.AutoSize = true;
+ this.labelSum.Location = new System.Drawing.Point(12, 62);
+ this.labelSum.Name = "labelSum";
+ this.labelSum.Size = new System.Drawing.Size(44, 13);
+ this.labelSum.TabIndex = 4;
+ this.labelSum.Text = "Сумма:";
+ //
+ // textBoxSum
+ //
+ this.textBoxSum.Location = new System.Drawing.Point(87, 59);
+ this.textBoxSum.Name = "textBoxSum";
+ this.textBoxSum.ReadOnly = true;
+ this.textBoxSum.Size = new System.Drawing.Size(217, 20);
+ this.textBoxSum.TabIndex = 5;
+ //
+ // FormCreateOrder
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(318, 118);
+ this.Controls.Add(this.labelSum);
+ this.Controls.Add(this.textBoxSum);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.comboBoxProduct);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.labelProduct);
+ this.Name = "FormCreateOrder";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Заказ";
+ this.Load += new System.EventHandler(this.FormCreateOrder_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+ private System.Windows.Forms.Label labelCount;
+ private System.Windows.Forms.ComboBox comboBoxProduct;
+ private System.Windows.Forms.Button buttonCancel;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.TextBox textBoxCount;
+ private System.Windows.Forms.Label labelProduct;
+ private System.Windows.Forms.Label labelSum;
+ private System.Windows.Forms.TextBox textBoxSum;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FormCreateOrder.cs b/FurnitureAssembly/FormCreateOrder.cs
new file mode 100644
index 0000000..5ef892d
--- /dev/null
+++ b/FurnitureAssembly/FormCreateOrder.cs
@@ -0,0 +1,143 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.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 FurnitureAssembly
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IProductLogic _logicP;
+ private readonly IOrderLogic _logicO;
+
+ public FormCreateOrder(ILogger logger, IProductLogic logicP, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicO = logicO;
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка изделий для заказа");
+
+ try
+ {
+ var list = _logicP.ReadList(null);
+ if (list != null)
+ {
+ comboBoxProduct.DisplayMember = "ProductName";
+ comboBoxProduct.ValueMember = "Id";
+ comboBoxProduct.DataSource = list;
+ comboBoxProduct.SelectedItem = null;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки списка изделий");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void CalcSum()
+ {
+ if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxProduct.SelectedValue);
+
+ var Product = _logicP.ReadElement(new ProductSearchModel
+ {
+ Id = id
+ });
+
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (Product?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void CountTextBox_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void ProductComboBox_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void SaveButton_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (comboBoxProduct.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Создание заказа");
+
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ ProductId = Convert.ToInt32(comboBoxProduct.SelectedValue),
+ ProductName = comboBoxProduct.Text,
+ Count = Convert.ToInt32(textBoxCount.Text),
+ Sum = Convert.ToDouble(textBoxSum.Text)
+ });
+
+ 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/FurnitureAssembly/FormCreateOrder.resx b/FurnitureAssembly/FormCreateOrder.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FurnitureAssembly/FormCreateOrder.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FormMain.Designer.cs b/FurnitureAssembly/FormMain.Designer.cs
new file mode 100644
index 0000000..70cd6c2
--- /dev/null
+++ b/FurnitureAssembly/FormMain.Designer.cs
@@ -0,0 +1,184 @@
+namespace FurnitureAssembly
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #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.MenuStrip = new System.Windows.Forms.MenuStrip();
+ this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.DataGridView = new System.Windows.Forms.DataGridView();
+ this.CreateOrderButton = new System.Windows.Forms.Button();
+ this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
+ this.OrderReadyButton = new System.Windows.Forms.Button();
+ this.IssuedOrderButton = new System.Windows.Forms.Button();
+ this.UpdateListButton = new System.Windows.Forms.Button();
+ this.MenuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // MenuStrip
+ //
+ this.MenuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.СправочникиToolStripMenuItem});
+ this.MenuStrip.Location = new System.Drawing.Point(0, 0);
+ this.MenuStrip.Name = "MenuStrip";
+ this.MenuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
+ this.MenuStrip.Size = new System.Drawing.Size(989, 30);
+ this.MenuStrip.TabIndex = 0;
+ this.MenuStrip.Text = "menuStrip1";
+ //
+ // СправочникиToolStripMenuItem
+ //
+ this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.ИзделияToolStripMenuItem,
+ this.КомпонентыToolStripMenuItem});
+ this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
+ this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
+ this.СправочникиToolStripMenuItem.Text = "Cправочники";
+ //
+ // Изделия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);
+ //
+ // Компоненты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);
+ //
+ // DataGridView
+ //
+ this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.DataGridView.Location = new System.Drawing.Point(0, 36);
+ 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(825, 561);
+ this.DataGridView.TabIndex = 1;
+ //
+ // CreateOrderButton
+ //
+ this.CreateOrderButton.Location = new System.Drawing.Point(832, 37);
+ this.CreateOrderButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.CreateOrderButton.Name = "CreateOrderButton";
+ this.CreateOrderButton.Size = new System.Drawing.Size(143, 44);
+ this.CreateOrderButton.TabIndex = 2;
+ this.CreateOrderButton.Text = "Создать заказ";
+ this.CreateOrderButton.UseVisualStyleBackColor = true;
+ this.CreateOrderButton.Click += new System.EventHandler(this.CreateOrderButton_Click);
+ //
+ // TakeOrderInWorkButton
+ //
+ this.TakeOrderInWorkButton.Location = new System.Drawing.Point(832, 111);
+ this.TakeOrderInWorkButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.TakeOrderInWorkButton.Name = "TakeOrderInWorkButton";
+ this.TakeOrderInWorkButton.Size = new System.Drawing.Size(143, 52);
+ this.TakeOrderInWorkButton.TabIndex = 3;
+ this.TakeOrderInWorkButton.Text = "Отдать на выполнение";
+ this.TakeOrderInWorkButton.UseVisualStyleBackColor = true;
+ this.TakeOrderInWorkButton.Click += new System.EventHandler(this.TakeOrderInWorkButton_Click);
+ //
+ // OrderReadyButton
+ //
+ this.OrderReadyButton.Location = new System.Drawing.Point(832, 195);
+ this.OrderReadyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.OrderReadyButton.Name = "OrderReadyButton";
+ this.OrderReadyButton.Size = new System.Drawing.Size(143, 44);
+ this.OrderReadyButton.TabIndex = 4;
+ this.OrderReadyButton.Text = "Заказ готов";
+ this.OrderReadyButton.UseVisualStyleBackColor = true;
+ this.OrderReadyButton.Click += new System.EventHandler(this.OrderReadyButton_Click);
+ //
+ // IssuedOrderButton
+ //
+ this.IssuedOrderButton.Location = new System.Drawing.Point(832, 272);
+ this.IssuedOrderButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.IssuedOrderButton.Name = "IssuedOrderButton";
+ this.IssuedOrderButton.Size = new System.Drawing.Size(143, 44);
+ this.IssuedOrderButton.TabIndex = 5;
+ this.IssuedOrderButton.Text = "Заказ выдан";
+ this.IssuedOrderButton.UseVisualStyleBackColor = true;
+ this.IssuedOrderButton.Click += new System.EventHandler(this.IssuedOrderButton_Click);
+ //
+ // UpdateListButton
+ //
+ this.UpdateListButton.Location = new System.Drawing.Point(832, 349);
+ this.UpdateListButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.UpdateListButton.Name = "UpdateListButton";
+ this.UpdateListButton.Size = new System.Drawing.Size(143, 44);
+ this.UpdateListButton.TabIndex = 6;
+ this.UpdateListButton.Text = "Обновить список";
+ this.UpdateListButton.UseVisualStyleBackColor = true;
+ this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(989, 600);
+ this.Controls.Add(this.UpdateListButton);
+ this.Controls.Add(this.IssuedOrderButton);
+ this.Controls.Add(this.OrderReadyButton);
+ this.Controls.Add(this.TakeOrderInWorkButton);
+ this.Controls.Add(this.CreateOrderButton);
+ this.Controls.Add(this.DataGridView);
+ this.Controls.Add(this.MenuStrip);
+ this.MainMenuStrip = this.MenuStrip;
+ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.Name = "FormMain";
+ this.Text = "Ремонтные Работы";
+ this.MenuStrip.ResumeLayout(false);
+ this.MenuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+
+ private MenuStrip MenuStrip;
+ private ToolStripMenuItem СправочникиToolStripMenuItem;
+ private ToolStripMenuItem ИзделияToolStripMenuItem;
+ private ToolStripMenuItem КомпонентыToolStripMenuItem;
+ private DataGridView DataGridView;
+ private Button CreateOrderButton;
+ private Button TakeOrderInWorkButton;
+ private Button OrderReadyButton;
+ private Button IssuedOrderButton;
+ private Button UpdateListButton;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FormMain.cs
new file mode 100644
index 0000000..ba0dfbe
--- /dev/null
+++ b/FurnitureAssembly/FormMain.cs
@@ -0,0 +1,200 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyDataModels.Enums;
+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 FurnitureAssembly
+{
+ public partial class FormMain : Form
+ {
+
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+
+ public FormMain(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка заказов");
+
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+
+ if (list != null)
+ {
+ DataGridView.DataSource = list;
+ DataGridView.Columns["ProductId"].Visible = false;
+ }
+
+ _logger.LogInformation("Загрузка заказов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormProducts));
+
+ if (service is FormProducts form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void CreateOrderButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void TakeOrderInWorkButton_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,
+ ProductId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ProductId"].Value),
+ ProductName = DataGridView.SelectedRows[0].Cells["ProductName"].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 IssuedOrderButton_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,
+ ProductId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ProductId"].Value),
+ ProductName = DataGridView.SelectedRows[0].Cells["ProductName"].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 OrderReadyButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
+ {
+ Id = id,
+ ProductId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ProductId"].Value),
+ ProductName = DataGridView.SelectedRows[0].Cells["ProductName"].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("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void UpdateListButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/FurnitureAssembly/FormMain.resx b/FurnitureAssembly/FormMain.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FurnitureAssembly/FormMain.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FormProduct.Designer.cs b/FurnitureAssembly/FormProduct.Designer.cs
new file mode 100644
index 0000000..350b8e2
--- /dev/null
+++ b/FurnitureAssembly/FormProduct.Designer.cs
@@ -0,0 +1,252 @@
+namespace FurnitureAssembly
+{
+ partial class FormProduct
+ {
+ ///
+ /// 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()
+ {
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
+ this.ProductNameLabel = new System.Windows.Forms.Label();
+ this.PriceLabel = new System.Windows.Forms.Label();
+ this.ProductNameTextBox = new System.Windows.Forms.TextBox();
+ this.PriceTextBox = new System.Windows.Forms.TextBox();
+ this.ComponentsGroupBox = new System.Windows.Forms.GroupBox();
+ this.UpdateButton = new System.Windows.Forms.Button();
+ this.DeleteButton = new System.Windows.Forms.Button();
+ this.ChangeButton = new System.Windows.Forms.Button();
+ this.AddButton = new System.Windows.Forms.Button();
+ this.DataGridView = new System.Windows.Forms.DataGridView();
+ this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ComponentNameField = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.CountField = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ButtonCancel = new System.Windows.Forms.Button();
+ this.SaveButton = new System.Windows.Forms.Button();
+ this.ComponentsGroupBox.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // ProductNameLabel
+ //
+ this.ProductNameLabel.AutoSize = true;
+ this.ProductNameLabel.Location = new System.Drawing.Point(12, 9);
+ this.ProductNameLabel.Name = "ProductNameLabel";
+ this.ProductNameLabel.Size = new System.Drawing.Size(65, 15);
+ this.ProductNameLabel.TabIndex = 0;
+ this.ProductNameLabel.Text = "Название: ";
+ //
+ // PriceLabel
+ //
+ this.PriceLabel.AutoSize = true;
+ this.PriceLabel.Location = new System.Drawing.Point(12, 43);
+ this.PriceLabel.Name = "PriceLabel";
+ this.PriceLabel.Size = new System.Drawing.Size(73, 15);
+ this.PriceLabel.TabIndex = 1;
+ this.PriceLabel.Text = "Стоимость: ";
+ //
+ // ProductNameTextBox
+ //
+ this.ProductNameTextBox.Location = new System.Drawing.Point(83, 6);
+ this.ProductNameTextBox.Name = "ProductNameTextBox";
+ this.ProductNameTextBox.Size = new System.Drawing.Size(283, 23);
+ this.ProductNameTextBox.TabIndex = 2;
+ //
+ // PriceTextBox
+ //
+ this.PriceTextBox.Location = new System.Drawing.Point(83, 40);
+ this.PriceTextBox.Name = "PriceTextBox";
+ this.PriceTextBox.Size = new System.Drawing.Size(283, 23);
+ this.PriceTextBox.TabIndex = 3;
+ //
+ // ComponentsGroupBox
+ //
+ this.ComponentsGroupBox.Controls.Add(this.UpdateButton);
+ this.ComponentsGroupBox.Controls.Add(this.DeleteButton);
+ this.ComponentsGroupBox.Controls.Add(this.ChangeButton);
+ this.ComponentsGroupBox.Controls.Add(this.AddButton);
+ this.ComponentsGroupBox.Controls.Add(this.DataGridView);
+ this.ComponentsGroupBox.Location = new System.Drawing.Point(12, 80);
+ this.ComponentsGroupBox.Name = "ComponentsGroupBox";
+ this.ComponentsGroupBox.Size = new System.Drawing.Size(722, 350);
+ this.ComponentsGroupBox.TabIndex = 5;
+ this.ComponentsGroupBox.TabStop = false;
+ this.ComponentsGroupBox.Text = "Компоненты";
+ //
+ // UpdateButton
+ //
+ this.UpdateButton.Location = new System.Drawing.Point(590, 203);
+ this.UpdateButton.Name = "UpdateButton";
+ this.UpdateButton.Size = new System.Drawing.Size(110, 38);
+ this.UpdateButton.TabIndex = 4;
+ this.UpdateButton.Text = "Обновить";
+ this.UpdateButton.UseVisualStyleBackColor = true;
+ this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
+ //
+ // DeleteButton
+ //
+ this.DeleteButton.Location = new System.Drawing.Point(590, 143);
+ this.DeleteButton.Name = "DeleteButton";
+ this.DeleteButton.Size = new System.Drawing.Size(110, 38);
+ this.DeleteButton.TabIndex = 3;
+ this.DeleteButton.Text = "Удалить";
+ this.DeleteButton.UseVisualStyleBackColor = true;
+ this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
+ //
+ // ChangeButton
+ //
+ this.ChangeButton.Location = new System.Drawing.Point(590, 82);
+ this.ChangeButton.Name = "ChangeButton";
+ this.ChangeButton.Size = new System.Drawing.Size(110, 38);
+ this.ChangeButton.TabIndex = 2;
+ this.ChangeButton.Text = "Изменить";
+ this.ChangeButton.UseVisualStyleBackColor = true;
+ this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
+ //
+ // AddButton
+ //
+ this.AddButton.Location = new System.Drawing.Point(590, 22);
+ this.AddButton.Name = "AddButton";
+ this.AddButton.Size = new System.Drawing.Size(110, 38);
+ this.AddButton.TabIndex = 1;
+ this.AddButton.Text = "Добавить";
+ this.AddButton.UseVisualStyleBackColor = true;
+ this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
+ //
+ // DataGridView
+ //
+ dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.DataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
+ this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.DataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ID,
+ this.ComponentNameField,
+ this.CountField});
+ dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
+ dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
+ dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+ this.DataGridView.DefaultCellStyle = dataGridViewCellStyle2;
+ this.DataGridView.Location = new System.Drawing.Point(6, 22);
+ this.DataGridView.Name = "DataGridView";
+ dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.DataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
+ this.DataGridView.RowTemplate.Height = 25;
+ this.DataGridView.Size = new System.Drawing.Size(561, 322);
+ this.DataGridView.TabIndex = 0;
+ //
+ // ID
+ //
+ this.ID.HeaderText = "ID";
+ this.ID.Name = "ID";
+ this.ID.Visible = false;
+ //
+ // ComponentNameField
+ //
+ this.ComponentNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.ComponentNameField.HeaderText = "Компонент";
+ this.ComponentNameField.Name = "ComponentNameField";
+ //
+ // CountField
+ //
+ this.CountField.HeaderText = "Количество";
+ this.CountField.Name = "CountField";
+ //
+ // ButtonCancel
+ //
+ this.ButtonCancel.Location = new System.Drawing.Point(602, 446);
+ this.ButtonCancel.Name = "ButtonCancel";
+ this.ButtonCancel.Size = new System.Drawing.Size(110, 34);
+ this.ButtonCancel.TabIndex = 7;
+ this.ButtonCancel.Text = "Отмена";
+ this.ButtonCancel.UseVisualStyleBackColor = true;
+ this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // SaveButton
+ //
+ this.SaveButton.Location = new System.Drawing.Point(486, 446);
+ this.SaveButton.Name = "SaveButton";
+ this.SaveButton.Size = new System.Drawing.Size(110, 34);
+ this.SaveButton.TabIndex = 8;
+ this.SaveButton.Text = "Сохранить";
+ this.SaveButton.UseVisualStyleBackColor = true;
+ this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
+ //
+ // FormProduct
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(746, 498);
+ this.Controls.Add(this.SaveButton);
+ this.Controls.Add(this.ButtonCancel);
+ this.Controls.Add(this.ComponentsGroupBox);
+ this.Controls.Add(this.PriceTextBox);
+ this.Controls.Add(this.ProductNameTextBox);
+ this.Controls.Add(this.PriceLabel);
+ this.Controls.Add(this.ProductNameLabel);
+ this.Name = "FormProduct";
+ this.Text = "Изделие";
+ this.ComponentsGroupBox.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+ }
+
+ #endregion
+
+
+ private Label ProductNameLabel;
+ private Label PriceLabel;
+ private TextBox ProductNameTextBox;
+ private TextBox PriceTextBox;
+ private GroupBox ComponentsGroupBox;
+ private Button UpdateButton;
+ private Button DeleteButton;
+ private Button ChangeButton;
+ private Button AddButton;
+ private DataGridView DataGridView;
+ private DataGridViewTextBoxColumn ID;
+ private DataGridViewTextBoxColumn ComponentNameField;
+ private DataGridViewTextBoxColumn CountField;
+ private Button ButtonCancel;
+ private Button SaveButton;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FormProduct.cs b/FurnitureAssembly/FormProduct.cs
new file mode 100644
index 0000000..415ae42
--- /dev/null
+++ b/FurnitureAssembly/FormProduct.cs
@@ -0,0 +1,237 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyDataModels.Models;
+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 FurnitureAssembly
+{
+ public partial class FormProduct : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IProductLogic _logic;
+
+ private int? _id;
+
+ private Dictionary _productComponents;
+
+ public int Id { set { _id = value; } }
+ public FormProduct(ILogger logger, IProductLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _productComponents = new Dictionary();
+ }
+ private void FormProduct_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+
+ try
+ {
+ var view = _logic.ReadElement(new ProductSearchModel
+ {
+ Id = _id.Value
+ });
+
+ if (view != null)
+ {
+ ProductNameTextBox.Text = view.ProductName;
+ PriceTextBox.Text = view.Price.ToString();
+ _productComponents = view.ProductComponents ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+
+ try
+ {
+ if (_productComponents != null)
+ {
+ DataGridView.Rows.Clear();
+ foreach (var pc in _productComponents)
+ {
+ DataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
+ }
+ PriceTextBox.Text = CalcPrice().ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонент изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent));
+
+ if (service is FormProductComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+
+ _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+
+ if (_productComponents.ContainsKey(form.Id))
+ {
+ _productComponents[form.Id] = (form.ComponentModel, form.Count);
+ }
+
+ else
+ {
+ _productComponents.Add(form.Id, (form.ComponentModel, form.Count));
+ }
+
+ LoadData();
+ }
+ }
+ }
+
+ private void ChangeButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent));
+
+ if (service is FormProductComponent form)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _productComponents[id].Item2;
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+
+ _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ _productComponents[form.Id] = (form.ComponentModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void DeleteButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ try
+ {
+ _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", DataGridView.SelectedRows[0].Cells[1].Value);
+ _productComponents?.Remove(Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ LoadData();
+ }
+ }
+ }
+
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void SaveButton_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(ProductNameTextBox.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(PriceTextBox.Text))
+ {
+ MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (_productComponents == null || _productComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Сохранение изделия");
+
+ try
+ {
+ var model = new ProductBindingModel
+ {
+ Id = _id ?? 0,
+ ProductName = ProductNameTextBox.Text,
+ Price = Convert.ToDouble(PriceTextBox.Text),
+ ProductComponents = _productComponents
+ };
+
+ 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();
+ }
+
+ private double CalcPrice()
+ {
+ double price = 0;
+
+ foreach (var elem in _productComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/FurnitureAssembly/FormProduct.resx b/FurnitureAssembly/FormProduct.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FurnitureAssembly/FormProduct.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FormProductComponent.Designer.cs b/FurnitureAssembly/FormProductComponent.Designer.cs
new file mode 100644
index 0000000..2924036
--- /dev/null
+++ b/FurnitureAssembly/FormProductComponent.Designer.cs
@@ -0,0 +1,121 @@
+namespace FurnitureAssembly
+{
+ partial class FormProductComponent
+ {
+ ///
+ /// 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.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.labelComponent = new System.Windows.Forms.Label();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.comboBoxComponent = new System.Windows.Forms.ComboBox();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(218, 59);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(137, 59);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // labelComponent
+ //
+ this.labelComponent.AutoSize = true;
+ this.labelComponent.Location = new System.Drawing.Point(12, 9);
+ this.labelComponent.Name = "labelComponent";
+ this.labelComponent.Size = new System.Drawing.Size(66, 13);
+ this.labelComponent.TabIndex = 0;
+ this.labelComponent.Text = "Компонент:";
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(87, 33);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(217, 20);
+ this.textBoxCount.TabIndex = 3;
+ //
+ // comboBoxComponent
+ //
+ this.comboBoxComponent.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxComponent.FormattingEnabled = true;
+ this.comboBoxComponent.Location = new System.Drawing.Point(87, 6);
+ this.comboBoxComponent.Name = "comboBoxComponent";
+ this.comboBoxComponent.Size = new System.Drawing.Size(217, 21);
+ this.comboBoxComponent.TabIndex = 1;
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(12, 36);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(69, 13);
+ this.labelCount.TabIndex = 2;
+ this.labelCount.Text = "Количество:";
+ //
+ // FormProductComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(320, 96);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.comboBoxComponent);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.labelComponent);
+ this.Name = "FormProductComponent";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Компонент изделия";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button buttonCancel;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.Label labelComponent;
+ private System.Windows.Forms.TextBox textBoxCount;
+ private System.Windows.Forms.ComboBox comboBoxComponent;
+ private System.Windows.Forms.Label labelCount;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FormProductComponent.cs b/FurnitureAssembly/FormProductComponent.cs
new file mode 100644
index 0000000..89eaee4
--- /dev/null
+++ b/FurnitureAssembly/FormProductComponent.cs
@@ -0,0 +1,80 @@
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyDataModels.Models;
+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 FurnitureAssembly
+{
+ public partial class FormProductComponent : Form
+ {
+ private readonly List? _list;
+
+ public int Id { get { return Convert.ToInt32(comboBoxComponent.SelectedValue); } set { comboBoxComponent.SelectedValue = value; } }
+
+ public IComponentModel? ComponentModel
+ {
+ get
+ {
+ if (_list == null)
+ {
+ return null;
+ }
+ foreach (var elem in _list)
+ {
+ if (elem.Id == Id)
+ {
+ return elem;
+ }
+ }
+ return null;
+ }
+ }
+
+ public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } }
+
+ public FormProductComponent(IComponentLogic logic)
+ {
+ InitializeComponent();
+
+ _list = logic.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxComponent.DisplayMember = "ComponentName";
+ comboBoxComponent.ValueMember = "Id";
+ comboBoxComponent.DataSource = _list;
+ comboBoxComponent.SelectedItem = null;
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxComponent.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/FurnitureAssembly/FormProductComponent.resx b/FurnitureAssembly/FormProductComponent.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FurnitureAssembly/FormProductComponent.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FormProducts.Designer.cs b/FurnitureAssembly/FormProducts.Designer.cs
new file mode 100644
index 0000000..18063bb
--- /dev/null
+++ b/FurnitureAssembly/FormProducts.Designer.cs
@@ -0,0 +1,112 @@
+namespace FurnitureAssembly
+{
+ partial class FormProducts
+ {
+ ///
+ /// 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.AddButton = new System.Windows.Forms.Button();
+ this.ChangeButton = new System.Windows.Forms.Button();
+ this.DeleteButton = new System.Windows.Forms.Button();
+ this.UpdateButton = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // DataGridView
+ //
+ this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.DataGridView.Location = new System.Drawing.Point(1, 1);
+ this.DataGridView.Name = "DataGridView";
+ this.DataGridView.RowTemplate.Height = 25;
+ this.DataGridView.Size = new System.Drawing.Size(562, 495);
+ this.DataGridView.TabIndex = 0;
+ //
+ // AddButton
+ //
+ this.AddButton.Location = new System.Drawing.Point(585, 12);
+ this.AddButton.Name = "AddButton";
+ this.AddButton.Size = new System.Drawing.Size(120, 41);
+ this.AddButton.TabIndex = 1;
+ this.AddButton.Text = "Добавить";
+ this.AddButton.UseVisualStyleBackColor = true;
+ this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
+ //
+ // ChangeButton
+ //
+ this.ChangeButton.Location = new System.Drawing.Point(585, 71);
+ this.ChangeButton.Name = "ChangeButton";
+ this.ChangeButton.Size = new System.Drawing.Size(120, 41);
+ this.ChangeButton.TabIndex = 2;
+ this.ChangeButton.Text = "Изменить";
+ this.ChangeButton.UseVisualStyleBackColor = true;
+ this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
+ //
+ // DeleteButton
+ //
+ this.DeleteButton.Location = new System.Drawing.Point(585, 130);
+ this.DeleteButton.Name = "DeleteButton";
+ this.DeleteButton.Size = new System.Drawing.Size(120, 41);
+ this.DeleteButton.TabIndex = 3;
+ this.DeleteButton.Text = "Удалить";
+ this.DeleteButton.UseVisualStyleBackColor = true;
+ this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
+ //
+ // UpdateButton
+ //
+ this.UpdateButton.Location = new System.Drawing.Point(585, 191);
+ this.UpdateButton.Name = "UpdateButton";
+ this.UpdateButton.Size = new System.Drawing.Size(120, 41);
+ this.UpdateButton.TabIndex = 4;
+ this.UpdateButton.Text = "Обновить";
+ this.UpdateButton.UseVisualStyleBackColor = true;
+ this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
+ //
+ // FormProducts
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(717, 502);
+ this.Controls.Add(this.UpdateButton);
+ this.Controls.Add(this.DeleteButton);
+ this.Controls.Add(this.ChangeButton);
+ this.Controls.Add(this.AddButton);
+ this.Controls.Add(this.DataGridView);
+ this.Name = "FormProducts";
+ this.Text = "Изделия";
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
+ this.ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView DataGridView;
+ private Button AddButton;
+ private Button ChangeButton;
+ private Button DeleteButton;
+ private Button UpdateButton;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FormProducts.cs b/FurnitureAssembly/FormProducts.cs
new file mode 100644
index 0000000..5f3de95
--- /dev/null
+++ b/FurnitureAssembly/FormProducts.cs
@@ -0,0 +1,120 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FurnitureAssembly
+{
+ public partial class FormProducts : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IProductLogic _logic;
+
+ public FormProducts(ILogger logger, IProductLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormProducts_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["ProductName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ DataGridView.Columns["ProductComponents"].Visible = false;
+ }
+
+ _logger.LogInformation("Загрузка изделий");
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделий");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
+
+ if (service is FormProduct form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ChangeButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
+
+ if (service is FormProduct form)
+ {
+ form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void DeleteButton_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 ProductBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/FurnitureAssembly/FormProducts.resx b/FurnitureAssembly/FormProducts.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FurnitureAssembly/FormProducts.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly.csproj b/FurnitureAssembly/FurnitureAssembly.csproj
index b57c89e..5c93a50 100644
--- a/FurnitureAssembly/FurnitureAssembly.csproj
+++ b/FurnitureAssembly/FurnitureAssembly.csproj
@@ -8,4 +8,16 @@
enable
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly.sln b/FurnitureAssembly/FurnitureAssembly.sln
index 873f125..c2cad1c 100644
--- a/FurnitureAssembly/FurnitureAssembly.sln
+++ b/FurnitureAssembly/FurnitureAssembly.sln
@@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssembly", "FurnitureAssembly.csproj", "{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssembly", "FurnitureAssembly.csproj", "{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyDataModels", "..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj", "{C610F257-6EF1-49B7-A6B1-53B0531A1D94}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyContracts", "..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj", "{AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyListImplement", "..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj", "{D6524F12-93DE-4983-81AD-9703A3488B95}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyBusinessLogic", "..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj", "{95752DB2-8672-4A78-96CF-3F87E83C27B2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +23,22 @@ Global
{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1C559D9-85DE-4173-A6C5-FE75B2C9A261}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C610F257-6EF1-49B7-A6B1-53B0531A1D94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C610F257-6EF1-49B7-A6B1-53B0531A1D94}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C610F257-6EF1-49B7-A6B1-53B0531A1D94}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C610F257-6EF1-49B7-A6B1-53B0531A1D94}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AD9F4632-FB53-45E2-8B1B-0A6C406C57FA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D6524F12-93DE-4983-81AD-9703A3488B95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D6524F12-93DE-4983-81AD-9703A3488B95}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D6524F12-93DE-4983-81AD-9703A3488B95}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D6524F12-93DE-4983-81AD-9703A3488B95}.Release|Any CPU.Build.0 = Release|Any CPU
+ {95752DB2-8672-4A78-96CF-3F87E83C27B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {95752DB2-8672-4A78-96CF-3F87E83C27B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {95752DB2-8672-4A78-96CF-3F87E83C27B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {95752DB2-8672-4A78-96CF-3F87E83C27B2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/FurnitureAssembly/Program.cs b/FurnitureAssembly/Program.cs
index 22f2995..35dc790 100644
--- a/FurnitureAssembly/Program.cs
+++ b/FurnitureAssembly/Program.cs
@@ -1,17 +1,49 @@
+using FurnitureAssemblyBusinessLogic.BusinessLogic;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyListImplement.Implements;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using System;
+
namespace FurnitureAssembly
{
internal static class Program
{
- ///
- /// The main entry point for the application.
- ///
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+
[STAThread]
static void Main()
{
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/FurnitureAssemblyBusinessLogic/BusinessLogic/ComponentLogic.cs b/FurnitureAssemblyBusinessLogic/BusinessLogic/ComponentLogic.cs
new file mode 100644
index 0000000..f9ca4db
--- /dev/null
+++ b/FurnitureAssemblyBusinessLogic/BusinessLogic/ComponentLogic.cs
@@ -0,0 +1,120 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyBusinessLogic.BusinessLogic
+{
+ public class ComponentLogic : IComponentLogic
+ {
+ private readonly ILogger _logger;
+
+ private readonly IComponentStorage _componentStorage;
+
+ public ComponentLogic(ILogger logger, IComponentStorage componentStorage)
+ {
+ _logger = logger;
+ _componentStorage = componentStorage;
+ }
+
+ public List? ReadList(ComponentSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}", model?.ComponentName, model?.Id);
+ var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ public ComponentViewModel? ReadElement(ComponentSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{Id}", model.ComponentName, model.Id);
+ var element = _componentStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+
+ public bool Create(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool Update(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool Delete(ComponentBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_componentStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(ComponentBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName));
+ }
+ if (model.Cost <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
+ }
+ _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{Cost}. Id:{Id}", model.ComponentName, model.Cost, model.Id);
+ var element = _componentStorage.GetElement(new ComponentSearchModel
+ {
+ ComponentName = model.ComponentName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компонент с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/FurnitureAssemblyBusinessLogic/BusinessLogic/OrderLogic.cs b/FurnitureAssemblyBusinessLogic/BusinessLogic/OrderLogic.cs
new file mode 100644
index 0000000..d0e60f3
--- /dev/null
+++ b/FurnitureAssemblyBusinessLogic/BusinessLogic/OrderLogic.cs
@@ -0,0 +1,136 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyDataModels.Enums;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyBusinessLogic.BusinessLogic
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+
+ if (model.Status != OrderStatus.Неизвестен)
+ {
+ _logger.LogWarning("Insert operation failed. Order status incorrect.");
+ return false;
+ }
+
+ model.Status = OrderStatus.Принят;
+
+ if (_orderStorage.Insert(model) == null)
+ {
+ model.Status = OrderStatus.Неизвестен;
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
+ {
+ CheckModel(model);
+
+ if (model.Status + 1 != newStatus)
+ {
+ _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
+ return false;
+ }
+
+ model.Status = newStatus;
+
+ if (model.Status == OrderStatus.Выдан)
+ model.DateImplement = DateTime.Now;
+
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status--;
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выполняется);
+ }
+
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Готов);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выдан);
+ }
+
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("Order. OrderId:{Id}", model?.Id);
+
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (!withParams)
+ {
+ return;
+ }
+
+ if (model.ProductId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.ProductId));
+ }
+
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
+ }
+
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
+ }
+
+ _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. PackageId: { PackageId}", model.Id, model.Sum, model.ProductId);
+ }
+ }
+
+}
diff --git a/FurnitureAssemblyBusinessLogic/BusinessLogic/ProductLogic.cs b/FurnitureAssemblyBusinessLogic/BusinessLogic/ProductLogic.cs
new file mode 100644
index 0000000..e69b38d
--- /dev/null
+++ b/FurnitureAssemblyBusinessLogic/BusinessLogic/ProductLogic.cs
@@ -0,0 +1,142 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyBusinessLogic.BusinessLogic
+{
+ public class ProductLogic : IProductLogic
+ {
+ private readonly ILogger _logger;
+
+ private readonly IProductStorage _productStorage;
+
+ public ProductLogic(ILogger logger, IProductStorage productStorage)
+ {
+ _logger = logger;
+ _productStorage = productStorage;
+ }
+
+ public bool Create(ProductBindingModel model)
+ {
+ CheckModel(model);
+
+ if (_productStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool Delete(ProductBindingModel model)
+ {
+ CheckModel(model, false);
+
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+
+ if (_productStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public ProductViewModel? ReadElement(ProductSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ _logger.LogInformation("ReadElement. ProductName:{ProductName}.Id:{ Id}", model.ProductName, model.Id);
+
+ var element = _productStorage.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(ProductSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ProductName:{ProductName}.Id:{ Id}", model?.ProductName, model?.Id);
+
+ var list = model == null ? _productStorage.GetFullList() : _productStorage.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(ProductBindingModel model)
+ {
+ CheckModel(model);
+
+ if (_productStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ private void CheckModel(ProductBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (!withParams)
+ {
+ return;
+ }
+
+ if (string.IsNullOrEmpty(model.ProductName))
+ {
+ throw new ArgumentNullException("Нет названия изделия", nameof(model.ProductName));
+ }
+
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
+ }
+
+ _logger.LogInformation("Product. ProductName:{ProductName}.Price:{ Cost}. Id: { Id}", model.ProductName, model.Price, model.Id);
+
+ var element = _productStorage.GetElement(new ProductSearchModel
+ {
+ ProductName = model.ProductName
+ });
+
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Изделие с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj b/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj
new file mode 100644
index 0000000..4358031
--- /dev/null
+++ b/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs b/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..a7bbb9a
--- /dev/null
+++ b/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,18 @@
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BindingModels
+{
+ public class ComponentBindingModel : IComponentModel
+ {
+ public int Id { get; set; }
+
+ public string ComponentName { get; set; } = string.Empty;
+
+ public double Cost { get; set; }
+ }
+}
diff --git a/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs b/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..922b3fb
--- /dev/null
+++ b/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,29 @@
+using FurnitureAssemblyDataModels.Enums;
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public string ProductName { get; set; }
+
+ public int Id { get; set; }
+
+ public int ProductId { get; set; }
+
+ public int Count { get; set; }
+
+ public double Sum { get; set; }
+
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+
+ public DateTime? DateImplement { get; set; }
+ }
+}
diff --git a/FurnitureAssemblyContracts/BindingModels/ProductBindingModel.cs b/FurnitureAssemblyContracts/BindingModels/ProductBindingModel.cs
new file mode 100644
index 0000000..50d13bf
--- /dev/null
+++ b/FurnitureAssemblyContracts/BindingModels/ProductBindingModel.cs
@@ -0,0 +1,20 @@
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BindingModels
+{
+ public class ProductBindingModel : IProductModel
+ {
+ public int Id { get; set; }
+
+ public string ProductName { get; set; } = string.Empty;
+
+ public double Price { get; set; }
+
+ public Dictionary ProductComponents { get; set; } = new();
+ }
+}
diff --git a/FurnitureAssemblyContracts/BusinessLogicsContracts/IComponentLogic.cs b/FurnitureAssemblyContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..fbf31ce
--- /dev/null
+++ b/FurnitureAssemblyContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,24 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BusinessLogicsContracts
+{
+ public interface IComponentLogic
+ {
+ List? ReadList(ComponentSearchModel? model);
+
+ ComponentViewModel? ReadElement(ComponentSearchModel model);
+
+ bool Create(ComponentBindingModel model);
+
+ bool Update(ComponentBindingModel model);
+
+ bool Delete(ComponentBindingModel model);
+ }
+}
diff --git a/FurnitureAssemblyContracts/BusinessLogicsContracts/IOrderLogic.cs b/FurnitureAssemblyContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..1615817
--- /dev/null
+++ b/FurnitureAssemblyContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,24 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BusinessLogicsContracts
+{
+ public interface IOrderLogic
+ {
+ List? ReadList(OrderSearchModel? model);
+
+ bool CreateOrder(OrderBindingModel model);
+
+ bool TakeOrderInWork(OrderBindingModel model);
+
+ bool FinishOrder(OrderBindingModel model);
+
+ bool DeliveryOrder(OrderBindingModel model);
+ }
+}
diff --git a/FurnitureAssemblyContracts/BusinessLogicsContracts/IProductLogic.cs b/FurnitureAssemblyContracts/BusinessLogicsContracts/IProductLogic.cs
new file mode 100644
index 0000000..e4b7e16
--- /dev/null
+++ b/FurnitureAssemblyContracts/BusinessLogicsContracts/IProductLogic.cs
@@ -0,0 +1,24 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BusinessLogicsContracts
+{
+ public interface IProductLogic
+ {
+ List? ReadList(ProductSearchModel? model);
+
+ ProductViewModel? ReadElement(ProductSearchModel model);
+
+ bool Create(ProductBindingModel model);
+
+ bool Update(ProductBindingModel model);
+
+ bool Delete(ProductBindingModel model);
+ }
+}
diff --git a/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj b/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj
new file mode 100644
index 0000000..71e2e97
--- /dev/null
+++ b/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs b/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..9e6589d
--- /dev/null
+++ b/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+
+ public string? ComponentName { get; set; }
+ }
+}
diff --git a/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs b/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..25dba07
--- /dev/null
+++ b/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/FurnitureAssemblyContracts/SearchModels/ProductSearchModel.cs b/FurnitureAssemblyContracts/SearchModels/ProductSearchModel.cs
new file mode 100644
index 0000000..4156300
--- /dev/null
+++ b/FurnitureAssemblyContracts/SearchModels/ProductSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.SearchModels
+{
+ public class ProductSearchModel
+ {
+ public int? Id { get; set; }
+
+ public string? ProductName { get; set; }
+ }
+}
diff --git a/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs b/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..36cc4d1
--- /dev/null
+++ b/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,26 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.StoragesContracts
+{
+ public interface IComponentStorage
+ {
+ List GetFullList();
+
+ List GetFilteredList(ComponentSearchModel model);
+
+ ComponentViewModel? GetElement(ComponentSearchModel model);
+
+ ComponentViewModel? Insert(ComponentBindingModel model);
+
+ ComponentViewModel? Update(ComponentBindingModel model);
+
+ ComponentViewModel? Delete(ComponentBindingModel model);
+ }
+}
diff --git a/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs b/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..e10c7ed
--- /dev/null
+++ b/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,26 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.StoragesContracts
+{
+ public interface IOrderStorage
+ {
+ List GetFullList();
+
+ List GetFilteredList(OrderSearchModel model);
+
+ OrderViewModel? GetElement(OrderSearchModel model);
+
+ OrderViewModel? Insert(OrderBindingModel model);
+
+ OrderViewModel? Update(OrderBindingModel model);
+
+ OrderViewModel? Delete(OrderBindingModel model);
+ }
+}
diff --git a/FurnitureAssemblyContracts/StoragesContracts/IProducStorage.cs b/FurnitureAssemblyContracts/StoragesContracts/IProducStorage.cs
new file mode 100644
index 0000000..4ac4cfe
--- /dev/null
+++ b/FurnitureAssemblyContracts/StoragesContracts/IProducStorage.cs
@@ -0,0 +1,26 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.StoragesContracts
+{
+ public interface IProductStorage
+ {
+ List GetFullList();
+
+ List GetFilteredList(ProductSearchModel model);
+
+ ProductViewModel? GetElement(ProductSearchModel model);
+
+ ProductViewModel? Insert(ProductBindingModel model);
+
+ ProductViewModel? Update(ProductBindingModel model);
+
+ ProductViewModel? Delete(ProductBindingModel model);
+ }
+}
diff --git a/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs b/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..56f217c
--- /dev/null
+++ b/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,21 @@
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.ViewModels
+{
+ public class ComponentViewModel : IComponentModel
+ {
+ public int Id { get; set; }
+
+ [DisplayName("Название компонента")]
+ public string ComponentName { get; set; } = string.Empty;
+
+ [DisplayName("Цена")]
+ public double Cost { get; set; }
+ }
+}
diff --git a/FurnitureAssemblyContracts/ViewModels/OrderViewModels.cs b/FurnitureAssemblyContracts/ViewModels/OrderViewModels.cs
new file mode 100644
index 0000000..5262d83
--- /dev/null
+++ b/FurnitureAssemblyContracts/ViewModels/OrderViewModels.cs
@@ -0,0 +1,37 @@
+using FurnitureAssemblyDataModels.Enums;
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+
+ public int ProductId { get; set; }
+
+ [DisplayName("Изделие")]
+ public string ProductName { get; set; } = string.Empty;
+
+ [DisplayName("Количество")]
+ public int Count { get; set; }
+
+ [DisplayName("Сумма")]
+ public double Sum { get; set; }
+
+ [DisplayName("Статус")]
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+
+ [DisplayName("Дата создания")]
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+
+ [DisplayName("Дата выполнения")]
+ public DateTime? DateImplement { get; set; }
+ }
+}
diff --git a/FurnitureAssemblyContracts/ViewModels/ProductViewModel.cs b/FurnitureAssemblyContracts/ViewModels/ProductViewModel.cs
new file mode 100644
index 0000000..eadc169
--- /dev/null
+++ b/FurnitureAssemblyContracts/ViewModels/ProductViewModel.cs
@@ -0,0 +1,23 @@
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.ViewModels
+{
+ public class ProductViewModel : IProductModel
+ {
+ public int Id { get; set; }
+
+ [DisplayName("Название изделия")]
+ public string ProductName { get; set; } = string.Empty;
+
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+
+ public Dictionary ProductComponents { get; set; } = new();
+ }
+}
diff --git a/FurnitureAssemblyDataModels/Enums/OrderStatus.cs b/FurnitureAssemblyDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..b1a6d47
--- /dev/null
+++ b/FurnitureAssemblyDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+
+ Принят = 0,
+
+ Выполняется = 1,
+
+ Готов = 2,
+
+ Выдан = 3
+ }
+}
diff --git a/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj b/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/FurnitureAssemblyDataModels/IId.cs b/FurnitureAssemblyDataModels/IId.cs
new file mode 100644
index 0000000..07be087
--- /dev/null
+++ b/FurnitureAssemblyDataModels/IId.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/FurnitureAssemblyDataModels/Models/IComponentModel.cs b/FurnitureAssemblyDataModels/Models/IComponentModel.cs
new file mode 100644
index 0000000..111084a
--- /dev/null
+++ b/FurnitureAssemblyDataModels/Models/IComponentModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+
+ double Cost { get; }
+ }
+}
diff --git a/FurnitureAssemblyDataModels/Models/IOrderModel.cs b/FurnitureAssemblyDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..03259b6
--- /dev/null
+++ b/FurnitureAssemblyDataModels/Models/IOrderModel.cs
@@ -0,0 +1,24 @@
+using FurnitureAssemblyDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int ProductId { get; }
+
+ int Count { get; }
+
+ double Sum { get; }
+
+ OrderStatus Status { get; }
+
+ DateTime DateCreate { get; }
+
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/FurnitureAssemblyDataModels/Models/IProductModel.cs b/FurnitureAssemblyDataModels/Models/IProductModel.cs
new file mode 100644
index 0000000..747a1fe
--- /dev/null
+++ b/FurnitureAssemblyDataModels/Models/IProductModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels.Models
+{
+ public interface IProductModel : IId
+ {
+ string ProductName { get; }
+
+ double Price { get; }
+
+ Dictionary ProductComponents { get; }
+ }
+}
diff --git a/FurnitureAssemblyListImplement/DataListSingleton.cs b/FurnitureAssemblyListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..9315713
--- /dev/null
+++ b/FurnitureAssemblyListImplement/DataListSingleton.cs
@@ -0,0 +1,39 @@
+using FurnitureAssemblyListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Component = FurnitureAssemblyListImplement.Models.Component;
+
+namespace FurnitureAssemblyListImplement
+{
+ internal class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+
+ public List Components { get; set; }
+
+ public List Orders { get; set; }
+
+ public List Products { get; set; }
+
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Products = new List();
+ }
+
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+
+ return _instance;
+ }
+ }
+}
diff --git a/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj b/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj
new file mode 100644
index 0000000..83ae5ee
--- /dev/null
+++ b/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs b/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..43ce3d6
--- /dev/null
+++ b/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,113 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Implements
+{
+ public class ComponentStorage : IComponentStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public ComponentStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var component in _source.Components)
+ {
+ result.Add(component.GetViewModel);
+ }
+ return result;
+ }
+
+ public List GetFilteredList(ComponentSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ return result;
+ }
+ foreach (var component in _source.Components)
+ {
+ if (component.ComponentName.Contains(model.ComponentName))
+ {
+ result.Add(component.GetViewModel);
+ }
+ }
+ return result;
+ }
+
+ public ComponentViewModel? GetElement(ComponentSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var component in _source.Components)
+ {
+ if ((!string.IsNullOrEmpty(model.ComponentName) && component.ComponentName == model.ComponentName) ||
+ (model.Id.HasValue && component.Id == model.Id))
+ {
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public ComponentViewModel? Insert(ComponentBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var component in _source.Components)
+ {
+ if (model.Id <= component.Id)
+ {
+ model.Id = component.Id + 1;
+ }
+ }
+ var newComponent = Component.Create(model);
+ if (newComponent == null)
+ {
+ return null;
+ }
+ _source.Components.Add(newComponent);
+ return newComponent.GetViewModel;
+ }
+
+ public ComponentViewModel? Update(ComponentBindingModel model)
+ {
+ foreach (var component in _source.Components)
+ {
+ if (component.Id == model.Id)
+ {
+ component.Update(model);
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public ComponentViewModel? Delete(ComponentBindingModel model)
+ {
+ for (int i = 0; i < _source.Components.Count; ++i)
+ {
+ if (_source.Components[i].Id == model.Id)
+ {
+ var element = _source.Components[i];
+ _source.Components.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/FurnitureAssemblyListImplement/Implements/OrderStorage.cs b/FurnitureAssemblyListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..1e5343a
--- /dev/null
+++ b/FurnitureAssemblyListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,124 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ for (int i = 0; i < _source.Orders.Count; ++i)
+ {
+ if (_source.Orders[i].Id == model.Id)
+ {
+ var element = _source.Orders[i];
+ _source.Orders.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id.HasValue && order.Id == model.Id)
+ {
+ return order.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+
+ if (!model.Id.HasValue)
+ {
+ return result;
+ }
+
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id.HasValue && order.Id == model.Id)
+ {
+ result.Add(order.GetViewModel);
+ }
+ }
+
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+
+ foreach (var order in _source.Orders)
+ {
+ result.Add(order.GetViewModel);
+ }
+
+ return result;
+ }
+
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = 1;
+
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id <= order.Id)
+ {
+ model.Id = order.Id + 1;
+ }
+ }
+
+ var newOrder = Order.Create(model);
+
+ if (newOrder == null)
+ {
+ return null;
+ }
+
+ _source.Orders.Add(newOrder);
+
+ return newOrder.GetViewModel;
+ }
+
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return order.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/FurnitureAssemblyListImplement/Implements/ProductStorage.cs b/FurnitureAssemblyListImplement/Implements/ProductStorage.cs
new file mode 100644
index 0000000..830d38d
--- /dev/null
+++ b/FurnitureAssemblyListImplement/Implements/ProductStorage.cs
@@ -0,0 +1,126 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Implements
+{
+ public class ProductStorage : IProductStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public ProductStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public ProductViewModel? Delete(ProductBindingModel model)
+ {
+ for (int i = 0; i < _source.Products.Count; ++i)
+ {
+ if (_source.Products[i].Id == model.Id)
+ {
+ var element = _source.Products[i];
+ _source.Products.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public ProductViewModel? GetElement(ProductSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ProductName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+
+ foreach (var product in _source.Products)
+ {
+ if ((!string.IsNullOrEmpty(model.ProductName) && product.ProductName == model.ProductName) || (model.Id.HasValue && product.Id == model.Id))
+ {
+ return product.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public List GetFilteredList(ProductSearchModel model)
+ {
+ var result = new List();
+
+ if (string.IsNullOrEmpty(model.ProductName))
+ {
+ return result;
+ }
+
+ foreach (var product in _source.Products)
+ {
+ if (product.ProductName.Contains(model.ProductName))
+ {
+ result.Add(product.GetViewModel);
+ }
+ }
+
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+
+ foreach (var product in _source.Products)
+ {
+ result.Add(product.GetViewModel);
+ }
+
+ return result;
+ }
+
+ public ProductViewModel? Insert(ProductBindingModel model)
+ {
+ model.Id = 1;
+
+ foreach (var product in _source.Products)
+ {
+ if (model.Id <= product.Id)
+ {
+ model.Id = product.Id + 1;
+ }
+ }
+
+ var newProduct = Product.Create(model);
+
+ if (newProduct == null)
+ {
+ return null;
+ }
+
+ _source.Products.Add(newProduct);
+
+ return newProduct.GetViewModel;
+ }
+
+ public ProductViewModel? Update(ProductBindingModel model)
+ {
+ foreach (var product in _source.Products)
+ {
+ if (product.Id == model.Id)
+ {
+ product.Update(model);
+ return product.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/FurnitureAssemblyListImplement/Models/Component.cs b/FurnitureAssemblyListImplement/Models/Component.cs
new file mode 100644
index 0000000..a9b3fa4
--- /dev/null
+++ b/FurnitureAssemblyListImplement/Models/Component.cs
@@ -0,0 +1,51 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Models
+{
+ internal class Component : IComponentModel
+ {
+ public int Id { get; private set; }
+
+ public string ComponentName { get; private set; } = string.Empty;
+
+ public double Cost { get; set; }
+
+ public static Component? Create(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Component()
+ {
+ Id = model.Id,
+ ComponentName = model.ComponentName,
+ Cost = model.Cost
+ };
+ }
+
+ public void Update(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ComponentName = model.ComponentName;
+ Cost = model.Cost;
+ }
+
+ public ComponentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComponentName = ComponentName,
+ Cost = Cost
+ };
+ }
+}
diff --git a/FurnitureAssemblyListImplement/Models/Order.cs b/FurnitureAssemblyListImplement/Models/Order.cs
new file mode 100644
index 0000000..b0ff04f
--- /dev/null
+++ b/FurnitureAssemblyListImplement/Models/Order.cs
@@ -0,0 +1,77 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyDataModels.Enums;
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int ProductId { get; private set; }
+
+ public string ProductName { get; private set; }
+
+ public int Count { get; private set; }
+
+ public double Sum { get; private set; }
+
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+
+ public DateTime? DateImplement { get; private set; }
+
+ public int Id { get; private set; }
+
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ ProductId = model.ProductId,
+ ProductName = model.ProductName,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement
+ };
+ }
+
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ProductId = model.ProductId;
+ ProductName = model.ProductName;
+ Count = model.Count;
+ Sum = model.Sum;
+ Status = model.Status;
+ DateCreate = model.DateCreate;
+ DateImplement = model.DateImplement;
+ }
+
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ProductId = ProductId,
+ ProductName = ProductName,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+ }
+}
diff --git a/FurnitureAssemblyListImplement/Models/Product.cs b/FurnitureAssemblyListImplement/Models/Product.cs
new file mode 100644
index 0000000..5416b82
--- /dev/null
+++ b/FurnitureAssemblyListImplement/Models/Product.cs
@@ -0,0 +1,57 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Models
+{
+ internal class Product : IProductModel
+ {
+ public int Id { get; private set; }
+
+ public string ProductName { get; private set; } = string.Empty;
+
+ public double Price { get; private set; }
+
+ public Dictionary ProductComponents { get; private set; } = new Dictionary();
+
+ public static Product? Create(ProductBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Product()
+ {
+ Id = model.Id,
+ ProductName = model.ProductName,
+ Price = model.Price,
+ ProductComponents = model.ProductComponents
+ };
+ }
+
+ public void Update(ProductBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ProductName = model.ProductName;
+ Price = model.Price;
+ ProductComponents = model.ProductComponents;
+ }
+
+ public ProductViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ProductName = ProductName,
+ Price = Price,
+ ProductComponents = ProductComponents
+ };
+ }
+
+}