diff --git a/.gitignore b/.gitignore
index ca1c7a3..26212b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -397,4 +397,3 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
-
diff --git a/SushiBar/SushiBar.sln b/SushiBar/SushiBar.sln
new file mode 100644
index 0000000..6fd8544
--- /dev/null
+++ b/SushiBar/SushiBar.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.7.34031.279
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBar", "SushiBar\SushiBar.csproj", "{FA7992B7-E081-4E09-9CED-48394FA38B31}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarBusinessLogic", "SushiBarBusinessLogic\SushiBarBusinessLogic.csproj", "{2657FF86-010E-4A49-9D3F-01FCCAC286B1}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarContracts", "SushiBarContracts\SushiBarContracts.csproj", "{2D04F87F-2348-4540-9DCB-44A72201FA1B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarDataModels", "SushiBarDataModels\SushiBarDataModels.csproj", "{8073F7CA-FED3-48C5-B8CD-1A91A8D8D5BD}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarListImplement", "SushiBarListImplement\SushiBarListImplement.csproj", "{FE2BCA7B-A6E4-4628-9DCE-2F04F258BE1F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FA7992B7-E081-4E09-9CED-48394FA38B31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FA7992B7-E081-4E09-9CED-48394FA38B31}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FA7992B7-E081-4E09-9CED-48394FA38B31}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FA7992B7-E081-4E09-9CED-48394FA38B31}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2657FF86-010E-4A49-9D3F-01FCCAC286B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2657FF86-010E-4A49-9D3F-01FCCAC286B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2657FF86-010E-4A49-9D3F-01FCCAC286B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2657FF86-010E-4A49-9D3F-01FCCAC286B1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2D04F87F-2348-4540-9DCB-44A72201FA1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2D04F87F-2348-4540-9DCB-44A72201FA1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2D04F87F-2348-4540-9DCB-44A72201FA1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2D04F87F-2348-4540-9DCB-44A72201FA1B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8073F7CA-FED3-48C5-B8CD-1A91A8D8D5BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8073F7CA-FED3-48C5-B8CD-1A91A8D8D5BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8073F7CA-FED3-48C5-B8CD-1A91A8D8D5BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8073F7CA-FED3-48C5-B8CD-1A91A8D8D5BD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FE2BCA7B-A6E4-4628-9DCE-2F04F258BE1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FE2BCA7B-A6E4-4628-9DCE-2F04F258BE1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FE2BCA7B-A6E4-4628-9DCE-2F04F258BE1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FE2BCA7B-A6E4-4628-9DCE-2F04F258BE1F}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {28DB1CDE-A61B-4A26-A1F8-14D39B4DE40B}
+ EndGlobalSection
+EndGlobal
diff --git a/SushiBar/SushiBar/Forms/FormComponent.Designer.cs b/SushiBar/SushiBar/Forms/FormComponent.Designer.cs
new file mode 100644
index 0000000..ad848b9
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormComponent.Designer.cs
@@ -0,0 +1,102 @@
+namespace SushiBar.Forms
+{
+ 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()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormComponent));
+ label1 = new Label();
+ textBoxName = new TextBox();
+ textBoxCost = new TextBox();
+ label2 = new Label();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // label1
+ //
+ resources.ApplyResources(label1, "label1");
+ label1.Name = "label1";
+ //
+ // textBoxName
+ //
+ resources.ApplyResources(textBoxName, "textBoxName");
+ textBoxName.Name = "textBoxName";
+ //
+ // textBoxCost
+ //
+ resources.ApplyResources(textBoxCost, "textBoxCost");
+ textBoxCost.Name = "textBoxCost";
+ //
+ // label2
+ //
+ resources.ApplyResources(label2, "label2");
+ label2.Name = "label2";
+ //
+ // buttonSave
+ //
+ resources.ApplyResources(buttonSave, "buttonSave");
+ buttonSave.Name = "buttonSave";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ resources.ApplyResources(buttonCancel, "buttonCancel");
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormComponent
+ //
+ resources.ApplyResources(this, "$this");
+ AutoScaleMode = AutoScaleMode.None;
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCost);
+ Controls.Add(label2);
+ Controls.Add(textBoxName);
+ Controls.Add(label1);
+ MaximizeBox = false;
+ Name = "FormComponent";
+ ShowInTaskbar = false;
+ TopMost = true;
+ Load += FormComponent_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ private Label label2;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormComponent.cs b/SushiBar/SushiBar/Forms/FormComponent.cs
new file mode 100644
index 0000000..1c22dbe
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormComponent.cs
@@ -0,0 +1,17 @@
+using System;
+namespace SushiBar.Forms
+{
+ public partial class FormComponent
+ {
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ ButtonSave_Click(sender, e);
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ ButtonCancel_Click(sender, e);
+
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormComponent.resx b/SushiBar/SushiBar/Forms/FormComponent.resx
new file mode 100644
index 0000000..4cf9735
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormComponent.resx
@@ -0,0 +1,305 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ buttonSave
+
+
+ System.Windows.Forms.TextBox, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ 0
+
+
+
+ 222, 85
+
+
+ 95, 39
+
+
+ buttonCancel
+
+
+ 8, 20
+
+
+ label1
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Windows.Forms.TextBox, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ FormComponent
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ 2
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 800, 450
+
+
+ 5
+
+
+ 2
+
+
+ 222, 85
+
+
+ $this
+
+
+ 0
+
+
+ 68, 6
+
+
+ FormComponent
+
+
+ 4
+
+
+ 1
+
+
+ 5
+
+
+ $this
+
+
+ 12, 9
+
+
+ 3
+
+
+ $this
+
+
+ 5
+
+
+ textBox1
+
+
+ 1
+
+
+ 1
+
+
+ 95, 85
+
+
+ $this
+
+
+ textBoxCost
+
+
+ 3
+
+
+ 1
+
+
+ 4
+
+
+ $this
+
+
+ button1
+
+
+ button2
+
+
+ 0
+
+
+ 95, 85
+
+
+ $this
+
+
+ System.Windows.Forms.Form, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 12, 42
+
+
+ System.Windows.Forms.TextBox, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ textBoxName
+
+
+ label2
+
+
+ 4
+
+
+ 95, 6
+
+
+ 0
+
+
+ ru
+
+
+ True
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormComponent.ru.resx b/SushiBar/SushiBar/Forms/FormComponent.ru.resx
new file mode 100644
index 0000000..14672e4
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormComponent.ru.resx
@@ -0,0 +1,171 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+
+ 77, 20
+
+
+ Название
+
+
+ 246, 27
+
+
+ 246, 27
+
+
+ True
+
+
+
+ NoControl
+
+
+ 45, 20
+
+
+ Цена
+
+
+ 121, 29
+
+
+ Сохранить
+
+
+ NoControl
+
+
+ 119, 29
+
+
+ Отмена
+
+
+ 353, 126
+
+
+ Компонент
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormComponentLogic.cs b/SushiBar/SushiBar/Forms/FormComponentLogic.cs
new file mode 100644
index 0000000..7225978
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormComponentLogic.cs
@@ -0,0 +1,81 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace SushiBar.Forms
+{
+ 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/SushiBar/SushiBar/Forms/FormComponents.Designer.cs b/SushiBar/SushiBar/Forms/FormComponents.Designer.cs
new file mode 100644
index 0000000..b68809c
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormComponents.Designer.cs
@@ -0,0 +1,116 @@
+namespace SushiBar.Forms
+{
+ 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();
+ buttonUpd = new Button();
+ buttonDel = new Button();
+ buttonRef = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(694, 408);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(700, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(180, 29);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(700, 47);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(180, 29);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(700, 82);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(180, 29);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(700, 117);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(180, 29);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // FormComponents
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(892, 408);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonUpd);
+ 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 buttonUpd;
+ private Button buttonDel;
+ private Button buttonRef;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormComponents.cs b/SushiBar/SushiBar/Forms/FormComponents.cs
new file mode 100644
index 0000000..a2b5925
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormComponents.cs
@@ -0,0 +1,35 @@
+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 SushiBar.Forms
+{
+ public partial class FormComponents
+ {
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ ButtonAdd_Click(sender, e);
+ }
+
+ private void buttonUpd_Click(object sender, EventArgs e)
+ {
+ ButtonUpd_Click(sender, e);
+ }
+
+ private void buttonDel_Click(object sender, EventArgs e)
+ {
+ ButtonDel_Click(sender, e);
+ }
+
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ ButtonRef_Click(sender, e);
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormComponents.resx b/SushiBar/SushiBar/Forms/FormComponents.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/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/SushiBar/SushiBar/Forms/FormComponentsLogic.cs b/SushiBar/SushiBar/Forms/FormComponentsLogic.cs
new file mode 100644
index 0000000..7943174
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormComponentsLogic.cs
@@ -0,0 +1,98 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace SushiBar.Forms
+{
+ 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/SushiBar/SushiBar/Forms/FormCreateOrder.Designer.cs b/SushiBar/SushiBar/Forms/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..22d1beb
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormCreateOrder.Designer.cs
@@ -0,0 +1,146 @@
+namespace SushiBar.Forms
+{
+ 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()
+ {
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ label1 = new Label();
+ label2 = new Label();
+ label3 = new Label();
+ textBoxCount = new TextBox();
+ textBoxSum = new TextBox();
+ comboBoxSushi = new ComboBox();
+ SuspendLayout();
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(185, 112);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(100, 30);
+ buttonSave.TabIndex = 0;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(291, 112);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(100, 30);
+ buttonCancel.TabIndex = 1;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 15);
+ label1.Name = "label1";
+ label1.Size = new Size(49, 20);
+ label1.TabIndex = 2;
+ label1.Text = "Суши:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(12, 49);
+ label2.Name = "label2";
+ label2.Size = new Size(93, 20);
+ label2.TabIndex = 3;
+ label2.Text = "Количество:";
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(12, 82);
+ label3.Name = "label3";
+ label3.Size = new Size(58, 20);
+ label3.TabIndex = 4;
+ label3.Text = "Сумма:";
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(119, 46);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(272, 27);
+ textBoxCount.TabIndex = 5;
+ textBoxCount.TextChanged += textBoxCount_TextChanged;
+ //
+ // textBoxSum
+ //
+ textBoxSum.Location = new Point(119, 79);
+ textBoxSum.Name = "textBoxSum";
+ textBoxSum.ReadOnly = true;
+ textBoxSum.Size = new Size(272, 27);
+ textBoxSum.TabIndex = 6;
+ //
+ // comboBoxSushi
+ //
+ comboBoxSushi.FormattingEnabled = true;
+ comboBoxSushi.Location = new Point(119, 12);
+ comboBoxSushi.Name = "comboBoxSushi";
+ comboBoxSushi.Size = new Size(272, 28);
+ comboBoxSushi.TabIndex = 7;
+ comboBoxSushi.SelectedIndexChanged += comboBoxSushi_SelectedIndexChanged;
+ //
+ // FormCreateOrder
+ //
+ AutoScaleMode = AutoScaleMode.None;
+ ClientSize = new Size(403, 152);
+ Controls.Add(comboBoxSushi);
+ Controls.Add(textBoxSum);
+ Controls.Add(textBoxCount);
+ Controls.Add(label3);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ MaximizeBox = false;
+ MinimizeBox = false;
+ Name = "FormCreateOrder";
+ ShowInTaskbar = false;
+ Text = "Заказ";
+ Load += FormCreateOrder_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label label1;
+ private Label label2;
+ private Label label3;
+ private TextBox textBoxCount;
+ private TextBox textBoxSum;
+ private ComboBox comboBoxSushi;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormCreateOrder.cs b/SushiBar/SushiBar/Forms/FormCreateOrder.cs
new file mode 100644
index 0000000..216ce4f
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormCreateOrder.cs
@@ -0,0 +1,35 @@
+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 SushiBar.Forms
+{
+ public partial class FormCreateOrder
+ {
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ ButtonSave_Click(sender, e);
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ ButtonCancel_Click(sender, e);
+ }
+
+ private void textBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ TextBoxCount_TextChanged(sender, e);
+ }
+
+ private void comboBoxSushi_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ ComboBoxSushi_SelectedIndexChanged(sender, e);
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormCreateOrder.resx b/SushiBar/SushiBar/Forms/FormCreateOrder.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/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/SushiBar/SushiBar/Forms/FormCreateOrderLogic.cs b/SushiBar/SushiBar/Forms/FormCreateOrderLogic.cs
new file mode 100644
index 0000000..4801e2e
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormCreateOrderLogic.cs
@@ -0,0 +1,115 @@
+using Microsoft.Extensions.Logging;
+using Microsoft.VisualBasic.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+using System.Windows.Forms;
+
+namespace SushiBar.Forms
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly ISushiLogic _logicS;
+ private readonly IOrderLogic _logicO;
+ public FormCreateOrder(ILogger logger, ISushiLogic logicS, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicS = logicS;
+ _logicO = logicO;
+ }
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ _logger.LogInformation("Загрузка суши для заказа");
+ List? _list = _logicS.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxSushi.DisplayMember = "SushiName";
+ comboBoxSushi.ValueMember = "Id";
+ comboBoxSushi.DataSource = _list;
+ comboBoxSushi.SelectedItem = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки суши");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void CalcSum()
+ {
+ if (comboBoxSushi.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxSushi.SelectedValue);
+ var sushi = _logicS.ReadElement(new SushiSearchModel
+ {
+ Id = id
+ });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (sushi?.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 ComboBoxSushi_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 (comboBoxSushi.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ SushiId = Convert.ToInt32(comboBoxSushi.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/SushiBar/SushiBar/Forms/FormMain.Designer.cs b/SushiBar/SushiBar/Forms/FormMain.Designer.cs
new file mode 100644
index 0000000..e2eb16f
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormMain.Designer.cs
@@ -0,0 +1,174 @@
+namespace SushiBar.Forms
+{
+ 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()
+ {
+ dataGridView = new DataGridView();
+ menuStrip1 = new MenuStrip();
+ ToolStripMenuItem = new ToolStripMenuItem();
+ sushiToolStripMenuItem = new ToolStripMenuItem();
+ componentsToolStripMenuItem = new ToolStripMenuItem();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonIssuedOrder = new Button();
+ buttonRef = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ menuStrip1.SuspendLayout();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Left;
+ dataGridView.Location = new Point(0, 28);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(980, 422);
+ dataGridView.TabIndex = 0;
+ //
+ // menuStrip1
+ //
+ menuStrip1.ImageScalingSize = new Size(20, 20);
+ menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Size = new Size(1190, 28);
+ menuStrip1.TabIndex = 1;
+ menuStrip1.Text = "menuStrip1";
+ //
+ // ToolStripMenuItem
+ //
+ ToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { sushiToolStripMenuItem, componentsToolStripMenuItem });
+ ToolStripMenuItem.Name = "ToolStripMenuItem";
+ ToolStripMenuItem.Size = new Size(117, 24);
+ ToolStripMenuItem.Text = "Справочники";
+ //
+ // sushiToolStripMenuItem
+ //
+ sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
+ sushiToolStripMenuItem.Size = new Size(182, 26);
+ sushiToolStripMenuItem.Text = "Суши";
+ sushiToolStripMenuItem.Click += sushiToolStripMenuItem_Click;
+ //
+ // componentsToolStripMenuItem
+ //
+ componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
+ componentsToolStripMenuItem.Size = new Size(182, 26);
+ componentsToolStripMenuItem.Text = "Компоненты";
+ componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Location = new Point(998, 50);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(180, 30);
+ buttonCreateOrder.TabIndex = 2;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += buttonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Location = new Point(998, 86);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(180, 30);
+ buttonTakeOrderInWork.TabIndex = 3;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Location = new Point(998, 122);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(180, 30);
+ buttonOrderReady.TabIndex = 4;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += buttonOrderReady_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Location = new Point(998, 158);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(180, 30);
+ buttonIssuedOrder.TabIndex = 5;
+ buttonIssuedOrder.Text = "Заказ Выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += buttonIssuedOrder_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(998, 194);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(180, 30);
+ buttonRef.TabIndex = 6;
+ buttonRef.Text = "Обновить список";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1190, 450);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip1);
+ MainMenuStrip = menuStrip1;
+ Name = "FormMain";
+ Text = "Сушибар";
+ Load += FormMain_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private MenuStrip menuStrip1;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonRef;
+ private ToolStripMenuItem ToolStripMenuItem;
+ private ToolStripMenuItem sushiToolStripMenuItem;
+ private ToolStripMenuItem componentsToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormMain.cs b/SushiBar/SushiBar/Forms/FormMain.cs
new file mode 100644
index 0000000..f9a5708
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormMain.cs
@@ -0,0 +1,40 @@
+namespace SushiBar.Forms
+{
+ public partial class FormMain
+ {
+ private void buttonCreateOrder_Click(object sender, EventArgs e)
+ {
+ ButtonCreateOrder_Click(sender, e);
+ }
+
+ private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ ButtonTakeOrderInWork_Click(sender, e);
+ }
+
+ private void buttonOrderReady_Click(object sender, EventArgs e)
+ {
+ ButtonOrderReady_Click(sender, e);
+ }
+
+ private void buttonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ ButtonIssuedOrder_Click(sender, e);
+ }
+
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ ButtonRef_Click(sender, e);
+ }
+
+ private void sushiToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ SushiToolStripMenuItem_Click(sender, e);
+ }
+
+ private void componentsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ ComponentsToolStripMenuItem_Click(sender, e);
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormMain.resx b/SushiBar/SushiBar/Forms/FormMain.resx
new file mode 100644
index 0000000..a0623c8
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/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/SushiBar/SushiBar/Forms/FormMainLogic.cs b/SushiBar/SushiBar/Forms/FormMainLogic.cs
new file mode 100644
index 0000000..7d96481
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormMainLogic.cs
@@ -0,0 +1,140 @@
+using Microsoft.Extensions.Logging;
+using SushiBarBusinessLogic.BusinessLogics;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarDataModels.Enums;
+using System.Windows.Forms;
+
+namespace SushiBar.Forms
+{
+ 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()
+ {
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["SushiId"].Visible = false;
+ dataGridView.Columns["SushiName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка заказов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки суши");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void SushiToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormSushis));
+ if (service is FormSushis 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/SushiBar/SushiBar/Forms/FormSushi.Designer.cs b/SushiBar/SushiBar/Forms/FormSushi.Designer.cs
new file mode 100644
index 0000000..83ce316
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushi.Designer.cs
@@ -0,0 +1,253 @@
+namespace SushiBar.Forms
+{
+ partial class FormSushi
+ {
+ ///
+ /// 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()
+ {
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ID = new DataGridViewTextBoxColumn();
+ ComponentName = new DataGridViewTextBoxColumn();
+ ComponentCount = new DataGridViewTextBoxColumn();
+ groupBox1 = new GroupBox();
+ buttonRef = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ label1 = new Label();
+ label2 = new Label();
+ textBoxPrice = new TextBox();
+ textBoxName = new TextBox();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ groupBox1.SuspendLayout();
+ SuspendLayout();
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(640, 29);
+ buttonAdd.Margin = new Padding(3, 4, 3, 4);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(126, 39);
+ buttonAdd.TabIndex = 0;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ComponentName, ComponentCount });
+ dataGridView.Location = new Point(3, 24);
+ dataGridView.Margin = new Padding(3, 4, 3, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(630, 263);
+ dataGridView.TabIndex = 1;
+ //
+ // ID
+ //
+ ID.HeaderText = "";
+ ID.MinimumWidth = 6;
+ ID.Name = "ID";
+ ID.ReadOnly = true;
+ ID.Visible = false;
+ ID.Width = 125;
+ //
+ // ComponentName
+ //
+ ComponentName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ ComponentName.HeaderText = "Компонент";
+ ComponentName.MinimumWidth = 6;
+ ComponentName.Name = "ComponentName";
+ ComponentName.ReadOnly = true;
+ //
+ // ComponentCount
+ //
+ ComponentCount.HeaderText = "Количество";
+ ComponentCount.MinimumWidth = 6;
+ ComponentCount.Name = "ComponentCount";
+ ComponentCount.ReadOnly = true;
+ ComponentCount.Width = 125;
+ //
+ // groupBox1
+ //
+ groupBox1.Controls.Add(buttonRef);
+ groupBox1.Controls.Add(buttonDel);
+ groupBox1.Controls.Add(buttonUpd);
+ groupBox1.Controls.Add(dataGridView);
+ groupBox1.Controls.Add(buttonAdd);
+ groupBox1.Location = new Point(14, 101);
+ groupBox1.Margin = new Padding(3, 4, 3, 4);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Padding = new Padding(3, 4, 3, 4);
+ groupBox1.Size = new Size(773, 295);
+ groupBox1.TabIndex = 2;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Компоненты";
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(640, 169);
+ buttonRef.Margin = new Padding(3, 4, 3, 4);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(126, 39);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(640, 123);
+ buttonDel.Margin = new Padding(3, 4, 3, 4);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(126, 39);
+ buttonDel.TabIndex = 3;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(640, 76);
+ buttonUpd.Margin = new Padding(3, 4, 3, 4);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(126, 39);
+ buttonUpd.TabIndex = 2;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(573, 404);
+ buttonSave.Margin = new Padding(3, 4, 3, 4);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(100, 31);
+ buttonSave.TabIndex = 3;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(679, 404);
+ buttonCancel.Margin = new Padding(3, 4, 3, 4);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(100, 31);
+ buttonCancel.TabIndex = 4;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(25, 16);
+ label1.Name = "label1";
+ label1.Size = new Size(80, 20);
+ label1.TabIndex = 5;
+ label1.Text = "Название:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(25, 60);
+ label2.Name = "label2";
+ label2.Size = new Size(86, 20);
+ label2.TabIndex = 6;
+ label2.Text = "Стоимость:";
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Location = new Point(112, 56);
+ textBoxPrice.Margin = new Padding(3, 4, 3, 4);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.Size = new Size(278, 27);
+ textBoxPrice.TabIndex = 7;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(112, 17);
+ textBoxName.Margin = new Padding(3, 4, 3, 4);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(278, 27);
+ textBoxName.TabIndex = 8;
+ //
+ // FormSushi
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 451);
+ Controls.Add(textBoxName);
+ Controls.Add(textBoxPrice);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(groupBox1);
+ MaximizeBox = false;
+ MinimizeBox = false;
+ Name = "FormSushi";
+ ShowInTaskbar = false;
+ Text = "Суши";
+ TopMost = true;
+ Load += FormSushi_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ groupBox1.ResumeLayout(false);
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ private GroupBox groupBox1;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label label1;
+ private Label label2;
+ private TextBox textBoxPrice;
+ private TextBox textBoxName;
+ private DataGridViewTextBoxColumn ID;
+ private DataGridViewTextBoxColumn ComponentName;
+ private DataGridViewTextBoxColumn ComponentCount;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormSushi.cs b/SushiBar/SushiBar/Forms/FormSushi.cs
new file mode 100644
index 0000000..8e40fa5
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushi.cs
@@ -0,0 +1,35 @@
+namespace SushiBar.Forms
+{
+ public partial class FormSushi
+ {
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ ButtonAdd_Click(sender, e);
+ }
+
+ private void buttonUpd_Click(object sender, EventArgs e)
+ {
+ ButtonUpd_Click(sender, e);
+ }
+
+ private void buttonDel_Click(object sender, EventArgs e)
+ {
+ ButtonDel_Click(sender, e);
+ }
+
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ ButtonRef_Click(sender, e);
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ ButtonSave_Click(sender, e);
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ ButtonCancel_Click(sender, e);
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormSushi.resx b/SushiBar/SushiBar/Forms/FormSushi.resx
new file mode 100644
index 0000000..610eb88
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushi.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/SushiBar/SushiBar/Forms/FormSushiComponent.Designer.cs b/SushiBar/SushiBar/Forms/FormSushiComponent.Designer.cs
new file mode 100644
index 0000000..0563bb3
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushiComponent.Designer.cs
@@ -0,0 +1,122 @@
+namespace SushiBar.Forms
+{
+ partial class FormSushiComponent
+ {
+ ///
+ /// 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()
+ {
+ label1 = new Label();
+ label2 = new Label();
+ comboBoxComponent = new ComboBox();
+ textBoxCount = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 15);
+ label1.Name = "label1";
+ label1.Size = new Size(91, 20);
+ label1.TabIndex = 0;
+ label1.Text = "Компонент:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(12, 65);
+ label2.Name = "label2";
+ label2.Size = new Size(93, 20);
+ label2.TabIndex = 1;
+ label2.Text = "Количество:";
+ //
+ // comboBoxComponent
+ //
+ comboBoxComponent.FormattingEnabled = true;
+ comboBoxComponent.Location = new Point(125, 12);
+ comboBoxComponent.Name = "comboBoxComponent";
+ comboBoxComponent.Size = new Size(227, 28);
+ comboBoxComponent.TabIndex = 2;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(125, 62);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(227, 27);
+ textBoxCount.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(158, 95);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(258, 95);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormSushiComponent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(364, 132);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxComponent);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ MaximizeBox = false;
+ MinimizeBox = false;
+ Name = "FormSushiComponent";
+ ShowInTaskbar = false;
+ Text = "Компонент Изделия";
+ TopMost = true;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private Label label2;
+ private ComboBox comboBoxComponent;
+ private TextBox textBoxCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormSushiComponent.cs b/SushiBar/SushiBar/Forms/FormSushiComponent.cs
new file mode 100644
index 0000000..994a0b3
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushiComponent.cs
@@ -0,0 +1,25 @@
+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 SushiBar.Forms
+{
+ public partial class FormSushiComponent
+ {
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ ButtonSave_Click(sender, e);
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ ButtonCancel_Click(sender, e);
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormSushiComponent.resx b/SushiBar/SushiBar/Forms/FormSushiComponent.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushiComponent.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/SushiBar/SushiBar/Forms/FormSushiComponentLogic.cs b/SushiBar/SushiBar/Forms/FormSushiComponentLogic.cs
new file mode 100644
index 0000000..bcbd12e
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushiComponentLogic.cs
@@ -0,0 +1,78 @@
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+
+namespace SushiBar.Forms
+{
+ partial class FormSushiComponent : 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 FormSushiComponent(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/SushiBar/SushiBar/Forms/FormSushiLogic.cs b/SushiBar/SushiBar/Forms/FormSushiLogic.cs
new file mode 100644
index 0000000..9df5936
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushiLogic.cs
@@ -0,0 +1,199 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using SushiBarDataModels.Models;
+
+namespace SushiBar.Forms
+{
+ public partial class FormSushi : Form
+ {
+ private readonly ILogger _logger;
+ private readonly ISushiLogic _logic;
+ private int? _id;
+ private Dictionary _sushiComponents;
+ public int Id { set { _id = value; } }
+ public FormSushi(ILogger logger, ISushiLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _sushiComponents = new Dictionary();
+ }
+ private void FormSushi_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+ try
+ {
+ var view = _logic.ReadElement(new SushiSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.SushiName;
+ textBoxPrice.Text = view.Price.ToString();
+ _sushiComponents = view.SushiComponents ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+ try
+ {
+ if (_sushiComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var sc in _sushiComponents)
+ {
+ dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.ComponentName, sc.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(FormSushiComponent));
+ if (service is FormSushiComponent form)
+ {
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ if (_sushiComponents.ContainsKey(form.Id))
+ {
+ _sushiComponents[form.Id] = (form.ComponentModel, form.Count);
+ }
+ else
+ {
+ _sushiComponents.Add(form.Id, (form.ComponentModel, form.Count));
+ }
+ LoadData();
+ }
+ }
+ }
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent));
+ if (service is FormSushiComponent form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _sushiComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ _sushiComponents[form.Id] = (form.ComponentModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ try
+ {
+ _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
+ _sushiComponents?.Remove(Convert.ToInt32(dataGridView.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 (_sushiComponents == null || _sushiComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение изделия");
+ try
+ {
+ var model = new SushiBindingModel
+ {
+ Id = _id ?? 0,
+ SushiName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ SushiComponents = _sushiComponents
+ };
+ 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 _sushiComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormSushis.Designer.cs b/SushiBar/SushiBar/Forms/FormSushis.Designer.cs
new file mode 100644
index 0000000..b340685
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushis.Designer.cs
@@ -0,0 +1,117 @@
+namespace SushiBar.Forms
+{
+ partial class FormSushis
+ {
+ ///
+ /// 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();
+ buttonRef = new Button();
+ buttonDel = new Button();
+ buttonUpd = new Button();
+ buttonAdd = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 70;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(762, 450);
+ dataGridView.TabIndex = 1;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(768, 117);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(114, 29);
+ buttonRef.TabIndex = 8;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += buttonRef_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Location = new Point(768, 82);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(114, 29);
+ buttonDel.TabIndex = 7;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += buttonDel_Click;
+ //
+ // buttonUpd
+ //
+ buttonUpd.Location = new Point(768, 47);
+ buttonUpd.Name = "buttonUpd";
+ buttonUpd.Size = new Size(114, 29);
+ buttonUpd.TabIndex = 6;
+ buttonUpd.Text = "Изменить";
+ buttonUpd.UseVisualStyleBackColor = true;
+ buttonUpd.Click += buttonUpd_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(768, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(114, 29);
+ buttonAdd.TabIndex = 5;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // FormSushis
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(893, 450);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonDel);
+ Controls.Add(buttonUpd);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormSushis";
+ Text = "Суши";
+ Load += FormSushis_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormSushis.cs b/SushiBar/SushiBar/Forms/FormSushis.cs
new file mode 100644
index 0000000..6a12f95
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushis.cs
@@ -0,0 +1,35 @@
+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 SushiBar.Forms
+{
+ public partial class FormSushis
+ {
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ ButtonAdd_Click(sender, e);
+ }
+
+ private void buttonUpd_Click(object sender, EventArgs e)
+ {
+ ButtonUpd_Click(sender, e);
+ }
+
+ private void buttonDel_Click(object sender, EventArgs e)
+ {
+ ButtonDel_Click(sender, e);
+ }
+
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ ButtonRef_Click(sender, e);
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormSushis.resx b/SushiBar/SushiBar/Forms/FormSushis.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushis.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/SushiBar/SushiBar/Forms/FormSushisLogic.cs b/SushiBar/SushiBar/Forms/FormSushisLogic.cs
new file mode 100644
index 0000000..caefccd
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormSushisLogic.cs
@@ -0,0 +1,99 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+
+namespace SushiBar.Forms
+{
+ public partial class FormSushis : Form
+ {
+ private readonly ILogger _logger;
+ private readonly ISushiLogic _logic;
+ public FormSushis(ILogger logger, ISushiLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormSushis_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["SushiComponents"].Visible = false;
+ dataGridView.Columns["SushiName"].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(FormSushi));
+ if (service is FormSushi 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(FormSushi));
+ if (service is FormSushi 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 SushiBindingModel
+ {
+ 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/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs
new file mode 100644
index 0000000..0627eda
--- /dev/null
+++ b/SushiBar/SushiBar/Program.cs
@@ -0,0 +1,54 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using SushiBar.Forms;
+using SushiBarBusinessLogic.BusinessLogics;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.StoragesContracts;
+using SushiBarListImplement.Implements;
+
+namespace SushiBar
+{
+ 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();
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/SushiBar.csproj b/SushiBar/SushiBar/SushiBar.csproj
new file mode 100644
index 0000000..dfe9d68
--- /dev/null
+++ b/SushiBar/SushiBar/SushiBar.csproj
@@ -0,0 +1,40 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ Always
+
+
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/nlog.config b/SushiBar/SushiBar/nlog.config
new file mode 100644
index 0000000..aad59db
--- /dev/null
+++ b/SushiBar/SushiBar/nlog.config
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/ComponentLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/ComponentLogic.cs
new file mode 100644
index 0000000..f5ad6bb
--- /dev/null
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/ComponentLogic.cs
@@ -0,0 +1,109 @@
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace SushiBarBusinessLogic.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/SushiBar/SushiBarBusinessLogic/BusinessLogics/OrderLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/OrderLogic.cs
new file mode 100644
index 0000000..4d66099
--- /dev/null
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -0,0 +1,128 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Enums;
+
+namespace SushiBarBusinessLogic.BusinessLogics
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Id:{ 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;
+ }
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != OrderStatus.Неизвестен)
+ {
+ _logger.LogWarning("Wrong Order Status");
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ model.Status = OrderStatus.Принят;
+ if (_orderStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return ToNextStatus(model, OrderStatus.Выполняется);
+ }
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return ToNextStatus(model, OrderStatus.Выдан);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return ToNextStatus(model, OrderStatus.Готов);
+ }
+
+ public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus)
+ {
+ CheckModel(model, false);
+ var element = _orderStorage.GetElement(new OrderSearchModel()
+ {
+ Id = model.Id
+ });
+ if (element == null)
+ {
+ throw new ArgumentNullException(nameof(element));
+ }
+
+ model.SushiId = element.SushiId;
+ model.DateCreate = element.DateCreate;
+ model.DateImplement = element.DateImplement;
+ model.Status = element.Status;
+ model.Count = element.Count;
+ model.Sum = element.Sum;
+
+ if (model.Status != orderStatus - 1)
+ {
+ _logger.LogWarning("Status update to " + orderStatus + " operation failed");
+ return false;
+ }
+ model.Status = orderStatus;
+
+ if (model.Status == OrderStatus.Выдан)
+ {
+ model.DateImplement = DateTime.Now;
+ }
+
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status--;
+ _logger.LogWarning("Changing status operation faled");
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (model.DateImplement != null && model.DateCreate > model.DateImplement)
+ {
+ throw new InvalidOperationException("Заказ не может быть начат после его завершения");
+ }
+ if (model.Count <= 0)
+ {
+ throw new ArgumentException("Количество продукта должно быть бльше 0");
+ }
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentException("Сумма заказа должна быть больше 0", nameof(model.Sum));
+ }
+ }
+ }
+}
diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/SushiLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/SushiLogic.cs
new file mode 100644
index 0000000..0a1fa92
--- /dev/null
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/SushiLogic.cs
@@ -0,0 +1,106 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBarBusinessLogic.BusinessLogics
+{
+ public class SushiLogic : ISushiLogic
+ {
+ private readonly ILogger _logger;
+ private readonly ISushiStorage _sushiStorage;
+ public SushiLogic(ILogger logger, ISushiStorage sushiStorage)
+ {
+ _logger = logger;
+ _sushiStorage = sushiStorage;
+ }
+ public List? ReadList(SushiSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. SushiName:{SushiName}. Id:{ Id}", model?.SushiName, model?.Id);
+ var list = model == null ? _sushiStorage.GetFullList() :
+ _sushiStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public SushiViewModel? ReadElement(SushiSearchModel model)
+ {
+ if(model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. SushiName:{SushiName}. Id:{ Id}", model.SushiName, model.Id);
+ var element = _sushiStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ return element;
+ }
+ public bool Create(SushiBindingModel model)
+ {
+ CheckModel(model);
+ if (_sushiStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(SushiBindingModel model)
+ {
+ CheckModel(model);
+ if (_sushiStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(SushiBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_sushiStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(SushiBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.SushiName))
+ {
+ throw new ArgumentException("Нет названия продукта", nameof(model.SushiName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
+ }
+ var element = _sushiStorage.GetElement(new SushiSearchModel
+ {
+ SushiName = model.SushiName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Продукт с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj b/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj
new file mode 100644
index 0000000..e944f4d
--- /dev/null
+++ b/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj
@@ -0,0 +1,20 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..3df23d5
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,11 @@
+using SushiBarDataModels.Models;
+
+namespace SushiBarContracts.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/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..04c26e9
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,16 @@
+using SushiBarDataModels.Enums;
+using SushiBarDataModels.Models;
+
+namespace SushiBarContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int SushiId { 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/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs
new file mode 100644
index 0000000..2e10f06
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs
@@ -0,0 +1,16 @@
+using SushiBarDataModels.Models;
+
+namespace SushiBarContracts.BindingModels
+{
+ public class SushiBindingModel : ISushiModel
+ {
+ public int Id { get; set; }
+ public string SushiName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary SushiComponents
+ {
+ get;
+ set;
+ } = new();
+ }
+}
diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..d75c9f1
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,16 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBarContracts.BusinessLogicsContracts
+{
+ public interface IComponentLogic
+ {
+ List? ReadList(ComponentSearchModel? model);
+ ComponentViewModel? ReadElement(ComponentSearchModel model);
+ bool Create(ComponentBindingModel model);
+ bool Update(ComponentBindingModel model);
+ bool Delete(ComponentBindingModel model);
+
+ }
+}
diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..be0cb58
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,15 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBarContracts.BusinessLogicsContracts
+{
+ public interface IOrderLogic
+ {
+ List? ReadList(OrderSearchModel? model);
+ bool CreateOrder(OrderBindingModel model);
+ bool TakeOrderInWork(OrderBindingModel model);
+ bool FinishOrder(OrderBindingModel model);
+ bool DeliveryOrder(OrderBindingModel model);
+ }
+}
diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
new file mode 100644
index 0000000..ae5cbbb
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
@@ -0,0 +1,15 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBarContracts.BusinessLogicsContracts
+{
+ public interface ISushiLogic
+ {
+ List? ReadList(SushiSearchModel? model);
+ SushiViewModel? ReadElement(SushiSearchModel model);
+ bool Create(SushiBindingModel model);
+ bool Update(SushiBindingModel model);
+ bool Delete(SushiBindingModel model);
+ }
+}
diff --git a/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..3e9c31b
--- /dev/null
+++ b/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,8 @@
+namespace SushiBarContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+}
diff --git a/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..becbcd5
--- /dev/null
+++ b/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,7 @@
+namespace SushiBarContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs
new file mode 100644
index 0000000..55e424e
--- /dev/null
+++ b/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs
@@ -0,0 +1,8 @@
+namespace SushiBarContracts.SearchModels
+{
+ public class SushiSearchModel
+ {
+ public int? Id { get; set; }
+ public string? SushiName { get; set; }
+ }
+}
diff --git a/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..2f18178
--- /dev/null
+++ b/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,16 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBarContracts.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/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..f337dbf
--- /dev/null
+++ b/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,16 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBarContracts.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/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs
new file mode 100644
index 0000000..ff49391
--- /dev/null
+++ b/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs
@@ -0,0 +1,16 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBarContracts.StoragesContracts
+{
+ public interface ISushiStorage
+ {
+ List GetFullList();
+ List GetFilteredList(SushiSearchModel model);
+ SushiViewModel? GetElement(SushiSearchModel model);
+ SushiViewModel? Insert(SushiBindingModel model);
+ SushiViewModel? Update(SushiBindingModel model);
+ SushiViewModel? Delete(SushiBindingModel model);
+ }
+}
diff --git a/SushiBar/SushiBarContracts/SushiBarContracts.csproj b/SushiBar/SushiBarContracts/SushiBarContracts.csproj
new file mode 100644
index 0000000..ef52534
--- /dev/null
+++ b/SushiBar/SushiBarContracts/SushiBarContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..f879afc
--- /dev/null
+++ b/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,14 @@
+using SushiBarDataModels.Models;
+using System.ComponentModel;
+
+namespace SushiBarContracts.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/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..0d9b086
--- /dev/null
+++ b/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,25 @@
+using SushiBarDataModels.Enums;
+using SushiBarDataModels.Models;
+using System.ComponentModel;
+
+namespace SushiBarContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+ public int SushiId { get; set; }
+ [DisplayName("Суши")]
+ public string SushiName { 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/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs
new file mode 100644
index 0000000..73b3ae8
--- /dev/null
+++ b/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs
@@ -0,0 +1,20 @@
+using SushiBarDataModels.Models;
+using System.ComponentModel;
+
+namespace SushiBarContracts.ViewModels
+{
+ public class SushiViewModel : ISushiModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название суши")]
+ public string SushiName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary SushiComponents
+ {
+ get;
+ set;
+ } = new();
+
+ }
+}
diff --git a/SushiBar/SushiBarDataModels/Enums/OrderStatus.cs b/SushiBar/SushiBarDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..64556e2
--- /dev/null
+++ b/SushiBar/SushiBarDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,11 @@
+namespace SushiBarDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/SushiBar/SushiBarDataModels/IId.cs b/SushiBar/SushiBarDataModels/IId.cs
new file mode 100644
index 0000000..2b4af59
--- /dev/null
+++ b/SushiBar/SushiBarDataModels/IId.cs
@@ -0,0 +1,7 @@
+namespace SushiBarDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/SushiBar/SushiBarDataModels/Models/IComponentModel.cs b/SushiBar/SushiBarDataModels/Models/IComponentModel.cs
new file mode 100644
index 0000000..93c68db
--- /dev/null
+++ b/SushiBar/SushiBarDataModels/Models/IComponentModel.cs
@@ -0,0 +1,8 @@
+namespace SushiBarDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/SushiBar/SushiBarDataModels/Models/IOrderModel.cs b/SushiBar/SushiBarDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..3770e12
--- /dev/null
+++ b/SushiBar/SushiBarDataModels/Models/IOrderModel.cs
@@ -0,0 +1,14 @@
+using SushiBarDataModels.Enums;
+
+namespace SushiBarDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int SushiId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/SushiBar/SushiBarDataModels/Models/ISushiModel.cs b/SushiBar/SushiBarDataModels/Models/ISushiModel.cs
new file mode 100644
index 0000000..d7257ad
--- /dev/null
+++ b/SushiBar/SushiBarDataModels/Models/ISushiModel.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+namespace SushiBarDataModels.Models
+{
+ public interface ISushiModel : IId
+ {
+ string SushiName { get; }
+ double Price { get; }
+ Dictionary SushiComponents { get; }
+ }
+}
diff --git a/SushiBar/SushiBarDataModels/SushiBarDataModels.csproj b/SushiBar/SushiBarDataModels/SushiBarDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/SushiBar/SushiBarDataModels/SushiBarDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/SushiBar/SushiBarListImplement/DataListSingleton.cs b/SushiBar/SushiBarListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..3df79fa
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/DataListSingleton.cs
@@ -0,0 +1,27 @@
+using SushiBarListImplement.Models;
+
+namespace SushiBarListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Sushis { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Sushis = new List();
+ }
+
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarListImplement/Implements/ComponentStorage.cs b/SushiBar/SushiBarListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..1fea2c0
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,102 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarListImplement.Models;
+
+namespace SushiBarListImplement.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/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..29483f7
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,112 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarListImplement.Models;
+
+namespace SushiBarListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var order in _source.Orders)
+ {
+ result.Add(AttachSushiName(order.GetViewModel));
+ }
+ return result;
+ }
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+ if (model == null || !model.Id.HasValue)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ result.Add(AttachSushiName(order.GetViewModel));
+ }
+ }
+ return result;
+ }
+ 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 AttachSushiName(order.GetViewModel);
+ }
+ }
+ return null;
+ }
+ 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 AttachSushiName(newOrder.GetViewModel);
+ }
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return AttachSushiName(order.GetViewModel);
+ }
+ }
+ return null;
+ }
+ 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 AttachSushiName(element.GetViewModel);
+ }
+ }
+ return null;
+ }
+ private OrderViewModel AttachSushiName(OrderViewModel model)
+ {
+ foreach (var sushi in _source.Sushis)
+ {
+ if (sushi.Id == model.SushiId)
+ {
+ model.SushiName = sushi.SushiName;
+ return model;
+ }
+ }
+ return model;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarListImplement/Implements/SushiStorage.cs b/SushiBar/SushiBarListImplement/Implements/SushiStorage.cs
new file mode 100644
index 0000000..4e2454f
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/Implements/SushiStorage.cs
@@ -0,0 +1,102 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarListImplement.Models;
+
+namespace SushiBarListImplement.Implements
+{
+ public class SushiStorage : ISushiStorage
+ {
+ private readonly DataListSingleton _source;
+ public SushiStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var sushi in _source.Sushis)
+ {
+ result.Add(sushi.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(SushiSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.SushiName))
+ {
+ return result;
+ }
+ foreach (var sushi in _source.Sushis)
+ {
+ if (sushi.SushiName.Contains(model.SushiName))
+ {
+ result.Add(sushi.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public SushiViewModel? GetElement(SushiSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.SushiName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var sushi in _source.Sushis)
+ {
+ if ((!string.IsNullOrEmpty(model.SushiName) &&
+ sushi.SushiName == model.SushiName) ||
+ (model.Id.HasValue && sushi.Id == model.Id))
+ {
+ return sushi.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public SushiViewModel? Insert(SushiBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var sushi in _source.Sushis)
+ {
+ if (model.Id <= sushi.Id)
+ {
+ model.Id = sushi.Id + 1;
+ }
+ }
+ var newSushi = Sushi.Create(model);
+ if (newSushi == null)
+ {
+ return null;
+ }
+ _source.Sushis.Add(newSushi);
+ return newSushi.GetViewModel;
+ }
+ public SushiViewModel? Update(SushiBindingModel model)
+ {
+ foreach (var sushi in _source.Sushis)
+ {
+ if (sushi.Id == model.Id)
+ {
+ sushi.Update(model);
+ return sushi.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public SushiViewModel? Delete(SushiBindingModel model)
+ {
+ for (int i = 0; i < _source.Sushis.Count; ++i)
+ {
+ if (_source.Sushis[i].Id == model.Id)
+ {
+ var element = _source.Sushis[i];
+ _source.Sushis.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarListImplement/Models/Component.cs b/SushiBar/SushiBarListImplement/Models/Component.cs
new file mode 100644
index 0000000..b220453
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/Models/Component.cs
@@ -0,0 +1,41 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+
+namespace SushiBarListImplement.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/SushiBar/SushiBarListImplement/Models/Order.cs b/SushiBar/SushiBarListImplement/Models/Order.cs
new file mode 100644
index 0000000..5897bf7
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/Models/Order.cs
@@ -0,0 +1,61 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Enums;
+using SushiBarDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+ public int SushiId { 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; }
+ public DateTime? DateImplement { get; private set; }
+ public static Order? Create(OrderBindingModel? model) {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ SushiId = model.SushiId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement
+ };
+ }
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ SushiId = model.SushiId;
+ Count = model.Count;
+ Sum = model.Sum;
+ Status = model.Status;
+ DateImplement = model.DateImplement;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ SushiId = SushiId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+ }
+}
diff --git a/SushiBar/SushiBarListImplement/Models/Sushi.cs b/SushiBar/SushiBarListImplement/Models/Sushi.cs
new file mode 100644
index 0000000..a3656cd
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/Models/Sushi.cs
@@ -0,0 +1,54 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SushiBarListImplement.Models
+{
+ public class Sushi : ISushiModel
+ {
+ public int Id { get; private set; }
+ public string SushiName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary SushiComponents
+ {
+ get;
+ private set;
+ } = new Dictionary();
+ public static Sushi? Create(SushiBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Sushi()
+ {
+ Id = model.Id,
+ SushiName = model.SushiName,
+ Price = model.Price,
+ SushiComponents = model.SushiComponents
+ };
+ }
+ public void Update(SushiBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ SushiName = model.SushiName;
+ Price = model.Price;
+ SushiComponents = model.SushiComponents;
+ }
+ public SushiViewModel GetViewModel => new()
+ {
+ Id = Id,
+ SushiName = SushiName,
+ Price = Price,
+ SushiComponents = SushiComponents
+ };
+ }
+}
diff --git a/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj b/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj
new file mode 100644
index 0000000..00e2c96
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+