Compare commits
5 Commits
LabWork_2
...
LabWork_1_
| Author | SHA1 | Date | |
|---|---|---|---|
| 153d212184 | |||
| 4b9f66ba35 | |||
| b7ccba8acc | |||
| 665aaab1a6 | |||
| ae4eef9254 |
53
SushiBar/SushiBar/FormMain.Designer.cs
generated
53
SushiBar/SushiBar/FormMain.Designer.cs
generated
@@ -31,13 +31,15 @@
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.directoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.sushiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.storeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonSubmit = new System.Windows.Forms.Button();
|
||||
this.buttonReady = new System.Windows.Forms.Button();
|
||||
this.buttonIssue = new System.Windows.Forms.Button();
|
||||
this.buttonReload = new System.Windows.Forms.Button();
|
||||
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.sushiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.buttonReplenishment = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@@ -65,11 +67,33 @@
|
||||
//
|
||||
this.directoryToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.componentsToolStripMenuItem,
|
||||
this.sushiToolStripMenuItem});
|
||||
this.sushiToolStripMenuItem,
|
||||
this.storeToolStripMenuItem});
|
||||
this.directoryToolStripMenuItem.Name = "directoryToolStripMenuItem";
|
||||
this.directoryToolStripMenuItem.Size = new System.Drawing.Size(67, 20);
|
||||
this.directoryToolStripMenuItem.Text = "Directory";
|
||||
//
|
||||
// componentsToolStripMenuItem
|
||||
//
|
||||
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
|
||||
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.componentsToolStripMenuItem.Text = "Components";
|
||||
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||
//
|
||||
// sushiToolStripMenuItem
|
||||
//
|
||||
this.sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
|
||||
this.sushiToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.sushiToolStripMenuItem.Text = "Sushi";
|
||||
this.sushiToolStripMenuItem.Click += new System.EventHandler(this.SushiToolStripMenuItem_Click);
|
||||
//
|
||||
// storeToolStripMenuItem
|
||||
//
|
||||
this.storeToolStripMenuItem.Name = "storeToolStripMenuItem";
|
||||
this.storeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.storeToolStripMenuItem.Text = "Store";
|
||||
this.storeToolStripMenuItem.Click += new System.EventHandler(this.StoreToolStripMenuItem_Click);
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(674, 27);
|
||||
@@ -120,25 +144,22 @@
|
||||
this.buttonReload.UseVisualStyleBackColor = true;
|
||||
this.buttonReload.Click += new System.EventHandler(this.ButtonReload_Click);
|
||||
//
|
||||
// componentsToolStripMenuItem
|
||||
// buttonReplenishment
|
||||
//
|
||||
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
|
||||
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.componentsToolStripMenuItem.Text = "Components";
|
||||
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||
//
|
||||
// sushiToolStripMenuItem
|
||||
//
|
||||
this.sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
|
||||
this.sushiToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.sushiToolStripMenuItem.Text = "Sushi";
|
||||
this.sushiToolStripMenuItem.Click += new System.EventHandler(this.SushiToolStripMenuItem_Click);
|
||||
this.buttonReplenishment.Location = new System.Drawing.Point(674, 415);
|
||||
this.buttonReplenishment.Name = "buttonReplenishment";
|
||||
this.buttonReplenishment.Size = new System.Drawing.Size(114, 23);
|
||||
this.buttonReplenishment.TabIndex = 7;
|
||||
this.buttonReplenishment.Text = "Replenishment";
|
||||
this.buttonReplenishment.UseVisualStyleBackColor = true;
|
||||
this.buttonReplenishment.Click += new System.EventHandler(this.ButtonReplenishment_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonReplenishment);
|
||||
this.Controls.Add(this.buttonReload);
|
||||
this.Controls.Add(this.buttonIssue);
|
||||
this.Controls.Add(this.buttonReady);
|
||||
@@ -170,5 +191,7 @@
|
||||
private Button buttonReload;
|
||||
private ToolStripMenuItem componentsToolStripMenuItem;
|
||||
private ToolStripMenuItem sushiToolStripMenuItem;
|
||||
private ToolStripMenuItem storeToolStripMenuItem;
|
||||
private Button buttonReplenishment;
|
||||
}
|
||||
}
|
||||
@@ -170,5 +170,25 @@ namespace SushiBar
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void StoreToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStores));
|
||||
|
||||
if (service is FormStores form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonReplenishment_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStoreReplenishment));
|
||||
|
||||
if (service is FormStoreReplenishment form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
171
SushiBar/SushiBar/FormStore.Designer.cs
generated
Normal file
171
SushiBar/SushiBar/FormStore.Designer.cs
generated
Normal file
@@ -0,0 +1,171 @@
|
||||
namespace SushiBar
|
||||
{
|
||||
partial class FormStore
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.comboBoxName = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.SushiName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Cost = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.SushiName,
|
||||
this.Cost,
|
||||
this.Count});
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(598, 426);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// comboBoxName
|
||||
//
|
||||
this.comboBoxName.FormattingEnabled = true;
|
||||
this.comboBoxName.Location = new System.Drawing.Point(616, 12);
|
||||
this.comboBoxName.Name = "comboBoxName";
|
||||
this.comboBoxName.Size = new System.Drawing.Size(172, 23);
|
||||
this.comboBoxName.TabIndex = 1;
|
||||
this.comboBoxName.SelectedIndexChanged += new System.EventHandler(this.ComboBoxName_SelectedIndexChanged);
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(616, 56);
|
||||
this.textBoxAddress.Name = "textBoxAddress";
|
||||
this.textBoxAddress.Size = new System.Drawing.Size(172, 23);
|
||||
this.textBoxAddress.TabIndex = 2;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(616, 38);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(49, 15);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Address";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(616, 82);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(80, 15);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Date Opening";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(621, 415);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Save";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(702, 415);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(86, 23);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
this.dateTimePicker.Location = new System.Drawing.Point(616, 100);
|
||||
this.dateTimePicker.Name = "dateTimePicker";
|
||||
this.dateTimePicker.Size = new System.Drawing.Size(172, 23);
|
||||
this.dateTimePicker.TabIndex = 8;
|
||||
//
|
||||
// SushiName
|
||||
//
|
||||
this.SushiName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.SushiName.HeaderText = "Sushi";
|
||||
this.SushiName.Name = "SushiName";
|
||||
//
|
||||
// Cost
|
||||
//
|
||||
this.Cost.HeaderText = "Cost";
|
||||
this.Cost.Name = "Cost";
|
||||
//
|
||||
// Count
|
||||
//
|
||||
this.Count.HeaderText = "Count";
|
||||
this.Count.Name = "Count";
|
||||
//
|
||||
// FormStore
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.dateTimePicker);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.textBoxAddress);
|
||||
this.Controls.Add(this.comboBoxName);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormStore";
|
||||
this.Text = "FormStore";
|
||||
this.Load += new System.EventHandler(this.FormStore_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private ComboBox comboBoxName;
|
||||
private TextBox textBoxAddress;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private DataGridViewTextBoxColumn SushiName;
|
||||
private DataGridViewTextBoxColumn Cost;
|
||||
private DataGridViewTextBoxColumn Count;
|
||||
}
|
||||
}
|
||||
141
SushiBar/SushiBar/FormStore.cs
Normal file
141
SushiBar/SushiBar/FormStore.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
public partial class FormStore : Form
|
||||
{
|
||||
private readonly List<StoreViewModel>? _listStores;
|
||||
private readonly IStoreLogic _logic;
|
||||
private readonly ILogger _logger;
|
||||
public int id { get; set; }
|
||||
public FormStore(ILogger<FormStore> logger, IStoreLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_listStores = logic.ReadList(null);
|
||||
_logic = logic;
|
||||
if (_listStores != null)
|
||||
{
|
||||
comboBoxName.DisplayMember = "StoreName";
|
||||
comboBoxName.ValueMember = "Id";
|
||||
comboBoxName.DataSource = _listStores;
|
||||
comboBoxName.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData(bool extendDate = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var model = GetStore(extendDate ? id : Convert.ToInt32(comboBoxName.SelectedValue));
|
||||
if (model != null)
|
||||
{
|
||||
comboBoxName.Text = model.StoreName;
|
||||
textBoxAddress.Text = model.StoreAdress;
|
||||
dateTimePicker.Text = Convert.ToString(model.OpeningDate);
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var el in model.Sushis.Values)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { el.Item1.SushiName, el.Item1.Price, el.Item2 });
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Load stores");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on load");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private IStoreModel? GetStore(int id)
|
||||
{
|
||||
if (_listStores == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _listStores)
|
||||
{
|
||||
if (elem.Id == id)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(comboBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Select store name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Fill in address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Saving store");
|
||||
|
||||
try
|
||||
{
|
||||
DateTime.TryParse(dateTimePicker.Text, out var dateTime);
|
||||
StoreBindingModel model = new()
|
||||
{
|
||||
StoreName = comboBoxName.Text,
|
||||
StoreAdress = textBoxAddress.Text,
|
||||
OpeningDate = dateTime
|
||||
};
|
||||
var search_model = GetStore(id);
|
||||
bool operationResult = false;
|
||||
|
||||
if (search_model != null)
|
||||
{
|
||||
model.Id = search_model.Id;
|
||||
operationResult = _logic.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
operationResult = _logic.Create(model);
|
||||
}
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Error on saving. Additional info below");
|
||||
}
|
||||
|
||||
MessageBox.Show("Save is successful", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on saving");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ComboBoxName_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
LoadData(false);
|
||||
}
|
||||
|
||||
private void FormStore_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
69
SushiBar/SushiBar/FormStore.resx
Normal file
69
SushiBar/SushiBar/FormStore.resx
Normal file
@@ -0,0 +1,69 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="SushiName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Cost.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
142
SushiBar/SushiBar/FormStoreReplenishment.Designer.cs
generated
Normal file
142
SushiBar/SushiBar/FormStoreReplenishment.Designer.cs
generated
Normal file
@@ -0,0 +1,142 @@
|
||||
namespace SushiBar
|
||||
{
|
||||
partial class FormStoreReplenishment
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.comboBoxStore = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxSushi = new System.Windows.Forms.ComboBox();
|
||||
this.labelSushi = new System.Windows.Forms.Label();
|
||||
this.labelStore = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comboBoxStore
|
||||
//
|
||||
this.comboBoxStore.FormattingEnabled = true;
|
||||
this.comboBoxStore.Location = new System.Drawing.Point(73, 12);
|
||||
this.comboBoxStore.Name = "comboBoxStore";
|
||||
this.comboBoxStore.Size = new System.Drawing.Size(172, 23);
|
||||
this.comboBoxStore.TabIndex = 0;
|
||||
//
|
||||
// comboBoxSushi
|
||||
//
|
||||
this.comboBoxSushi.FormattingEnabled = true;
|
||||
this.comboBoxSushi.Location = new System.Drawing.Point(73, 41);
|
||||
this.comboBoxSushi.Name = "comboBoxSushi";
|
||||
this.comboBoxSushi.Size = new System.Drawing.Size(172, 23);
|
||||
this.comboBoxSushi.TabIndex = 1;
|
||||
//
|
||||
// labelSushi
|
||||
//
|
||||
this.labelSushi.AutoSize = true;
|
||||
this.labelSushi.Location = new System.Drawing.Point(12, 44);
|
||||
this.labelSushi.Name = "labelSushi";
|
||||
this.labelSushi.Size = new System.Drawing.Size(35, 15);
|
||||
this.labelSushi.TabIndex = 2;
|
||||
this.labelSushi.Text = "Sushi";
|
||||
//
|
||||
// labelStore
|
||||
//
|
||||
this.labelStore.AutoSize = true;
|
||||
this.labelStore.Location = new System.Drawing.Point(12, 15);
|
||||
this.labelStore.Name = "labelStore";
|
||||
this.labelStore.Size = new System.Drawing.Size(34, 15);
|
||||
this.labelStore.TabIndex = 3;
|
||||
this.labelStore.Text = "Store";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(12, 101);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(113, 23);
|
||||
this.buttonSave.TabIndex = 4;
|
||||
this.buttonSave.Text = "Save";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(131, 101);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(114, 23);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(12, 75);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(40, 15);
|
||||
this.labelCount.TabIndex = 6;
|
||||
this.labelCount.Text = "Count";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(73, 72);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(172, 23);
|
||||
this.textBoxCount.TabIndex = 7;
|
||||
//
|
||||
// FormStoreReplenishment
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(257, 136);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.labelStore);
|
||||
this.Controls.Add(this.labelSushi);
|
||||
this.Controls.Add(this.comboBoxSushi);
|
||||
this.Controls.Add(this.comboBoxStore);
|
||||
this.Name = "FormStoreReplenishment";
|
||||
this.Text = "FormStoreReplenishment";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxStore;
|
||||
private ComboBox comboBoxSushi;
|
||||
private Label labelSushi;
|
||||
private Label labelStore;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelCount;
|
||||
private TextBox textBoxCount;
|
||||
}
|
||||
}
|
||||
95
SushiBar/SushiBar/FormStoreReplenishment.cs
Normal file
95
SushiBar/SushiBar/FormStoreReplenishment.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
public partial class FormStoreReplenishment : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreLogic _storeLogic;
|
||||
private readonly ISushiLogic _sushiLogic;
|
||||
private readonly List<StoreViewModel>? _listStores;
|
||||
private readonly List<SushiViewModel>? _listSushi;
|
||||
public FormStoreReplenishment(ILogger<FormStoreReplenishment> logger, IStoreLogic storeLogic, ISushiLogic sushiLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storeLogic = storeLogic;
|
||||
_sushiLogic = sushiLogic;
|
||||
_logger = logger;
|
||||
_listStores = storeLogic.ReadList(null);
|
||||
if (_listStores != null)
|
||||
{
|
||||
comboBoxStore.DisplayMember = "StoreName";
|
||||
comboBoxStore.ValueMember = "Id";
|
||||
comboBoxStore.DataSource = _listStores;
|
||||
comboBoxStore.SelectedItem = null;
|
||||
}
|
||||
|
||||
_listSushi = sushiLogic.ReadList(null);
|
||||
if (_listSushi != null)
|
||||
{
|
||||
comboBoxSushi.DisplayMember = "SushiName";
|
||||
comboBoxSushi.ValueMember = "Id";
|
||||
comboBoxSushi.DataSource = _listSushi;
|
||||
comboBoxSushi.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxStore.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Select store", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxSushi.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Select sushi", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Add sushi to store");
|
||||
|
||||
try
|
||||
{
|
||||
var sushi = _sushiLogic.ReadElement(new()
|
||||
{
|
||||
Id = (int)comboBoxSushi.SelectedValue
|
||||
});
|
||||
|
||||
if (sushi == null)
|
||||
{
|
||||
throw new Exception("Sushi is not found. Additional info below.");
|
||||
}
|
||||
|
||||
var resultOperation = _storeLogic.AddPackage(
|
||||
model: new() { Id = (int)comboBoxStore.SelectedValue },
|
||||
sushi: sushi,
|
||||
quantity: Convert.ToInt32(textBoxCount.Text)
|
||||
);
|
||||
|
||||
if (!resultOperation)
|
||||
{
|
||||
throw new Exception("Error on saving. Additional info below.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Save is successful", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on saving");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
60
SushiBar/SushiBar/FormStoreReplenishment.resx
Normal file
60
SushiBar/SushiBar/FormStoreReplenishment.resx
Normal file
@@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
114
SushiBar/SushiBar/FormStores.Designer.cs
generated
Normal file
114
SushiBar/SushiBar/FormStores.Designer.cs
generated
Normal file
@@ -0,0 +1,114 @@
|
||||
namespace SushiBar
|
||||
{
|
||||
partial class FormStores
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonRemove = new System.Windows.Forms.Button();
|
||||
this.buttonChange = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(605, 426);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(623, 12);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(165, 23);
|
||||
this.buttonAdd.TabIndex = 1;
|
||||
this.buttonAdd.Text = "Add";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// buttonRemove
|
||||
//
|
||||
this.buttonRemove.Location = new System.Drawing.Point(623, 41);
|
||||
this.buttonRemove.Name = "buttonRemove";
|
||||
this.buttonRemove.Size = new System.Drawing.Size(165, 23);
|
||||
this.buttonRemove.TabIndex = 2;
|
||||
this.buttonRemove.Text = "Remove";
|
||||
this.buttonRemove.UseVisualStyleBackColor = true;
|
||||
this.buttonRemove.Click += new System.EventHandler(this.ButtonRemove_Click);
|
||||
//
|
||||
// buttonChange
|
||||
//
|
||||
this.buttonChange.Location = new System.Drawing.Point(623, 70);
|
||||
this.buttonChange.Name = "buttonChange";
|
||||
this.buttonChange.Size = new System.Drawing.Size(165, 23);
|
||||
this.buttonChange.TabIndex = 3;
|
||||
this.buttonChange.Text = "Change";
|
||||
this.buttonChange.UseVisualStyleBackColor = true;
|
||||
this.buttonChange.Click += new System.EventHandler(this.ButtonChange_Click);
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(623, 99);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(165, 23);
|
||||
this.buttonUpdate.TabIndex = 4;
|
||||
this.buttonUpdate.Text = "Update";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
||||
//
|
||||
// FormStores
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonChange);
|
||||
this.Controls.Add(this.buttonRemove);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormStores";
|
||||
this.Text = "FormStores";
|
||||
this.Load += new System.EventHandler(this.FormStores_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
private Button buttonRemove;
|
||||
private Button buttonChange;
|
||||
private Button buttonUpdate;
|
||||
}
|
||||
}
|
||||
113
SushiBar/SushiBar/FormStores.cs
Normal file
113
SushiBar/SushiBar/FormStores.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
public partial class FormStores : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreLogic _logic;
|
||||
public FormStores(ILogger<FormStores> logger, IStoreLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["StoreName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Sushis"].Visible = false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Load stores");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on loading");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStore));
|
||||
|
||||
if (service is FormStore form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Deleting store");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new StoreBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Error on deleting. Additional info below.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error delete store");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonChange_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStore));
|
||||
|
||||
if (service is FormStore form)
|
||||
{
|
||||
form.id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void FormStores_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
60
SushiBar/SushiBar/FormStores.resx
Normal file
60
SushiBar/SushiBar/FormStores.resx
Normal file
@@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
2
SushiBar/SushiBar/FormSushi.Designer.cs
generated
2
SushiBar/SushiBar/FormSushi.Designer.cs
generated
@@ -168,7 +168,7 @@
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.HeaderText = "Id";
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
//
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace SushiBar
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<ISushiLogic, SushiLogic>();
|
||||
services.AddTransient<IStoreStorage, StoreStorage>();
|
||||
services.AddTransient<IStoreLogic, StoreLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
@@ -42,6 +44,9 @@ namespace SushiBar
|
||||
services.AddTransient<FormSushi>();
|
||||
services.AddTransient<FormSushiComponent>();
|
||||
services.AddTransient<FormSushiMoreThenOne>();
|
||||
services.AddTransient<FormStores>();
|
||||
services.AddTransient<FormStore>();
|
||||
services.AddTransient<FormStoreReplenishment>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,14 +46,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_orderStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return UpdateStatus(model, OrderStatus.Issued);
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
@@ -77,13 +70,17 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
private bool UpdateStatus(OrderBindingModel model, OrderStatus status)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
var order = _orderStorage.GetElement(new OrderSearchModel() { Id = model.Id });
|
||||
|
||||
if (model.Status + 1 != status)
|
||||
{
|
||||
_logger.LogWarning("Status update operation failed");
|
||||
return false;
|
||||
}
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Issued)
|
||||
model.DateImplement = order?.DateImplement;
|
||||
if (model.Status == OrderStatus.Ready)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
}
|
||||
@@ -107,7 +104,8 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Order. OrderId:{Id} .Count:{Count} .Sum:{Sum} .Status{Status} .DateCreate{DateCreate}", model.Id, model.Count, model.Sum, model.Status.ToString(), model.DateCreate.ToString());
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel {
|
||||
var element = _orderStorage.GetElement(new OrderSearchModel
|
||||
{
|
||||
Id = model.Id
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
@@ -116,4 +114,4 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
178
SushiBar/SushiBarBusinessLogic/BusinessLogics/StoreLogic.cs
Normal file
178
SushiBar/SushiBarBusinessLogic/BusinessLogics/StoreLogic.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class StoreLogic : IStoreLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreStorage _storeStorage;
|
||||
|
||||
public StoreLogic(ILogger<StoreLogic> logger, IStoreStorage storeStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storeStorage = storeStorage;
|
||||
}
|
||||
|
||||
public bool AddPackage(StoreSearchModel model, ISushiModel sushi, int quantity)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (quantity <= 0)
|
||||
{
|
||||
throw new ArgumentException("Quantity must be more then zero", nameof(quantity));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddPackageInStore. StoreName:{StoreName}.Id:{ Id}", model.StoreName, model.Id);
|
||||
|
||||
var element = _storeStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("AddPackageInStore element not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddPackageInStore find. Id:{Id}", element.Id);
|
||||
|
||||
if (element.Sushis.TryGetValue(sushi.Id, out var pair))
|
||||
{
|
||||
element.Sushis[sushi.Id] = (sushi, quantity + pair.Item2);
|
||||
_logger.LogInformation("AddPackageInStore. Has been added {quantity} {package} in {StoreName}", quantity, sushi.SushiName, element.StoreName);
|
||||
}
|
||||
else
|
||||
{
|
||||
element.Sushis[sushi.Id] = (sushi, quantity);
|
||||
_logger.LogInformation("AddPastryInShop. Has been added {quantity} new Package {package} in {StoreName}", quantity, sushi.SushiName, element.StoreName);
|
||||
}
|
||||
|
||||
_storeStorage.Update(new()
|
||||
{
|
||||
Id = element.Id,
|
||||
StoreAdress = element.StoreAdress,
|
||||
StoreName = element.StoreName,
|
||||
OpeningDate = element.OpeningDate,
|
||||
Sushis = element.Sushis
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Create(StoreBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
model.Sushis = new();
|
||||
|
||||
if (_storeStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(StoreBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_storeStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public StoreViewModel? ReadElement(StoreSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. StoreName:{StoreName}.Id:{ Id}", model.StoreName, model.Id);
|
||||
var element = _storeStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<StoreViewModel>? ReadList(StoreSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. StoreName:{StoreName}.Id:{ Id} ", model?.StoreName, model?.Id);
|
||||
|
||||
var list = (model == null) ? _storeStorage.GetFullList() : _storeStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(StoreBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
if (string.IsNullOrEmpty(model.StoreName))
|
||||
{
|
||||
throw new ArgumentNullException("Store name is empty!", nameof(model.StoreName));
|
||||
}
|
||||
|
||||
if (_storeStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(StoreBindingModel model, bool withParams=true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.StoreName))
|
||||
{
|
||||
throw new ArgumentNullException("Store name is empty!", nameof(model.StoreName));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Store. StoreName:{0}.StoreAdress:{1}. Id: {2}", model.StoreName, model.StoreAdress, model.Id);
|
||||
var element = _storeStorage.GetElement(new StoreSearchModel
|
||||
{
|
||||
StoreName = model.StoreName
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id && element.StoreName == model.StoreName)
|
||||
{
|
||||
throw new InvalidOperationException("This name of store is already exists!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarContracts.BindingModels
|
||||
{
|
||||
public class StoreBindingModel
|
||||
{
|
||||
public string StoreName { get; set; } = string.Empty;
|
||||
public string StoreAdress { get; set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (ISushiModel, int)> Sushis { get; set; } = new();
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IStoreLogic
|
||||
{
|
||||
List<StoreViewModel>? ReadList(StoreSearchModel? model);
|
||||
StoreViewModel? ReadElement(StoreSearchModel model);
|
||||
bool Create(StoreBindingModel model);
|
||||
bool Update(StoreBindingModel model);
|
||||
bool Delete(StoreBindingModel model);
|
||||
bool AddPackage(StoreSearchModel model, ISushiModel sushi, int quantity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SushiBarContracts.SearchModels
|
||||
{
|
||||
public class StoreSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? StoreName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushiBarContracts.StoragesContracts
|
||||
{
|
||||
public interface IStoreStorage
|
||||
{
|
||||
List<StoreViewModel> GetFullList();
|
||||
List<StoreViewModel> GetFilteredList(StoreSearchModel model);
|
||||
StoreViewModel? GetElement(StoreSearchModel model);
|
||||
StoreViewModel? Insert(StoreBindingModel model);
|
||||
StoreViewModel? Update(StoreBindingModel model);
|
||||
StoreViewModel? Delete(StoreBindingModel model);
|
||||
}
|
||||
}
|
||||
18
SushiBar/SushiBarContracts/ViewModels/StoreViewModel.cs
Normal file
18
SushiBar/SushiBarContracts/ViewModels/StoreViewModel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class StoreViewModel : IStoreModel
|
||||
{
|
||||
public Dictionary<int, (ISushiModel, int)> Sushis { get; set; } = new();
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Name store")]
|
||||
public string StoreName { get; set; } = string.Empty;
|
||||
[DisplayName("Adress store")]
|
||||
public string StoreAdress { get; set; } = string.Empty;
|
||||
[DisplayName("Date opening")]
|
||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
10
SushiBar/SushiBarModels/Models/IStoreModel.cs
Normal file
10
SushiBar/SushiBarModels/Models/IStoreModel.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace SushiBarDataModels.Models
|
||||
{
|
||||
public interface IStoreModel : IId
|
||||
{
|
||||
public string StoreName { get; }
|
||||
public string StoreAdress { get; }
|
||||
DateTime OpeningDate { get; }
|
||||
Dictionary<int, (ISushiModel, int)> Sushis { get; }
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,13 @@ namespace SushibarListImplement
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Sushi> Sushi { get; set; }
|
||||
public List<Store> Stores { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Sushi = new List<Sushi>();
|
||||
Stores = new List<Store>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
||||
118
SushiBar/SushibarListImplement/Implements/StoreStorage.cs
Normal file
118
SushiBar/SushibarListImplement/Implements/StoreStorage.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushibarListImplement.Models;
|
||||
|
||||
namespace SushibarListImplement.Implements
|
||||
{
|
||||
public class StoreStorage : IStoreStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public StoreStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public StoreViewModel? Delete(StoreBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Stores.Count; ++i)
|
||||
{
|
||||
if (_source.Stores[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Stores[i];
|
||||
_source.Stores.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public StoreViewModel? GetElement(StoreSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.StoreName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.StoreName) && store.StoreName == model.StoreName) || (model.Id.HasValue && store.Id == model.Id))
|
||||
{
|
||||
return store.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<StoreViewModel> GetFilteredList(StoreSearchModel model)
|
||||
{
|
||||
var result = new List<StoreViewModel>();
|
||||
|
||||
if (string.IsNullOrEmpty(model.StoreName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
if (store.StoreName.Contains(model.StoreName))
|
||||
{
|
||||
result.Add(store.GetViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<StoreViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<StoreViewModel>();
|
||||
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
result.Add(store.GetViewModel);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public StoreViewModel? Insert(StoreBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
if (model.Id <= store.Id)
|
||||
{
|
||||
model.Id = store.Id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newStore = Store.Create(model);
|
||||
|
||||
if (newStore == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Stores.Add(newStore);
|
||||
|
||||
return newStore.GetViewModel;
|
||||
}
|
||||
|
||||
public StoreViewModel? Update(StoreBindingModel model)
|
||||
{
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
if (store.Id == model.Id)
|
||||
{
|
||||
store.Update(model);
|
||||
return store.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
52
SushiBar/SushibarListImplement/Models/Store.cs
Normal file
52
SushiBar/SushibarListImplement/Models/Store.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushibarListImplement.Models
|
||||
{
|
||||
public class Store : IStoreModel
|
||||
{
|
||||
public string StoreName { get; private set; } = string.Empty;
|
||||
public string StoreAdress { get; private set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; private set; }
|
||||
public Dictionary<int, (ISushiModel, int)> Sushis { get; private set; } = new();
|
||||
public int Id { get; private set; }
|
||||
|
||||
public static Store? Create(StoreBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Store()
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreName = model.StoreName,
|
||||
StoreAdress = model.StoreAdress,
|
||||
OpeningDate = model.OpeningDate,
|
||||
Sushis = new()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(StoreBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StoreName = model.StoreName;
|
||||
StoreAdress = model.StoreAdress;
|
||||
OpeningDate = model.OpeningDate;
|
||||
Sushis = model.Sushis;
|
||||
}
|
||||
|
||||
public StoreViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StoreName = StoreName,
|
||||
StoreAdress = StoreAdress,
|
||||
OpeningDate = OpeningDate,
|
||||
Sushis = Sushis
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user