From 1d152b69d9850f13de8775e79122a1cf3b0bd756 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?=
=?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com>
Date: Fri, 15 Mar 2024 19:52:21 +0400
Subject: [PATCH] Vrode sdelal
---
.../SushiBar/FormCreateSupply.Designer.cs | 143 +++++++++++
SushiBar/SushiBar/FormCreateSupply.cs | 89 +++++++
SushiBar/SushiBar/FormCreateSupply.resx | 120 +++++++++
SushiBar/SushiBar/FormMain.Designer.cs | 229 ++++++++++--------
SushiBar/SushiBar/FormMain.cs | 23 +-
SushiBar/SushiBar/FormMain.resx | 62 ++++-
SushiBar/SushiBar/FormShop.Designer.cs | 188 ++++++++++++++
SushiBar/SushiBar/FormShop.cs | 120 +++++++++
SushiBar/SushiBar/FormShop.resx | 69 ++++++
SushiBar/SushiBar/FormShops.Designer.cs | 122 ++++++++++
SushiBar/SushiBar/FormShops.cs | 102 ++++++++
SushiBar/SushiBar/FormShops.resx | 60 +++++
SushiBar/SushiBar/Program.cs | 8 +
SushiBar/SushiBar/SushiBarView.csproj | 1 +
.../BusinessLogics/ShopLogic.cs | 149 ++++++++++++
.../BindingModels/ShopBindingModel.cs | 20 ++
.../BindingModels/SupplyBindingModel.cs | 11 +
.../BusinessLogicsContracts/IShopLogic.cs | 18 ++
.../BusinessLogicsContracts/ISushiLogic.cs | 3 +-
.../SearchModels/ShopSearchModel.cs | 8 +
.../StoragesContracts/IShopStorage.cs | 16 ++
.../ViewModels/ShopViewModel.cs | 24 ++
.../SushiBarDataModels/Models/IShopModel.cs | 10 +
.../SushiBarDataModels/Models/ISupplyModel.cs | 15 ++
.../DataListSingleton.cs | 3 +
.../Implements/ShopStorage.cs | 102 ++++++++
SushiBar/SushiBarListImplement/Models/Shop.cs | 53 ++++
27 files changed, 1661 insertions(+), 107 deletions(-)
create mode 100644 SushiBar/SushiBar/FormCreateSupply.Designer.cs
create mode 100644 SushiBar/SushiBar/FormCreateSupply.cs
create mode 100644 SushiBar/SushiBar/FormCreateSupply.resx
create mode 100644 SushiBar/SushiBar/FormShop.Designer.cs
create mode 100644 SushiBar/SushiBar/FormShop.cs
create mode 100644 SushiBar/SushiBar/FormShop.resx
create mode 100644 SushiBar/SushiBar/FormShops.Designer.cs
create mode 100644 SushiBar/SushiBar/FormShops.cs
create mode 100644 SushiBar/SushiBar/FormShops.resx
create mode 100644 SushiBar/SushiBarBusinessLogic/BusinessLogics/ShopLogic.cs
create mode 100644 SushiBar/SushiBarContracts/BindingModels/ShopBindingModel.cs
create mode 100644 SushiBar/SushiBarContracts/BindingModels/SupplyBindingModel.cs
create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/IShopLogic.cs
create mode 100644 SushiBar/SushiBarContracts/SearchModels/ShopSearchModel.cs
create mode 100644 SushiBar/SushiBarContracts/StoragesContracts/IShopStorage.cs
create mode 100644 SushiBar/SushiBarContracts/ViewModels/ShopViewModel.cs
create mode 100644 SushiBar/SushiBarDataModels/Models/IShopModel.cs
create mode 100644 SushiBar/SushiBarDataModels/Models/ISupplyModel.cs
create mode 100644 SushiBar/SushiBarListImplement/Implements/ShopStorage.cs
create mode 100644 SushiBar/SushiBarListImplement/Models/Shop.cs
diff --git a/SushiBar/SushiBar/FormCreateSupply.Designer.cs b/SushiBar/SushiBar/FormCreateSupply.Designer.cs
new file mode 100644
index 0000000..df6ca87
--- /dev/null
+++ b/SushiBar/SushiBar/FormCreateSupply.Designer.cs
@@ -0,0 +1,143 @@
+namespace PizzeriaView
+{
+ partial class FormCreateSupply
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.comboBoxShop = new System.Windows.Forms.ComboBox();
+ this.labelShop = new System.Windows.Forms.Label();
+ this.labelPizza = new System.Windows.Forms.Label();
+ this.comboBoxSushi = new System.Windows.Forms.ComboBox();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // comboBoxShop
+ //
+ this.comboBoxShop.FormattingEnabled = true;
+ this.comboBoxShop.Location = new System.Drawing.Point(115, 12);
+ this.comboBoxShop.Name = "comboBoxShop";
+ this.comboBoxShop.Size = new System.Drawing.Size(344, 28);
+ this.comboBoxShop.TabIndex = 0;
+ //
+ // labelShop
+ //
+ this.labelShop.AutoSize = true;
+ this.labelShop.Location = new System.Drawing.Point(12, 15);
+ this.labelShop.Name = "labelShop";
+ this.labelShop.Size = new System.Drawing.Size(76, 20);
+ this.labelShop.TabIndex = 1;
+ this.labelShop.Text = "Магазин: ";
+ //
+ // labelPizza
+ //
+ this.labelPizza.AutoSize = true;
+ this.labelPizza.Location = new System.Drawing.Point(12, 49);
+ this.labelPizza.Name = "labelPizza";
+ this.labelPizza.Size = new System.Drawing.Size(75, 20);
+ this.labelPizza.TabIndex = 2;
+ this.labelPizza.Text = "Изделие: ";
+ //
+ // comboBoxPizza
+ //
+ this.comboBoxSushi.FormattingEnabled = true;
+ this.comboBoxSushi.Location = new System.Drawing.Point(115, 46);
+ this.comboBoxSushi.Name = "comboBoxPizza";
+ this.comboBoxSushi.Size = new System.Drawing.Size(344, 28);
+ this.comboBoxSushi.TabIndex = 3;
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(12, 83);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(97, 20);
+ this.labelCount.TabIndex = 4;
+ this.labelCount.Text = "Количество: ";
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(115, 80);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(344, 27);
+ this.textBoxCount.TabIndex = 5;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(300, 113);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(116, 39);
+ this.buttonCancel.TabIndex = 6;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(168, 113);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(116, 39);
+ this.buttonSave.TabIndex = 7;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // FormCreateSupply
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(471, 164);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.comboBoxSushi);
+ this.Controls.Add(this.labelPizza);
+ this.Controls.Add(this.labelShop);
+ this.Controls.Add(this.comboBoxShop);
+ this.Name = "FormCreateSupply";
+ this.Text = "Создание поставки";
+ this.Load += new System.EventHandler(this.FormCreateSupply_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private ComboBox comboBoxShop;
+ private Label labelShop;
+ private Label labelPizza;
+ private ComboBox comboBoxSushi;
+ private Label labelCount;
+ private TextBox textBoxCount;
+ private Button buttonCancel;
+ private Button buttonSave;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormCreateSupply.cs b/SushiBar/SushiBar/FormCreateSupply.cs
new file mode 100644
index 0000000..7aa4e7a
--- /dev/null
+++ b/SushiBar/SushiBar/FormCreateSupply.cs
@@ -0,0 +1,89 @@
+using Microsoft.Extensions.Logging;
+using PizzeriaContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.ViewModels;
+
+
+namespace PizzeriaView
+{
+ public partial class FormCreateSupply : Form
+ {
+ private readonly ILogger _logger;
+ private readonly ISushiLogic _logicS;
+ private readonly IShopLogic _logicSh;
+ private List _ShopList = new List();
+ private List _SushiList = new List();
+
+ public FormCreateSupply(ILogger logger, ISushiLogic logicS, IShopLogic logicSh)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicS = logicS;
+ _logicSh = logicSh;
+ }
+
+ private void FormCreateSupply_Load(object sender, EventArgs e)
+ {
+ _ShopList = _logicSh.ReadList(null);
+ _SushiList = _logicS.ReadList(null);
+ if (_ShopList != null)
+ {
+ comboBoxShop.DisplayMember = "ShopName";
+ comboBoxShop.ValueMember = "Id";
+ comboBoxShop.DataSource = _ShopList;
+ comboBoxShop.SelectedItem = null;
+ _logger.LogInformation("Загрузка магазинов для поставок");
+ }
+ if (_SushiList != null)
+ {
+ comboBoxSushi.DisplayMember = "SushiName";
+ comboBoxSushi.ValueMember = "Id";
+ comboBoxSushi.DataSource = _SushiList;
+ comboBoxSushi.SelectedItem = null;
+ _logger.LogInformation("Загрузка суши для поставок");
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (comboBoxShop.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxSushi.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание поставки");
+ try
+ {
+ var operationResult = _logicSh.MakeSupply(new SupplyBindingModel
+ {
+ ShopId = Convert.ToInt32(comboBoxShop.SelectedValue),
+ SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue),
+ Count = Convert.ToInt32(textBoxCount.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/FormCreateSupply.resx b/SushiBar/SushiBar/FormCreateSupply.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/SushiBar/SushiBar/FormCreateSupply.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/FormMain.Designer.cs b/SushiBar/SushiBar/FormMain.Designer.cs
index cad392a..fd3b467 100644
--- a/SushiBar/SushiBar/FormMain.Designer.cs
+++ b/SushiBar/SushiBar/FormMain.Designer.cs
@@ -28,142 +28,162 @@
///
private void InitializeComponent()
{
- this.menuStrip = new System.Windows.Forms.MenuStrip();
- this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.ингредиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.сушиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.buttonUpdate = new System.Windows.Forms.Button();
- this.buttonSetToFinish = new System.Windows.Forms.Button();
- this.buttonSetToDone = new System.Windows.Forms.Button();
- this.buttonSetToWork = new System.Windows.Forms.Button();
- this.buttonCreateOrder = new System.Windows.Forms.Button();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- this.menuStrip.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
+ menuStrip = new MenuStrip();
+ справочникиToolStripMenuItem = new ToolStripMenuItem();
+ ингредиентыToolStripMenuItem = new ToolStripMenuItem();
+ сушиToolStripMenuItem = new ToolStripMenuItem();
+ ShopsToolStripMenuItem = new ToolStripMenuItem();
+ поставкаToolStripMenuItem = new ToolStripMenuItem();
+ buttonUpdate = new Button();
+ buttonSetToFinish = new Button();
+ buttonSetToDone = new Button();
+ buttonSetToWork = new Button();
+ buttonCreateOrder = new Button();
+ dataGridView = new DataGridView();
+ transactionToolStripMenuItem1 = new ToolStripMenuItem();
+ menuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
//
// menuStrip
//
- this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.справочникиToolStripMenuItem});
- this.menuStrip.Location = new System.Drawing.Point(0, 0);
- this.menuStrip.Name = "menuStrip";
- this.menuStrip.Size = new System.Drawing.Size(975, 24);
- this.menuStrip.TabIndex = 0;
- this.menuStrip.Text = "menuStrip1";
+ menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, поставкаToolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Size = new Size(975, 24);
+ menuStrip.TabIndex = 0;
+ menuStrip.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
- this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.ингредиентыToolStripMenuItem,
- this.сушиToolStripMenuItem});
- this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
- this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
- this.справочникиToolStripMenuItem.Text = "Справочники";
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ингредиентыToolStripMenuItem, сушиToolStripMenuItem, ShopsToolStripMenuItem });
+ справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
+ справочникиToolStripMenuItem.Size = new Size(94, 20);
+ справочникиToolStripMenuItem.Text = "Справочники";
//
// ингредиентыToolStripMenuItem
//
- this.ингредиентыToolStripMenuItem.Name = "ингредиентыToolStripMenuItem";
- this.ингредиентыToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
- this.ингредиентыToolStripMenuItem.Text = "Ингредиенты";
- this.ингредиентыToolStripMenuItem.Click += new System.EventHandler(this.IngredientsToolStripMenuItem_Click);
+ ингредиентыToolStripMenuItem.Name = "ингредиентыToolStripMenuItem";
+ ингредиентыToolStripMenuItem.Size = new Size(148, 22);
+ ингредиентыToolStripMenuItem.Text = "Ингредиенты";
+ ингредиентыToolStripMenuItem.Click += IngredientsToolStripMenuItem_Click;
//
// сушиToolStripMenuItem
//
- this.сушиToolStripMenuItem.Name = "сушиToolStripMenuItem";
- this.сушиToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
- this.сушиToolStripMenuItem.Text = "Суши";
- this.сушиToolStripMenuItem.Click += new System.EventHandler(this.SushiToolStripMenuItem_Click);
+ сушиToolStripMenuItem.Name = "сушиToolStripMenuItem";
+ сушиToolStripMenuItem.Size = new Size(148, 22);
+ сушиToolStripMenuItem.Text = "Суши";
+ сушиToolStripMenuItem.Click += SushiToolStripMenuItem_Click;
+ //
+ // ShopsToolStripMenuItem
+ //
+ ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
+ ShopsToolStripMenuItem.Size = new Size(148, 22);
+ ShopsToolStripMenuItem.Text = "Магазины";
+ ShopsToolStripMenuItem.Click += shopsToolStripMenuItem_Click;
+ //
+ // поставкаToolStripMenuItem
+ //
+ поставкаToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transactionToolStripMenuItem1 });
+ поставкаToolStripMenuItem.Name = "поставкаToolStripMenuItem";
+ поставкаToolStripMenuItem.Size = new Size(75, 20);
+ поставкаToolStripMenuItem.Text = "Операции";
//
// buttonUpdate
//
- this.buttonUpdate.Location = new System.Drawing.Point(780, 314);
- this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.buttonUpdate.Name = "buttonUpdate";
- this.buttonUpdate.Size = new System.Drawing.Size(170, 58);
- this.buttonUpdate.TabIndex = 12;
- this.buttonUpdate.Text = "Обновить";
- this.buttonUpdate.UseVisualStyleBackColor = true;
- this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
+ buttonUpdate.Location = new Point(780, 314);
+ buttonUpdate.Margin = new Padding(3, 2, 3, 2);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(170, 58);
+ buttonUpdate.TabIndex = 12;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonRef_Click;
//
// buttonSetToFinish
//
- this.buttonSetToFinish.Location = new System.Drawing.Point(780, 252);
- this.buttonSetToFinish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.buttonSetToFinish.Name = "buttonSetToFinish";
- this.buttonSetToFinish.Size = new System.Drawing.Size(170, 58);
- this.buttonSetToFinish.TabIndex = 11;
- this.buttonSetToFinish.Text = "Заказ выдан";
- this.buttonSetToFinish.UseVisualStyleBackColor = true;
- this.buttonSetToFinish.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
+ buttonSetToFinish.Location = new Point(780, 252);
+ buttonSetToFinish.Margin = new Padding(3, 2, 3, 2);
+ buttonSetToFinish.Name = "buttonSetToFinish";
+ buttonSetToFinish.Size = new Size(170, 58);
+ buttonSetToFinish.TabIndex = 11;
+ buttonSetToFinish.Text = "Заказ выдан";
+ buttonSetToFinish.UseVisualStyleBackColor = true;
+ buttonSetToFinish.Click += ButtonIssuedOrder_Click;
//
// buttonSetToDone
//
- this.buttonSetToDone.Location = new System.Drawing.Point(780, 190);
- this.buttonSetToDone.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.buttonSetToDone.Name = "buttonSetToDone";
- this.buttonSetToDone.Size = new System.Drawing.Size(170, 58);
- this.buttonSetToDone.TabIndex = 10;
- this.buttonSetToDone.Text = "Заказ готов";
- this.buttonSetToDone.UseVisualStyleBackColor = true;
- this.buttonSetToDone.Click += new System.EventHandler(this.ButtonOrderReady_Click);
+ buttonSetToDone.Location = new Point(780, 190);
+ buttonSetToDone.Margin = new Padding(3, 2, 3, 2);
+ buttonSetToDone.Name = "buttonSetToDone";
+ buttonSetToDone.Size = new Size(170, 58);
+ buttonSetToDone.TabIndex = 10;
+ buttonSetToDone.Text = "Заказ готов";
+ buttonSetToDone.UseVisualStyleBackColor = true;
+ buttonSetToDone.Click += ButtonOrderReady_Click;
//
// buttonSetToWork
//
- this.buttonSetToWork.Location = new System.Drawing.Point(780, 128);
- this.buttonSetToWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.buttonSetToWork.Name = "buttonSetToWork";
- this.buttonSetToWork.Size = new System.Drawing.Size(170, 58);
- this.buttonSetToWork.TabIndex = 9;
- this.buttonSetToWork.Text = "Отдать на выполнение";
- this.buttonSetToWork.UseVisualStyleBackColor = true;
- this.buttonSetToWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
+ buttonSetToWork.Location = new Point(780, 128);
+ buttonSetToWork.Margin = new Padding(3, 2, 3, 2);
+ buttonSetToWork.Name = "buttonSetToWork";
+ buttonSetToWork.Size = new Size(170, 58);
+ buttonSetToWork.TabIndex = 9;
+ buttonSetToWork.Text = "Отдать на выполнение";
+ buttonSetToWork.UseVisualStyleBackColor = true;
+ buttonSetToWork.Click += ButtonTakeOrderInWork_Click;
//
// buttonCreateOrder
//
- this.buttonCreateOrder.Location = new System.Drawing.Point(780, 66);
- this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.buttonCreateOrder.Name = "buttonCreateOrder";
- this.buttonCreateOrder.Size = new System.Drawing.Size(170, 58);
- this.buttonCreateOrder.TabIndex = 8;
- this.buttonCreateOrder.Text = "Создать заказ";
- this.buttonCreateOrder.UseVisualStyleBackColor = true;
- this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
+ buttonCreateOrder.Location = new Point(780, 66);
+ buttonCreateOrder.Margin = new Padding(3, 2, 3, 2);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(170, 58);
+ buttonCreateOrder.TabIndex = 8;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += ButtonCreateOrder_Click;
//
// dataGridView
//
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
- this.dataGridView.Location = new System.Drawing.Point(0, 24);
- this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowHeadersWidth = 51;
- this.dataGridView.RowTemplate.Height = 29;
- this.dataGridView.Size = new System.Drawing.Size(755, 426);
- this.dataGridView.TabIndex = 7;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Left;
+ dataGridView.Location = new Point(0, 24);
+ dataGridView.Margin = new Padding(3, 2, 3, 2);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(755, 426);
+ dataGridView.TabIndex = 7;
+ //
+ // transactionToolStripMenuItem1
+ //
+ transactionToolStripMenuItem1.Name = "transactionToolStripMenuItem1";
+ transactionToolStripMenuItem1.Size = new Size(180, 22);
+ transactionToolStripMenuItem1.Text = "Поставка";
+ transactionToolStripMenuItem1.Click += transactionToolStripMenuItem1_Click;
//
// FormMain
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(975, 450);
- this.Controls.Add(this.buttonUpdate);
- this.Controls.Add(this.buttonSetToFinish);
- this.Controls.Add(this.buttonSetToDone);
- this.Controls.Add(this.buttonSetToWork);
- this.Controls.Add(this.buttonCreateOrder);
- this.Controls.Add(this.dataGridView);
- this.Controls.Add(this.menuStrip);
- this.MainMenuStrip = this.menuStrip;
- this.Name = "FormMain";
- this.Text = "Суши-бар";
- this.Load += new System.EventHandler(this.FormMain_Load);
- this.menuStrip.ResumeLayout(false);
- this.menuStrip.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
-
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(975, 450);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonSetToFinish);
+ Controls.Add(buttonSetToDone);
+ Controls.Add(buttonSetToWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
+ Name = "FormMain";
+ Text = "Суши-бар";
+ Load += FormMain_Load;
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -178,5 +198,8 @@
private Button buttonSetToWork;
private Button buttonCreateOrder;
private DataGridView dataGridView;
+ private ToolStripMenuItem ShopsToolStripMenuItem;
+ private ToolStripMenuItem поставкаToolStripMenuItem;
+ private ToolStripMenuItem transactionToolStripMenuItem1;
}
}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormMain.cs b/SushiBar/SushiBar/FormMain.cs
index 6255276..86b9cc0 100644
--- a/SushiBar/SushiBar/FormMain.cs
+++ b/SushiBar/SushiBar/FormMain.cs
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
+using PizzeriaView;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarDataModels.Enums;
@@ -71,7 +72,7 @@ namespace SushiBarView
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
- var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
{
Id = id
});
@@ -96,7 +97,7 @@ namespace SushiBarView
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try
{
- var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{
Id = id
});
@@ -143,5 +144,23 @@ namespace SushiBarView
{
LoadData();
}
+
+ private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormShops));
+ if (service is FormShops form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void transactionToolStripMenuItem1_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply));
+ if (service is FormCreateSupply form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormMain.resx b/SushiBar/SushiBar/FormMain.resx
index 81a9e3d..6c82d08 100644
--- a/SushiBar/SushiBar/FormMain.resx
+++ b/SushiBar/SushiBar/FormMain.resx
@@ -1,4 +1,64 @@
-
+
+
+
diff --git a/SushiBar/SushiBar/FormShop.Designer.cs b/SushiBar/SushiBar/FormShop.Designer.cs
new file mode 100644
index 0000000..71971de
--- /dev/null
+++ b/SushiBar/SushiBar/FormShop.Designer.cs
@@ -0,0 +1,188 @@
+namespace SushiBarView
+{
+ partial class FormShop
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.textBoxAddress = new System.Windows.Forms.TextBox();
+ this.labelTime = new System.Windows.Forms.Label();
+ this.labelAddress = new System.Windows.Forms.Label();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.labelShop = new System.Windows.Forms.Label();
+ this.textBoxShop = new System.Windows.Forms.TextBox();
+ this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
+ this.ColumnID = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnSushiName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonSave
+ //
+ this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonSave.Location = new System.Drawing.Point(364, 303);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(120, 22);
+ this.buttonSave.TabIndex = 17;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonCancel.Location = new System.Drawing.Point(490, 302);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(103, 23);
+ this.buttonCancel.TabIndex = 16;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // textBoxAddress
+ //
+ this.textBoxAddress.Location = new System.Drawing.Point(159, 27);
+ this.textBoxAddress.Name = "textBoxAddress";
+ this.textBoxAddress.Size = new System.Drawing.Size(221, 23);
+ this.textBoxAddress.TabIndex = 14;
+ //
+ // labelTime
+ //
+ this.labelTime.AutoSize = true;
+ this.labelTime.Location = new System.Drawing.Point(386, 9);
+ this.labelTime.Name = "labelTime";
+ this.labelTime.Size = new System.Drawing.Size(87, 15);
+ this.labelTime.TabIndex = 13;
+ this.labelTime.Text = "Дата открытия";
+ //
+ // labelAddress
+ //
+ this.labelAddress.AutoSize = true;
+ this.labelAddress.Location = new System.Drawing.Point(159, 9);
+ this.labelAddress.Name = "labelAddress";
+ this.labelAddress.Size = new System.Drawing.Size(40, 15);
+ this.labelAddress.TabIndex = 12;
+ this.labelAddress.Text = "Адрес";
+ //
+ // dataGridView
+ //
+ this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColumnID,
+ this.ColumnSushiName,
+ this.ColumnCount});
+ this.dataGridView.Location = new System.Drawing.Point(12, 56);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(581, 240);
+ this.dataGridView.TabIndex = 11;
+ //
+ // labelShop
+ //
+ this.labelShop.AutoSize = true;
+ this.labelShop.Location = new System.Drawing.Point(12, 9);
+ this.labelShop.Name = "labelShop";
+ this.labelShop.Size = new System.Drawing.Size(54, 15);
+ this.labelShop.TabIndex = 9;
+ this.labelShop.Text = "Магазин";
+ //
+ // textBoxShop
+ //
+ this.textBoxShop.Location = new System.Drawing.Point(12, 27);
+ this.textBoxShop.Name = "textBoxShop";
+ this.textBoxShop.Size = new System.Drawing.Size(141, 23);
+ this.textBoxShop.TabIndex = 18;
+ //
+ // dateTimePicker
+ //
+ this.dateTimePicker.Location = new System.Drawing.Point(386, 27);
+ this.dateTimePicker.Name = "dateTimePicker";
+ this.dateTimePicker.Size = new System.Drawing.Size(207, 23);
+ this.dateTimePicker.TabIndex = 19;
+ //
+ // ColumnID
+ //
+ this.ColumnID.HeaderText = "ID";
+ this.ColumnID.Name = "ColumnID";
+ this.ColumnID.Visible = false;
+ //
+ // ColumnSushiName
+ //
+ this.ColumnSushiName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.ColumnSushiName.HeaderText = "Суши";
+ this.ColumnSushiName.Name = "ColumnSushiName";
+ //
+ // ColumnCount
+ //
+ this.ColumnCount.HeaderText = "Количество";
+ this.ColumnCount.Name = "ColumnCount";
+ //
+ // FormShop
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(605, 337);
+ this.Controls.Add(this.dateTimePicker);
+ this.Controls.Add(this.textBoxShop);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.textBoxAddress);
+ this.Controls.Add(this.labelTime);
+ this.Controls.Add(this.labelAddress);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.labelShop);
+ this.Name = "FormShop";
+ this.Text = "Магазин";
+ this.Load += new System.EventHandler(this.FormShop_Load);
+ this.Click += new System.EventHandler(this.FormShop_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private TextBox textBoxAddress;
+ private Label labelTime;
+ private Label labelAddress;
+ private DataGridView dataGridView;
+ private Label labelShop;
+ private TextBox textBoxShop;
+ private DateTimePicker dateTimePicker;
+ private DataGridViewTextBoxColumn ColumnID;
+ private DataGridViewTextBoxColumn ColumnSushiName;
+ private DataGridViewTextBoxColumn ColumnCount;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormShop.cs b/SushiBar/SushiBar/FormShop.cs
new file mode 100644
index 0000000..db7e096
--- /dev/null
+++ b/SushiBar/SushiBar/FormShop.cs
@@ -0,0 +1,120 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using SushiBarDataModels.Models;
+
+namespace SushiBarView
+{
+ public partial class FormShop : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IShopLogic _logic;
+ private int? _id;
+ private Dictionary _shopListSushi;
+ public int Id { set { _id = value; } }
+
+ public FormShop(ILogger logger, IShopLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _shopListSushi = new();
+ }
+
+ private void FormShop_Load(object sender, EventArgs e)
+ {
+
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка магазина");
+ try
+ {
+ var view = _logic.ReadElement(new ShopSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxShop.Text = view.ShopName;
+ textBoxAddress.Text = view.Address;
+ dateTimePicker.Text = view.DateOpening.ToString();
+ _shopListSushi = view.ShopSushi ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки магазина");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка суши магазина");
+ try
+ {
+ if (_shopListSushi != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in _shopListSushi)
+ {
+ dataGridView.Rows.Add(new object[] { elem.Key, elem.Value.Item1.SushiName, elem.Value.Item2 });
+ }
+ }
+ }
+ 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(textBoxShop.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(textBoxAddress.Text))
+ {
+ MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение магазина");
+ try
+ {
+ var model = new ShopBindingModel
+ {
+ Id = _id ?? 0,
+ ShopName = textBoxShop.Text,
+ Address = textBoxAddress.Text,
+ DateOpening = dateTimePicker.Value.Date
+ };
+ 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/FormShop.resx b/SushiBar/SushiBar/FormShop.resx
new file mode 100644
index 0000000..aa7de0d
--- /dev/null
+++ b/SushiBar/SushiBar/FormShop.resx
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormShops.Designer.cs b/SushiBar/SushiBar/FormShops.Designer.cs
new file mode 100644
index 0000000..d755d2d
--- /dev/null
+++ b/SushiBar/SushiBar/FormShops.Designer.cs
@@ -0,0 +1,122 @@
+namespace SushiBarView
+{
+ partial class FormShops
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonEdit = new System.Windows.Forms.Button();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
+ this.dataGridView.GridColor = System.Drawing.Color.White;
+ this.dataGridView.Location = new System.Drawing.Point(0, 0);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(426, 333);
+ this.dataGridView.TabIndex = 10;
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(432, 175);
+ this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(130, 22);
+ this.buttonUpdate.TabIndex = 14;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(432, 149);
+ this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(130, 22);
+ this.buttonDelete.TabIndex = 13;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(432, 123);
+ this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(130, 22);
+ this.buttonEdit.TabIndex = 12;
+ this.buttonEdit.Text = "Изменить";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(432, 97);
+ this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(130, 22);
+ this.buttonAdd.TabIndex = 11;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // FormShops
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(566, 333);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonEdit);
+ this.Controls.Add(this.buttonAdd);
+ this.Name = "FormShops";
+ this.Text = "Магазины";
+ this.Load += new System.EventHandler(this.FormShops_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonEdit;
+ private Button buttonAdd;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/FormShops.cs b/SushiBar/SushiBar/FormShops.cs
new file mode 100644
index 0000000..b751449
--- /dev/null
+++ b/SushiBar/SushiBar/FormShops.cs
@@ -0,0 +1,102 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+
+namespace SushiBarView
+{
+ public partial class FormShops : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IShopLogic _logic;
+ public FormShops(ILogger logger, IShopLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormShops_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["ShopSushi"].Visible = false;
+ dataGridView.Columns["ShopName"].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(FormShop));
+ if (service is FormShop 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(FormShop));
+ if (service is FormShop 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 ShopBindingModel
+ {
+ 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/FormShops.resx b/SushiBar/SushiBar/FormShops.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SushiBar/SushiBar/FormShops.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs
index f6a5594..005782c 100644
--- a/SushiBar/SushiBar/Program.cs
+++ b/SushiBar/SushiBar/Program.cs
@@ -1,10 +1,12 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
+using PizzeriaView;
using SushiBarBusinessLogic.BusinessLogics;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts;
using SushiBarListImplement.Implements;
+using SushiBusinessLogic;
namespace SushiBarView
{
@@ -51,6 +53,12 @@ namespace SushiBarView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
diff --git a/SushiBar/SushiBar/SushiBarView.csproj b/SushiBar/SushiBar/SushiBarView.csproj
index dceb0d9..debfc06 100644
--- a/SushiBar/SushiBar/SushiBarView.csproj
+++ b/SushiBar/SushiBar/SushiBarView.csproj
@@ -17,6 +17,7 @@
+
diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/ShopLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/ShopLogic.cs
new file mode 100644
index 0000000..b1dfc5d
--- /dev/null
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/ShopLogic.cs
@@ -0,0 +1,149 @@
+using Microsoft.Extensions.Logging;
+using PizzeriaContracts.BindingModels;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.BusinessLogicsContracts;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.StoragesContracts;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+
+namespace SushiBusinessLogic
+{
+ public class ShopLogic : IShopLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IShopStorage _shopStorage;
+ private readonly ISushiStorage _SushiStorage;
+ public ShopLogic(ILogger logger, IShopStorage shopStorage, ISushiStorage SushiStorage)
+ {
+ _logger = logger;
+ _shopStorage = shopStorage;
+ _SushiStorage = SushiStorage;
+ }
+ public List? ReadList(ShopSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ShopName: {ShopName}. Id: {Id}",
+ model?.ShopName, model?.Id);
+ var list = model == null ? _shopStorage.GetFullList() :
+ _shopStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count: {Count}", list.Count);
+ return list;
+ }
+ public ShopViewModel? ReadElement(ShopSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ShopName: {ShopName}. Id: {Id}",
+ model.ShopName, model.Id);
+ var element = _shopStorage.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(ShopBindingModel model)
+ {
+ CheckModel(model);
+ if (_shopStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ShopBindingModel model)
+ {
+ CheckModel(model);
+ if (_shopStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ShopBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id: {Id}", model.Id);
+ if (_shopStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ShopBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ShopName))
+ {
+ throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
+ }
+ _logger.LogInformation("Shop. ShopName:{0}.Address:{1}. Id: {2}",
+ model.ShopName, model.Address, model.Id);
+ var element = _shopStorage.GetElement(new ShopSearchModel
+ {
+ ShopName = model.ShopName
+ });
+ if (element != null && element.Id != model.Id && element.ShopName == model.ShopName)
+ {
+ throw new InvalidOperationException("Магазин с таким названием уже есть");
+ }
+ }
+ public bool MakeSupply(SupplyBindingModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (model.Count <= 0)
+ {
+ throw new ArgumentException("Количество изделий должно быть больше 0");
+ }
+ var shop = _shopStorage.GetElement(new ShopSearchModel
+ {
+ Id = model.ShopId
+ });
+ if (shop == null)
+ {
+ throw new ArgumentException("Магазина не существует");
+ }
+ if (shop.ShopSushi.ContainsKey(model.SushiId))
+ {
+ var oldValue = shop.ShopSushi[model.SushiId];
+ oldValue.Item2 += model.Count;
+ shop.ShopSushi[model.SushiId] = oldValue;
+ }
+ else
+ {
+ var sushi = _SushiStorage.GetElement(new SushiSearchModel
+ {
+ Id = model.SushiId
+ });
+ if (sushi == null)
+ {
+ throw new ArgumentException($"Поставка: Товар с id:{model.SushiId} не найденн");
+ }
+ shop.ShopSushi.Add(model.SushiId, (sushi, model.Count));
+ }
+ return true;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarContracts/BindingModels/ShopBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/ShopBindingModel.cs
new file mode 100644
index 0000000..e0be406
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BindingModels/ShopBindingModel.cs
@@ -0,0 +1,20 @@
+using SushiBarDataModels.Models;
+
+namespace SushiBarContracts.BindingModels
+{
+ public class ShopBindingModel : IShopModel
+ {
+ public int Id { get; set; }
+ public string ShopName { get; set; } = string.Empty;
+
+ public string Address { get; set; } = string.Empty;
+
+ public DateTime DateOpening { get; set; } = DateTime.Now;
+
+ public Dictionary ShopSushi
+ {
+ get;
+ set;
+ } = new();
+ }
+}
diff --git a/SushiBar/SushiBarContracts/BindingModels/SupplyBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/SupplyBindingModel.cs
new file mode 100644
index 0000000..3812dbd
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BindingModels/SupplyBindingModel.cs
@@ -0,0 +1,11 @@
+using PizzeriaDataModels.Models;
+
+namespace PizzeriaContracts.BindingModels
+{
+ public class SupplyBindingModel : ISupplyModel
+ {
+ public int ShopId { get; set; }
+ public int SushiId { get; set; }
+ public int Count { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IShopLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IShopLogic.cs
new file mode 100644
index 0000000..e2b6a3b
--- /dev/null
+++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IShopLogic.cs
@@ -0,0 +1,18 @@
+using PizzeriaContracts.BindingModels;
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+
+namespace SushiBarContracts.BusinessLogicsContracts
+{
+ public interface IShopLogic
+ {
+ List? ReadList(ShopSearchModel? model);
+ ShopViewModel? ReadElement(ShopSearchModel model);
+ bool Create(ShopBindingModel model);
+ bool Update(ShopBindingModel model);
+ bool Delete(ShopBindingModel model);
+ bool MakeSupply(SupplyBindingModel supplyBindingModel);
+ }
+}
diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
index e0d7a79..6171674 100644
--- a/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
+++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
@@ -1,4 +1,5 @@
-using SushiBarContracts.BindingModels;
+using PizzeriaContracts.BindingModels;
+using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels;
using SushiBarContracts.ViewModels;
diff --git a/SushiBar/SushiBarContracts/SearchModels/ShopSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/ShopSearchModel.cs
new file mode 100644
index 0000000..5438e15
--- /dev/null
+++ b/SushiBar/SushiBarContracts/SearchModels/ShopSearchModel.cs
@@ -0,0 +1,8 @@
+namespace SushiBarContracts.SearchModels
+{
+ public class ShopSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ShopName { get; set; }
+ }
+}
diff --git a/SushiBar/SushiBarContracts/StoragesContracts/IShopStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IShopStorage.cs
new file mode 100644
index 0000000..8ebaaf5
--- /dev/null
+++ b/SushiBar/SushiBarContracts/StoragesContracts/IShopStorage.cs
@@ -0,0 +1,16 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.SearchModels;
+using SushiBarContracts.ViewModels;
+
+namespace SushiBarContracts.StoragesContracts
+{
+ public interface IShopStorage
+ {
+ List GetFullList();
+ List GetFilteredList(ShopSearchModel model);
+ ShopViewModel? GetElement(ShopSearchModel model);
+ ShopViewModel? Insert(ShopBindingModel model);
+ ShopViewModel? Update(ShopBindingModel model);
+ ShopViewModel? Delete(ShopBindingModel model);
+ }
+}
diff --git a/SushiBar/SushiBarContracts/ViewModels/ShopViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/ShopViewModel.cs
new file mode 100644
index 0000000..998756f
--- /dev/null
+++ b/SushiBar/SushiBarContracts/ViewModels/ShopViewModel.cs
@@ -0,0 +1,24 @@
+using SushiBarDataModels.Models;
+using System.ComponentModel;
+
+namespace SushiBarContracts.ViewModels
+{
+ public class ShopViewModel : IShopModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название магазина")]
+ public string ShopName { get; set; } = string.Empty;
+
+ [DisplayName("Адрес магазина")]
+ public string Address { get; set; } = string.Empty;
+
+ [DisplayName("Дата открытия")]
+ public DateTime DateOpening { get; set; } = DateTime.Now;
+
+ public Dictionary ShopSushi
+ {
+ get;
+ set;
+ } = new();
+ }
+}
diff --git a/SushiBar/SushiBarDataModels/Models/IShopModel.cs b/SushiBar/SushiBarDataModels/Models/IShopModel.cs
new file mode 100644
index 0000000..fb0f104
--- /dev/null
+++ b/SushiBar/SushiBarDataModels/Models/IShopModel.cs
@@ -0,0 +1,10 @@
+namespace SushiBarDataModels.Models
+{
+ public interface IShopModel : IId
+ {
+ string ShopName { get; }
+ string Address { get; }
+ DateTime DateOpening { get; }
+ Dictionary ShopSushi { get; }
+ }
+}
diff --git a/SushiBar/SushiBarDataModels/Models/ISupplyModel.cs b/SushiBar/SushiBarDataModels/Models/ISupplyModel.cs
new file mode 100644
index 0000000..65e08a6
--- /dev/null
+++ b/SushiBar/SushiBarDataModels/Models/ISupplyModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PizzeriaDataModels.Models
+{
+ public interface ISupplyModel
+ {
+ int ShopId { get; }
+ int SushiId { get; }
+ int Count { get; }
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBarListImplement/DataListSingleton.cs b/SushiBar/SushiBarListImplement/DataListSingleton.cs
index f344d8f..81aaf30 100644
--- a/SushiBar/SushiBarListImplement/DataListSingleton.cs
+++ b/SushiBar/SushiBarListImplement/DataListSingleton.cs
@@ -8,11 +8,14 @@ namespace SushiBarListImplement
public List Ingredients { get; set; }
public List Orders { get; set; }
public List ListSushi { get; set; }
+
+ public List Shops { get; set; }
private DataListSingleton()
{
Ingredients = new List();
Orders = new List();
ListSushi = new List();
+ Shops = new List();
}
public static DataListSingleton GetInstance()
{
diff --git a/SushiBar/SushiBarListImplement/Implements/ShopStorage.cs b/SushiBar/SushiBarListImplement/Implements/ShopStorage.cs
new file mode 100644
index 0000000..a36aef1
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/Implements/ShopStorage.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 ShopStorage : IShopStorage
+ {
+ private readonly DataListSingleton _source;
+ public ShopStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var shop in _source.Shops)
+ {
+ result.Add(shop.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(ShopSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ShopName))
+ {
+ return result;
+ }
+ foreach (var shop in _source.Shops)
+ {
+ if (shop.ShopName.Contains(model.ShopName ?? string.Empty))
+ {
+ result.Add(shop.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public ShopViewModel? GetElement(ShopSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var shop in _source.Shops)
+ {
+ if ((!string.IsNullOrEmpty(model.ShopName) &&
+ shop.ShopName == model.ShopName) ||
+ (model.Id.HasValue && shop.Id == model.Id))
+ {
+ return shop.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ShopViewModel? Insert(ShopBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var shop in _source.Shops)
+ {
+ if (model.Id <= shop.Id)
+ {
+ model.Id = shop.Id + 1;
+ }
+ }
+ var newShop = Shop.Create(model);
+ if (newShop == null)
+ {
+ return null;
+ }
+ _source.Shops.Add(newShop);
+ return newShop.GetViewModel;
+ }
+ public ShopViewModel? Update(ShopBindingModel model)
+ {
+ foreach (var shop in _source.Shops)
+ {
+ if (shop.Id == model.Id)
+ {
+ shop.Update(model);
+ return shop.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ShopViewModel? Delete(ShopBindingModel model)
+ {
+ for (int i = 0; i < _source.Shops.Count; ++i)
+ {
+ if (_source.Shops[i].Id == model.Id)
+ {
+ var element = _source.Shops[i];
+ _source.Shops.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/SushiBar/SushiBarListImplement/Models/Shop.cs b/SushiBar/SushiBarListImplement/Models/Shop.cs
new file mode 100644
index 0000000..ef5e59d
--- /dev/null
+++ b/SushiBar/SushiBarListImplement/Models/Shop.cs
@@ -0,0 +1,53 @@
+using SushiBarContracts.BindingModels;
+using SushiBarContracts.ViewModels;
+using SushiBarDataModels.Models;
+
+namespace SushiBarListImplement.Models
+{
+ public class Shop : IShopModel
+ {
+ public int Id { get; private set; }
+ public string ShopName { get; private set; } = string.Empty;
+ public string Address { get; private set; } = string.Empty;
+ public DateTime DateOpening { get; private set; }
+ public Dictionary ShopSushi
+ {
+ get;
+ private set;
+ } = new();
+ public static Shop? Create(ShopBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Shop()
+ {
+ Id = model.Id,
+ ShopName = model.ShopName,
+ Address = model.Address,
+ DateOpening = model.DateOpening,
+ ShopSushi = new()
+ };
+ }
+ public void Update(ShopBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ShopName = model.ShopName;
+ Address = model.Address;
+ DateOpening = model.DateOpening;
+ ShopSushi = model.ShopSushi;
+ }
+ public ShopViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ShopName = ShopName,
+ Address = Address,
+ ShopSushi = ShopSushi,
+ DateOpening = DateOpening,
+ };
+ }
+}