diff --git a/.gitignore b/.gitignore
index a2e929e..d813bb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+.idea
+
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
diff --git a/SoftwareInstallation/SoftwareInstallation.sln b/SoftwareInstallation/SoftwareInstallation.sln
new file mode 100644
index 0000000..404a0d4
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34408.163
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallationView", "SoftwareInstallation\SoftwareInstallationView.csproj", "{953D2A36-3A8C-411D-A7EB-650E2508A9C1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallationDataModels", "SoftwareInstallationDataModels\SoftwareInstallationDataModels.csproj", "{4FE3D032-B5DD-4B3F-90FC-B6B3BCAEB0F3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallationContracts", "SoftwareInstallationContracts\SoftwareInstallationContracts.csproj", "{FF58CE99-D5AF-4033-BBCB-B9C218891FFB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallationListImplement", "SoftwareInstallationListImplement\SoftwareInstallationListImplement.csproj", "{4784E414-2B47-43D0-AD65-19132F85C7EA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftwareInstallationBusinessLogic", "SoftwareInstallationBusinessLogic\SoftwareInstallationBusinessLogic.csproj", "{7F4E4DE0-F13B-4F3B-B86C-2C7017AD6CF3}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {953D2A36-3A8C-411D-A7EB-650E2508A9C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {953D2A36-3A8C-411D-A7EB-650E2508A9C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {953D2A36-3A8C-411D-A7EB-650E2508A9C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {953D2A36-3A8C-411D-A7EB-650E2508A9C1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4FE3D032-B5DD-4B3F-90FC-B6B3BCAEB0F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4FE3D032-B5DD-4B3F-90FC-B6B3BCAEB0F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4FE3D032-B5DD-4B3F-90FC-B6B3BCAEB0F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4FE3D032-B5DD-4B3F-90FC-B6B3BCAEB0F3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FF58CE99-D5AF-4033-BBCB-B9C218891FFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FF58CE99-D5AF-4033-BBCB-B9C218891FFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FF58CE99-D5AF-4033-BBCB-B9C218891FFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FF58CE99-D5AF-4033-BBCB-B9C218891FFB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4784E414-2B47-43D0-AD65-19132F85C7EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4784E414-2B47-43D0-AD65-19132F85C7EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4784E414-2B47-43D0-AD65-19132F85C7EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4784E414-2B47-43D0-AD65-19132F85C7EA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7F4E4DE0-F13B-4F3B-B86C-2C7017AD6CF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7F4E4DE0-F13B-4F3B-B86C-2C7017AD6CF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7F4E4DE0-F13B-4F3B-B86C-2C7017AD6CF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7F4E4DE0-F13B-4F3B-B86C-2C7017AD6CF3}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {C38ECABA-7A2F-415E-94A9-0EA63F3FB9F8}
+ EndGlobalSection
+EndGlobal
diff --git a/SoftwareInstallation/SoftwareInstallation/FormComponent.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormComponent.Designer.cs
new file mode 100644
index 0000000..1a95047
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormComponent.Designer.cs
@@ -0,0 +1,125 @@
+namespace SoftwareInstallationView
+{
+ 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()
+ {
+ labelName = new Label();
+ labelCost = new Label();
+ textBoxName = new TextBox();
+ textBoxCost = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Font = new Font("Segoe UI", 12F);
+ labelName.Location = new Point(14, 24);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(104, 28);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название:";
+ //
+ // labelCost
+ //
+ labelCost.AutoSize = true;
+ labelCost.Font = new Font("Segoe UI", 12F);
+ labelCost.Location = new Point(14, 68);
+ labelCost.Name = "labelCost";
+ labelCost.Size = new Size(63, 28);
+ labelCost.TabIndex = 1;
+ labelCost.Text = "Цена:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(117, 28);
+ textBoxName.Margin = new Padding(3, 4, 3, 4);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(317, 27);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxCost
+ //
+ textBoxCost.Location = new Point(117, 69);
+ textBoxCost.Margin = new Padding(3, 4, 3, 4);
+ textBoxCost.Name = "textBoxCost";
+ textBoxCost.Size = new Size(154, 27);
+ textBoxCost.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(241, 139);
+ buttonSave.Margin = new Padding(3, 4, 3, 4);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(98, 31);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(345, 139);
+ buttonCancel.Margin = new Padding(3, 4, 3, 4);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(86, 31);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.MouseCaptureChanged += ButtonCancel_Click;
+ //
+ // FormComponent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(445, 183);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCost);
+ Controls.Add(textBoxName);
+ Controls.Add(labelCost);
+ Controls.Add(labelName);
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormComponent";
+ Text = "Компонент";
+ Load += FormComponent_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelCost;
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormComponent.cs b/SoftwareInstallation/SoftwareInstallation/FormComponent.cs
new file mode 100644
index 0000000..6b8ee07
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormComponent.cs
@@ -0,0 +1,93 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+using SoftwareInstallationContracts.SearchModels;
+
+namespace SoftwareInstallationView
+{
+ 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/SoftwareInstallation/SoftwareInstallation/FormComponent.resx b/SoftwareInstallation/SoftwareInstallation/FormComponent.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/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/SoftwareInstallation/SoftwareInstallation/FormComponents.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormComponents.Designer.cs
new file mode 100644
index 0000000..cf82224
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormComponents.Designer.cs
@@ -0,0 +1,119 @@
+namespace SoftwareInstallationView
+{
+ 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()
+ {
+ dataGridView = new DataGridView();
+ buttonAdd = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonRefresh = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Left;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(631, 450);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(663, 45);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(109, 39);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(663, 116);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(109, 39);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpd_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(663, 184);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(109, 39);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDel_Click;
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Location = new Point(663, 256);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(109, 39);
+ buttonRefresh.TabIndex = 4;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRef_Click;
+ //
+ // FormComponents
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonRefresh);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormComponents";
+ Text = "Компоненты";
+ Load += FormComponents_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonRefresh;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormComponents.cs b/SoftwareInstallation/SoftwareInstallation/FormComponents.cs
new file mode 100644
index 0000000..2a64e0a
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormComponents.cs
@@ -0,0 +1,110 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallation;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+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 SoftwareInstallationView
+{ 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/SoftwareInstallation/SoftwareInstallation/FormComponents.resx b/SoftwareInstallation/SoftwareInstallation/FormComponents.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/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/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..8c6117f
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.Designer.cs
@@ -0,0 +1,152 @@
+namespace SoftwareInstallationView
+{
+ 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()
+ {
+ labelPackage = new Label();
+ labelCount = new Label();
+ labelSum = new Label();
+ textBoxSum = new TextBox();
+ textBoxCount = new TextBox();
+ comboBoxPackage = new ComboBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelPackage
+ //
+ labelPackage.AutoSize = true;
+ labelPackage.Location = new Point(14, 12);
+ labelPackage.Name = "labelPackage";
+ labelPackage.Size = new Size(71, 20);
+ labelPackage.TabIndex = 0;
+ labelPackage.Text = "Изделие:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(14, 49);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(93, 20);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество:";
+ //
+ // labelSum
+ //
+ labelSum.AutoSize = true;
+ labelSum.Location = new Point(14, 88);
+ labelSum.Name = "labelSum";
+ labelSum.Size = new Size(58, 20);
+ labelSum.TabIndex = 2;
+ labelSum.Text = "Сумма:";
+ //
+ // textBoxSum
+ //
+ textBoxSum.Enabled = false;
+ textBoxSum.Location = new Point(112, 84);
+ textBoxSum.Margin = new Padding(3, 4, 3, 4);
+ textBoxSum.Name = "textBoxSum";
+ textBoxSum.ReadOnly = true;
+ textBoxSum.Size = new Size(370, 27);
+ textBoxSum.TabIndex = 3;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(112, 45);
+ textBoxCount.Margin = new Padding(3, 4, 3, 4);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(370, 27);
+ textBoxCount.TabIndex = 4;
+ textBoxCount.TextChanged += TextBoxCount_TextChanged;
+ //
+ // comboBoxPackage
+ //
+ comboBoxPackage.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxPackage.FormattingEnabled = true;
+ comboBoxPackage.Location = new Point(112, 7);
+ comboBoxPackage.Margin = new Padding(3, 4, 3, 4);
+ comboBoxPackage.Name = "comboBoxPackage";
+ comboBoxPackage.Size = new Size(370, 28);
+ comboBoxPackage.TabIndex = 5;
+ comboBoxPackage.SelectedIndexChanged += ComboBoxPackage_SelectedIndexChanged;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(295, 129);
+ buttonSave.Margin = new Padding(3, 4, 3, 4);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(92, 31);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(397, 129);
+ buttonCancel.Margin = new Padding(3, 4, 3, 4);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(86, 31);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отменить";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormCreateOrder
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(496, 173);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(comboBoxPackage);
+ Controls.Add(textBoxCount);
+ Controls.Add(textBoxSum);
+ Controls.Add(labelSum);
+ Controls.Add(labelCount);
+ Controls.Add(labelPackage);
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormCreateOrder";
+ Text = "Заказ";
+ Load += FormCreateOrder_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelPackage;
+ private Label labelCount;
+ private Label labelSum;
+ private TextBox textBoxSum;
+ private TextBox textBoxCount;
+ private ComboBox comboBoxPackage;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.cs b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.cs
new file mode 100644
index 0000000..e816591
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.cs
@@ -0,0 +1,132 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+using SoftwareInstallationContracts.SearchModels;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageLogic _logicP;
+ private readonly IOrderLogic _logicO;
+ public FormCreateOrder(ILogger logger, IPackageLogic
+ logicP, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicO = logicO;
+ }
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка изделий для заказа");
+
+ try
+ {
+ var list = _logicP.ReadList(null);
+ if (list != null)
+ {
+ comboBoxPackage.DisplayMember = "PackageName";
+ comboBoxPackage.ValueMember = "Id";
+ comboBoxPackage.DataSource = list;
+ comboBoxPackage.SelectedItem = null;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки списка изделий");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ }
+ private void CalcSum()
+ {
+ if (comboBoxPackage.SelectedValue != null &&
+ !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxPackage.SelectedValue);
+ var Package = _logicP.ReadElement(new PackageSearchModel
+ {
+ Id = id
+ });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (Package?.Price ?? 0),
+ 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void TextBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void ComboBoxPackage_SelectedIndexChanged(object sender,
+ EventArgs e)
+ {
+ CalcSum();
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxPackage.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ PackageId = Convert.ToInt32(comboBoxPackage.SelectedValue),
+ 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/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.resx b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/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/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs
new file mode 100644
index 0000000..7566509
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs
@@ -0,0 +1,190 @@
+namespace SoftwareInstallationView
+{
+ 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()
+ {
+ menuStrip = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ компонентыToolStripMenuItem = new ToolStripMenuItem();
+ изделияToolStripMenuItem = new ToolStripMenuItem();
+ dataGridView = new DataGridView();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonIssuedOrder = new Button();
+ buttonRefresh = new Button();
+ menuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // menuStrip
+ //
+ menuStrip.ImageScalingSize = new Size(20, 20);
+ menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Padding = new Padding(7, 3, 0, 3);
+ menuStrip.Size = new Size(1077, 30);
+ menuStrip.TabIndex = 0;
+ menuStrip.Text = "menuStrip1";
+ //
+ // справочникиToolStripMenuItem
+ //
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem });
+ справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ справочникиToolStripMenuItem.Size = new Size(117, 24);
+ справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // компонентыToolStripMenuItem
+ //
+ компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ компонентыToolStripMenuItem.Size = new Size(182, 26);
+ компонентыToolStripMenuItem.Text = "Компоненты";
+ компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
+ //
+ // изделияToolStripMenuItem
+ //
+ изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
+ изделияToolStripMenuItem.Size = new Size(182, 26);
+ изделияToolStripMenuItem.Text = "Изделия";
+ изделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 36);
+ dataGridView.Margin = new Padding(3, 4, 3, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(879, 432);
+ dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonCreateOrder.Location = new Point(885, 77);
+ buttonCreateOrder.Margin = new Padding(3, 4, 3, 4);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(178, 41);
+ buttonCreateOrder.TabIndex = 2;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += ButtonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonTakeOrderInWork.Location = new Point(885, 127);
+ buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(178, 39);
+ buttonTakeOrderInWork.TabIndex = 3;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonOrderReady.Location = new Point(885, 173);
+ buttonOrderReady.Margin = new Padding(3, 4, 3, 4);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(178, 36);
+ buttonOrderReady.TabIndex = 4;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += ButtonOrderReady_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonIssuedOrder.Location = new Point(885, 217);
+ buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(178, 39);
+ buttonIssuedOrder.TabIndex = 5;
+ buttonIssuedOrder.Text = "Заказ выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(885, 264);
+ buttonRefresh.Margin = new Padding(3, 4, 3, 4);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(178, 39);
+ buttonRefresh.TabIndex = 6;
+ buttonRefresh.Text = "Обновить список";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRef_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1077, 467);
+ Controls.Add(buttonRefresh);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormMain";
+ Text = "Установка ПО";
+ Load += FormMain_Load;
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem изделияToolStripMenuItem;
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonRefresh;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.cs
new file mode 100644
index 0000000..016d516
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormMain.cs
@@ -0,0 +1,158 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallation;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+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 SoftwareInstallationView
+{
+ 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["PackageId"].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(FormComponents));
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackages));
+
+ if (service is FormPackages form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void ButtonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+ private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonOrderReady_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
+ id);
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
+ id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.resx b/SoftwareInstallation/SoftwareInstallation/FormMain.resx
new file mode 100644
index 0000000..6c82d08
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormMain.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackage.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormPackage.Designer.cs
new file mode 100644
index 0000000..096bb9d
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackage.Designer.cs
@@ -0,0 +1,242 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackage
+ {
+ ///
+ /// 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()
+ {
+ labelName = new Label();
+ labelPrice = new Label();
+ textBoxName = new TextBox();
+ textBoxPrice = new TextBox();
+ componentsGroupBox = new GroupBox();
+ buttonRefresh = new Button();
+ buttonDelete = new Button();
+ buttonUpdate = new Button();
+ buttonAdd = new Button();
+ componentsDataGridView = new DataGridView();
+ ColumnId = new DataGridViewTextBoxColumn();
+ ColumnComponent = new DataGridViewTextBoxColumn();
+ ColumnCount = new DataGridViewTextBoxColumn();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ componentsGroupBox.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)componentsDataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(14, 25);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(80, 20);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название:";
+ //
+ // labelPrice
+ //
+ labelPrice.AutoSize = true;
+ labelPrice.Location = new Point(14, 68);
+ labelPrice.Name = "labelPrice";
+ labelPrice.Size = new Size(86, 20);
+ labelPrice.TabIndex = 1;
+ labelPrice.Text = "Стоимость:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(102, 21);
+ textBoxName.Margin = new Padding(3, 4, 3, 4);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(350, 27);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Enabled = false;
+ textBoxPrice.Location = new Point(102, 64);
+ textBoxPrice.Margin = new Padding(3, 4, 3, 4);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.Size = new Size(173, 27);
+ textBoxPrice.TabIndex = 3;
+ //
+ // componentsGroupBox
+ //
+ componentsGroupBox.Controls.Add(buttonRefresh);
+ componentsGroupBox.Controls.Add(buttonDelete);
+ componentsGroupBox.Controls.Add(buttonUpdate);
+ componentsGroupBox.Controls.Add(buttonAdd);
+ componentsGroupBox.Controls.Add(componentsDataGridView);
+ componentsGroupBox.Location = new Point(14, 115);
+ componentsGroupBox.Margin = new Padding(3, 4, 3, 4);
+ componentsGroupBox.Name = "componentsGroupBox";
+ componentsGroupBox.Padding = new Padding(3, 4, 3, 4);
+ componentsGroupBox.Size = new Size(639, 375);
+ componentsGroupBox.TabIndex = 4;
+ componentsGroupBox.TabStop = false;
+ componentsGroupBox.Text = "Компоненты";
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Location = new Point(534, 204);
+ buttonRefresh.Margin = new Padding(3, 4, 3, 4);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(86, 31);
+ buttonRefresh.TabIndex = 4;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRef_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(534, 151);
+ buttonDelete.Margin = new Padding(3, 4, 3, 4);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(86, 31);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDel_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(534, 97);
+ buttonUpdate.Margin = new Padding(3, 4, 3, 4);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(86, 31);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpd_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(534, 47);
+ buttonAdd.Margin = new Padding(3, 4, 3, 4);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(86, 31);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // componentsDataGridView
+ //
+ componentsDataGridView.AllowUserToAddRows = false;
+ componentsDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ componentsDataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnComponent, ColumnCount });
+ componentsDataGridView.Location = new Point(7, 29);
+ componentsDataGridView.Margin = new Padding(3, 4, 3, 4);
+ componentsDataGridView.Name = "componentsDataGridView";
+ componentsDataGridView.RowHeadersVisible = false;
+ componentsDataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
+ componentsDataGridView.Size = new Size(505, 332);
+ componentsDataGridView.TabIndex = 0;
+ //
+ // ColumnId
+ //
+ ColumnId.HeaderText = "Id";
+ ColumnId.MinimumWidth = 6;
+ ColumnId.Name = "ColumnId";
+ ColumnId.Visible = false;
+ ColumnId.Width = 125;
+ //
+ // ColumnComponent
+ //
+ ColumnComponent.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ ColumnComponent.HeaderText = "Компонент";
+ ColumnComponent.MinimumWidth = 6;
+ ColumnComponent.Name = "ColumnComponent";
+ //
+ // ColumnCount
+ //
+ ColumnCount.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ ColumnCount.HeaderText = "Количество";
+ ColumnCount.MinimumWidth = 6;
+ ColumnCount.Name = "ColumnCount";
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(456, 501);
+ buttonSave.Margin = new Padding(3, 4, 3, 4);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(95, 31);
+ buttonSave.TabIndex = 5;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(565, 501);
+ buttonCancel.Margin = new Padding(3, 4, 3, 4);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(86, 31);
+ buttonCancel.TabIndex = 6;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormPackage
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(664, 548);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(componentsGroupBox);
+ Controls.Add(textBoxPrice);
+ Controls.Add(textBoxName);
+ Controls.Add(labelPrice);
+ Controls.Add(labelName);
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormPackage";
+ Text = "Изделие";
+ Load += FormPackage_Load;
+ componentsGroupBox.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)componentsDataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelPrice;
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private GroupBox componentsGroupBox;
+ private Button buttonAdd;
+ private DataGridView componentsDataGridView;
+ private Button buttonRefresh;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ private Button buttonSave;
+ private Button buttonCancel;
+ private DataGridViewTextBoxColumn ColumnId;
+ private DataGridViewTextBoxColumn ColumnComponent;
+ private DataGridViewTextBoxColumn ColumnCount;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackage.cs b/SoftwareInstallation/SoftwareInstallation/FormPackage.cs
new file mode 100644
index 0000000..2317f5b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackage.cs
@@ -0,0 +1,224 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallation;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationDataModels.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 SoftwareInstallationView
+{
+ public partial class FormPackage : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageLogic _logic;
+ private int? _id;
+ private Dictionary _PackageComponents;
+ public int Id { set { _id = value; } }
+ public FormPackage(ILogger logger, IPackageLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _PackageComponents = new Dictionary();
+ }
+ private void FormPackage_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+ try
+ {
+ var view = _logic.ReadElement(new PackageSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.PackageName;
+ textBoxPrice.Text = view.Price.ToString();
+ _PackageComponents = view.PackageComponents ?? new
+ Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+ try
+ {
+ if (_PackageComponents != null)
+ {
+ componentsDataGridView.Rows.Clear();
+ foreach (var pc in _PackageComponents)
+ {
+ componentsDataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
+ }
+ textBoxPrice.Text = CalcPrice().ToString();
+ }
+ }
+ 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(FormPackageComponent));
+ if (service is FormPackageComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
+ if (_PackageComponents.ContainsKey(form.Id))
+ {
+ _PackageComponents[form.Id] = (form.ComponentModel,
+ form.Count);
+ }
+ else
+ {
+ _PackageComponents.Add(form.Id, (form.ComponentModel,
+ form.Count));
+ }
+ LoadData();
+ }
+ }
+ }
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (componentsDataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormPackageComponent));
+ if (service is FormPackageComponent form)
+ {
+ int id =
+ Convert.ToInt32(componentsDataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _PackageComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
+ _PackageComponents[form.Id] = (form.ComponentModel,
+ form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (componentsDataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ try
+ {
+ _logger.LogInformation("Удаление компонента: {ComponentName} - {Count}", componentsDataGridView.SelectedRows[0].Cells[1].Value);
+ _PackageComponents?.Remove(Convert.ToInt32(componentsDataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(textBoxPrice.Text))
+ {
+ MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ return;
+ }
+ if (_PackageComponents == null || _PackageComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение изделия");
+ try
+ {
+ var model = new PackageBindingModel
+ {
+ Id = _id ?? 0,
+ PackageName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ PackageComponents = _PackageComponents
+ };
+ 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 _PackageComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackage.resx b/SoftwareInstallation/SoftwareInstallation/FormPackage.resx
new file mode 100644
index 0000000..5c6df87
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackage.resx
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.Designer.cs
new file mode 100644
index 0000000..4a7d9d9
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.Designer.cs
@@ -0,0 +1,128 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackageComponent
+ {
+ ///
+ /// 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()
+ {
+ labelComponent = new Label();
+ labelCount = new Label();
+ comboBoxComponent = new ComboBox();
+ textBoxCount = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelComponent
+ //
+ labelComponent.AutoSize = true;
+ labelComponent.Font = new Font("Segoe UI", 12F);
+ labelComponent.Location = new Point(14, 28);
+ labelComponent.Name = "labelComponent";
+ labelComponent.Size = new Size(120, 28);
+ labelComponent.TabIndex = 0;
+ labelComponent.Text = "Компонент:";
+ labelComponent.TextAlign = ContentAlignment.TopCenter;
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Font = new Font("Segoe UI", 12F);
+ labelCount.Location = new Point(14, 73);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(124, 28);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество:";
+ labelCount.TextAlign = ContentAlignment.TopCenter;
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(143, 31);
+ comboBoxComponent.Margin = new Padding(3, 4, 3, 4);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(347, 28);
+ comboBoxComponent.TabIndex = 2;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(143, 78);
+ textBoxCount.Margin = new Padding(3, 4, 3, 4);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(347, 27);
+ textBoxCount.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(312, 135);
+ buttonSave.Margin = new Padding(3, 4, 3, 4);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 31);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(413, 135);
+ buttonCancel.Margin = new Padding(3, 4, 3, 4);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(86, 31);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormPackageComponent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(512, 181);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxComponent);
+ Controls.Add(labelCount);
+ Controls.Add(labelComponent);
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormPackageComponent";
+ Text = "Компонент изделия";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelComponent;
+ private Label labelCount;
+ private ComboBox comboBoxComponent;
+ private TextBox textBoxCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.cs b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.cs
new file mode 100644
index 0000000..a878d31
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.cs
@@ -0,0 +1,89 @@
+using SoftwareInstallationContracts.BusinessLoginContacts;
+using SoftwareInstallationContracts.ViewModels;
+using SoftwareInstallationDataModels.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 SoftwareInstallationView
+{
+ public partial class FormPackageComponent : 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 FormPackageComponent(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/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.resx b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.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/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs
new file mode 100644
index 0000000..f2c1f25
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs
@@ -0,0 +1,119 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackages
+ {
+ ///
+ /// 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()
+ {
+ dataGridView = new DataGridView();
+ buttonAdd = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonRefresh = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(1, 1);
+ dataGridView.Margin = new Padding(3, 4, 3, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.Size = new Size(642, 660);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(669, 16);
+ buttonAdd.Margin = new Padding(3, 4, 3, 4);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(137, 55);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(669, 95);
+ buttonUpdate.Margin = new Padding(3, 4, 3, 4);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(137, 55);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(669, 173);
+ buttonDelete.Margin = new Padding(3, 4, 3, 4);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(137, 55);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Location = new Point(669, 255);
+ buttonRefresh.Margin = new Padding(3, 4, 3, 4);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(137, 55);
+ buttonRefresh.TabIndex = 4;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // FormPackages
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(819, 669);
+ Controls.Add(buttonRefresh);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormPackages";
+ Text = "Изделия";
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonRefresh;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackages.cs b/SoftwareInstallation/SoftwareInstallation/FormPackages.cs
new file mode 100644
index 0000000..c15ead4
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.cs
@@ -0,0 +1,113 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallation;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormPackages : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageLogic _logic;
+
+ public FormPackages(ILogger logger, IPackageLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ LoadData();
+ }
+
+ private void FormPackages_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["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["PackageComponents"].Visible = false;
+ }
+
+ _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(FormPackage));
+
+ if (service is FormPackage form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
+
+ if (service is FormPackage form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление изделия");
+
+ try
+ {
+ if (!_logic.Delete(new PackageBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRefresh_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackages.resx b/SoftwareInstallation/SoftwareInstallation/FormPackages.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.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/SoftwareInstallation/SoftwareInstallation/Program.cs b/SoftwareInstallation/SoftwareInstallation/Program.cs
new file mode 100644
index 0000000..e850c13
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/Program.cs
@@ -0,0 +1,55 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using SoftwareInstallationBusinessLogic.BusinessLogics;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+using SoftwareInstallationContracts.StoragesContracts;
+using SoftwareInstallationListImplement.Implements;
+using SoftwareInstallationView;
+
+namespace SoftwareInstallation
+{
+ internal static class Program
+ {
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+
+ ApplicationConfiguration.Initialize();
+ 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/SoftwareInstallation/SoftwareInstallation/SoftwareInstallationView.csproj b/SoftwareInstallation/SoftwareInstallation/SoftwareInstallationView.csproj
new file mode 100644
index 0000000..28d9b44
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/SoftwareInstallationView.csproj
@@ -0,0 +1,34 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+ Always
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/nlog.config b/SoftwareInstallation/SoftwareInstallation/nlog.config
new file mode 100644
index 0000000..fb403a9
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/nlog.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/ComponentLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/ComponentLogic.cs
new file mode 100644
index 0000000..253181b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/ComponentLogic.cs
@@ -0,0 +1,119 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.StoragesContracts;
+using SoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationBusinessLogic.BusinessLogics
+{
+ 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/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/OrderLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/OrderLogic.cs
new file mode 100644
index 0000000..dd59117
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -0,0 +1,148 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.StoragesContracts;
+using SoftwareInstallationContracts.ViewModels;
+using SoftwareInstallationDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationBusinessLogic.BusinessLogics
+{
+ 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)
+ {
+ var viewModel = _orderStorage.GetElement(new() { Id = model.Id });
+ if (viewModel == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (viewModel.Status + 1 != newStatus)
+ {
+ _logger.LogWarning("Обновление статуса на " + newStatus.ToString() + " вызвало ошибку. Статус заказа некорректен.");
+ return false;
+ }
+
+ model.Status = newStatus;
+
+ if (model.Status == OrderStatus.Выдан)
+ {
+ model.DateImplement = DateTime.Now;
+ }
+
+ model.Sum = viewModel.Sum;
+ model.Count = viewModel.Count;
+ model.PackageId = viewModel.PackageId;
+
+ CheckModel(model, false);
+
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status--;
+ _logger.LogWarning("Неудачная операция обновления статуса");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выполняется);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Готов);
+ }
+
+ public bool DeliveryOrder(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.PackageId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.PackageId));
+ }
+
+ 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.PackageId);
+ }
+ }
+
+}
diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/PackageLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/PackageLogic.cs
new file mode 100644
index 0000000..1401efa
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogics/PackageLogic.cs
@@ -0,0 +1,143 @@
+using Microsoft.Extensions.Logging;
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.BusinessLoginContacts;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.StoragesContracts;
+using SoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationBusinessLogic.BusinessLogics
+{
+ public class PackageLogic : IPackageLogic
+ {
+ private readonly ILogger _logger;
+
+ private readonly IPackageStorage _packageStorage;
+
+ public PackageLogic(ILogger logger, IPackageStorage packageStorage)
+ {
+ _logger = logger;
+ _packageStorage = packageStorage;
+ }
+
+ public bool Create(PackageBindingModel model)
+ {
+ CheckModel(model);
+
+ if (_packageStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool Delete(PackageBindingModel model)
+ {
+ CheckModel(model, false);
+
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+
+ if (_packageStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public PackageViewModel? ReadElement(PackageSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ _logger.LogInformation("ReadElement. PackageName:{PackageName}.Id:{Id}", model.PackageName, model.Id);
+
+ var element = _packageStorage.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(PackageSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. PackageName:{PackageName}.Id:{ Id}", model?.PackageName, model?.Id);
+
+ var list = model == null ? _packageStorage.GetFullList() : _packageStorage.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(PackageBindingModel model)
+ {
+ CheckModel(model);
+
+ if (_packageStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ private void CheckModel(PackageBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (!withParams)
+ {
+ return;
+ }
+
+ if (string.IsNullOrEmpty(model.PackageName))
+ {
+ throw new ArgumentNullException("Нет названия изделия", nameof(model.PackageName));
+ }
+
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
+ }
+
+ _logger.LogInformation("Package. PackageName:{PackageName}.Price:{ Cost}. Id: { Id}", model.PackageName, model.Price, model.Id);
+
+ var element = _packageStorage.GetElement(new PackageSearchModel
+ {
+ PackageName = model.PackageName
+ });
+
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Изделие с таким названием уже есть");
+ }
+ }
+ }
+
+}
diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj b/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj
new file mode 100644
index 0000000..3195c65
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..f1da9cf
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,16 @@
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..4cd27e8
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,21 @@
+using SoftwareInstallationDataModels.Enums;
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int PackageId { 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/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs
new file mode 100644
index 0000000..7832b5b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/BindingModels/PackageBindingModel.cs
@@ -0,0 +1,21 @@
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.BindingModels
+{
+ public class PackageBindingModel : IPackageModel
+ {
+ public int Id { get; set; }
+ public string PackageName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary PackageComponents
+ {
+ get;
+ set;
+ } = new();
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IComponentLogic.cs b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IComponentLogic.cs
new file mode 100644
index 0000000..ce8144b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IComponentLogic.cs
@@ -0,0 +1,20 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.BusinessLoginContacts
+{
+ 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/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IOrderLogic.cs b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IOrderLogic.cs
new file mode 100644
index 0000000..0858d4e
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IOrderLogic.cs
@@ -0,0 +1,20 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.BusinessLoginContacts
+{
+ 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/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IPackageLogic.cs b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IPackageLogic.cs
new file mode 100644
index 0000000..67c7b9f
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/BusinessLoginContacts/IPackageLogic.cs
@@ -0,0 +1,20 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.BusinessLoginContacts
+{
+ public interface IPackageLogic
+ {
+ List? ReadList(PackageSearchModel? model);
+ PackageViewModel? ReadElement(PackageSearchModel model);
+ bool Create(PackageBindingModel model);
+ bool Update(PackageBindingModel model);
+ bool Delete(PackageBindingModel model);
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..c15aff8
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..b2831f6
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs
new file mode 100644
index 0000000..43c90d4
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/SearchModels/PackageSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.SearchModels
+{
+ public class PackageSearchModel
+ {
+ public int? Id { get; set; }
+ public string? PackageName { get; set; }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationContracts/SoftwareInstallationContracts.csproj b/SoftwareInstallation/SoftwareInstallationContracts/SoftwareInstallationContracts.csproj
new file mode 100644
index 0000000..b59ce13
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/SoftwareInstallationContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..6e6115e
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,21 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..79db704
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,21 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IPackageStorage.cs b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IPackageStorage.cs
new file mode 100644
index 0000000..3148b30
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/StoragesContracts/IPackageStorage.cs
@@ -0,0 +1,21 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.StoragesContracts
+{
+ public interface IPackageStorage
+ {
+ List GetFullList();
+ List GetFilteredList(PackageSearchModel model);
+ PackageViewModel? GetElement(PackageSearchModel model);
+ PackageViewModel? Insert(PackageBindingModel model);
+ PackageViewModel? Update(PackageBindingModel model);
+ PackageViewModel? Delete(PackageBindingModel model);
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..083b3c3
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,19 @@
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.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/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..a328954
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,30 @@
+using SoftwareInstallationDataModels.Enums;
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+ public int PackageId { get; set; }
+ [DisplayName("Изделие")]
+ public string PackageName { 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/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs
new file mode 100644
index 0000000..c2b7fd0
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/PackageViewModel.cs
@@ -0,0 +1,24 @@
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationContracts.ViewModels
+{
+ public class PackageViewModel : IPackageModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название изделия")]
+ public string PackageName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary PackageComponents
+ {
+ get;
+ set;
+ } = new();
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/Enums/OrderStatus.cs b/SoftwareInstallation/SoftwareInstallationDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..f83f095
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/IId.cs b/SoftwareInstallation/SoftwareInstallationDataModels/IId.cs
new file mode 100644
index 0000000..4c444f5
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationDataModels/IId.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/Models/IComponentModel.cs b/SoftwareInstallation/SoftwareInstallationDataModels/Models/IComponentModel.cs
new file mode 100644
index 0000000..685e812
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationDataModels/Models/IComponentModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/Models/IOrderModel.cs b/SoftwareInstallation/SoftwareInstallationDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..acdb1b7
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationDataModels/Models/IOrderModel.cs
@@ -0,0 +1,19 @@
+using SoftwareInstallationDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int PackageId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/Models/IPackageModel.cs b/SoftwareInstallation/SoftwareInstallationDataModels/Models/IPackageModel.cs
new file mode 100644
index 0000000..cba5df1
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationDataModels/Models/IPackageModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationDataModels.Models
+{
+ public interface IPackageModel : IId
+ {
+ string PackageName { get; }
+ double Price { get; }
+ Dictionary PackageComponents { get; }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj b/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj
new file mode 100644
index 0000000..fa71b7a
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/DataListSingleton.cs b/SoftwareInstallation/SoftwareInstallationListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..00565cd
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/DataListSingleton.cs
@@ -0,0 +1,31 @@
+using SoftwareInstallationListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Packages { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Packages = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Implements/ComponentStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..1e4f269
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,108 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.StoragesContracts;
+using SoftwareInstallationContracts.ViewModels;
+using SoftwareInstallationListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationListImplement.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/SoftwareInstallation/SoftwareInstallationListImplement/Implements/OrderStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..36d5590
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,137 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.StoragesContracts;
+using SoftwareInstallationContracts.ViewModels;
+using SoftwareInstallationListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationListImplement.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(GetViewModelName(order));
+ }
+ }
+
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+
+ foreach (var order in _source.Orders)
+ {
+ result.Add(GetViewModelName(order));
+ }
+
+ 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;
+ }
+ private OrderViewModel GetViewModelName(Order model)
+ {
+ var res = model.GetViewModel;
+ foreach (var package in _source.Packages)
+ {
+ if (package.Id == model.PackageId)
+ {
+ res.PackageName = package.PackageName;
+ break;
+ }
+ }
+ return res;
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Implements/PackageStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/PackageStorage.cs
new file mode 100644
index 0000000..e6ff4d9
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/PackageStorage.cs
@@ -0,0 +1,124 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.SearchModels;
+using SoftwareInstallationContracts.StoragesContracts;
+using SoftwareInstallationContracts.ViewModels;
+using SoftwareInstallationListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationListImplement.Implements
+{
+ public class PackageStorage : IPackageStorage
+ {
+ private readonly DataListSingleton _source;
+ public PackageStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public PackageViewModel? Delete(PackageBindingModel model)
+ {
+ for (int i = 0; i < _source.Packages.Count; ++i)
+ {
+ if (_source.Packages[i].Id == model.Id)
+ {
+ var element = _source.Packages[i];
+ _source.Packages.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+ public PackageViewModel? GetElement(PackageSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+
+ foreach (var package in _source.Packages)
+ {
+ if ((!string.IsNullOrEmpty(model.PackageName) && package.PackageName == model.PackageName) || (model.Id.HasValue && package.Id == model.Id))
+ {
+ return package.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public List GetFilteredList(PackageSearchModel model)
+ {
+ var result = new List();
+
+ if (string.IsNullOrEmpty(model.PackageName))
+ {
+ return result;
+ }
+
+ foreach (var package in _source.Packages)
+ {
+ if (package.PackageName.Contains(model.PackageName))
+ {
+ result.Add(package.GetViewModel);
+ }
+ }
+
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+
+ foreach (var package in _source.Packages)
+ {
+ result.Add(package.GetViewModel);
+ }
+
+ return result;
+ }
+
+ public PackageViewModel? Insert(PackageBindingModel model)
+ {
+ model.Id = 1;
+
+ foreach (var package in _source.Packages)
+ {
+ if (model.Id <= package.Id)
+ {
+ model.Id = package.Id + 1;
+ }
+ }
+
+ var newPackage = Package.Create(model);
+
+ if (newPackage == null)
+ {
+ return null;
+ }
+
+ _source.Packages.Add(newPackage);
+
+ return newPackage.GetViewModel;
+ }
+
+ public PackageViewModel? Update(PackageBindingModel model)
+ {
+ foreach (var package in _source.Packages)
+ {
+ if (package.Id == model.Id)
+ {
+ package.Update(model);
+ return package.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+ }
+
+}
diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Models/Component.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Models/Component.cs
new file mode 100644
index 0000000..98c3dfc
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/Models/Component.cs
@@ -0,0 +1,46 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.ViewModels;
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationListImplement.Models
+{
+ public 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/SoftwareInstallation/SoftwareInstallationListImplement/Models/Order.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Models/Order.cs
new file mode 100644
index 0000000..ed4840e
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/Models/Order.cs
@@ -0,0 +1,56 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.ViewModels;
+using SoftwareInstallationDataModels.Enums;
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int PackageId { 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
+ {
+ PackageId = model.PackageId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ Id = model.Id,
+ };
+ }
+ public void Update(OrderBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Status = model.Status;
+ DateImplement = model.DateImplement;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ PackageId = PackageId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Models/Package.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Models/Package.cs
new file mode 100644
index 0000000..b1d69b4
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/Models/Package.cs
@@ -0,0 +1,55 @@
+using SoftwareInstallationContracts.BindingModels;
+using SoftwareInstallationContracts.ViewModels;
+using SoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SoftwareInstallationListImplement.Models
+{
+ public class Package : IPackageModel
+ {
+ public int Id { get; private set; }
+ public string PackageName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary PackageComponents
+ {
+ get;
+ private set;
+ } = new Dictionary();
+ public static Package? Create(PackageBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Package()
+ {
+
+ Id = model.Id,
+ PackageName = model.PackageName,
+ Price = model.Price,
+ PackageComponents = model.PackageComponents
+ };
+ }
+ public void Update(PackageBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ PackageName = model.PackageName;
+ Price = model.Price;
+ PackageComponents = model.PackageComponents;
+ }
+ public PackageViewModel GetViewModel => new()
+ {
+ Id = Id,
+ PackageName = PackageName,
+ Price = Price,
+ PackageComponents = PackageComponents
+ };
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj b/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj
new file mode 100644
index 0000000..d544409
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+