2 готовая усложненная работа

This commit is contained in:
Alina Batylkina 2023-06-13 23:06:43 +04:00
parent 0a4b6aa1ce
commit a0d620afd5
37 changed files with 836 additions and 154 deletions

View File

@ -12,6 +12,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Extensions.Logging;
namespace FurnitureAssembly namespace FurnitureAssembly
{ {
@ -20,6 +21,9 @@ namespace FurnitureAssembly
private readonly List<ShopViewModel>? _listShops; private readonly List<ShopViewModel>? _listShops;
private readonly List<FurnitureViewModel>? _listFurnitures; private readonly List<FurnitureViewModel>? _listFurnitures;
private IShopLogic _shopLogic;
private ILogger _logger;
public int Id public int Id
{ {
@ -32,24 +36,7 @@ namespace FurnitureAssembly
comboBoxShop.SelectedValue = value; comboBoxShop.SelectedValue = value;
} }
} }
public IShopModel? ShopModel
{
get
{
if (_listShops == null)
{
return null;
}
foreach (var elem in _listShops)
{
if (elem.Id == Id)
{
return elem;
}
}
return null;
}
}
public int FurnitureId public int FurnitureId
{ {
@ -62,24 +49,6 @@ namespace FurnitureAssembly
comboBoxFurniture.SelectedValue = value; comboBoxFurniture.SelectedValue = value;
} }
} }
public IFurnitureModel? FurnitureModel
{
get
{
if (_listFurnitures == null)
{
return null;
}
foreach (var elem in _listFurnitures)
{
if (elem.Id == Id)
{
return elem;
}
}
return null;
}
}
public int Count public int Count
{ {
@ -87,9 +56,11 @@ namespace FurnitureAssembly
set set
{ textBoxCount.Text = value.ToString(); } { textBoxCount.Text = value.ToString(); }
} }
public FormAddToShop(IShopLogic shopLogic, IfurnitureLogic furnitureLogic) public FormAddToShop(IShopLogic shopLogic, IfurnitureLogic furnitureLogic, ILogger<FormShop> logger)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger;
_shopLogic = shopLogic;
_listShops = shopLogic.ReadList(null); _listShops = shopLogic.ReadList(null);
_listFurnitures = furnitureLogic.ReadList(null); _listFurnitures = furnitureLogic.ReadList(null);
if (_listShops != null) if (_listShops != null)
@ -135,6 +106,22 @@ namespace FurnitureAssembly
return; return;
} }
try
{
_logger.LogInformation("Добавление в магазин с id = {ShopName} изделия: id = { FurnitureName} - { Count}", Id, FurnitureId, Count);
var operationResult = _shopLogic.AddFurniture(new ShopBindingModel { Id = Id }, new FurnitureBindingModel { Id = FurnitureId }, Count);
if (!operationResult)
{
throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах.");
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при пополнении магазина c id = " + Id);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }

View File

@ -0,0 +1,119 @@
namespace FurnitureAssemblyView
{
partial class FormSell
{
/// <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.labelFurniture = new System.Windows.Forms.Label();
this.comboBoxToSell = new System.Windows.Forms.ComboBox();
this.labelCount = new System.Windows.Forms.Label();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.buttonSell = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelFurniture
//
this.labelFurniture.AutoSize = true;
this.labelFurniture.Location = new System.Drawing.Point(38, 53);
this.labelFurniture.Name = "labelFurniture";
this.labelFurniture.Size = new System.Drawing.Size(80, 25);
this.labelFurniture.TabIndex = 0;
this.labelFurniture.Text = "Изделие";
//
// comboBoxToSell
//
this.comboBoxToSell.FormattingEnabled = true;
this.comboBoxToSell.Location = new System.Drawing.Point(174, 50);
this.comboBoxToSell.Name = "comboBoxToSell";
this.comboBoxToSell.Size = new System.Drawing.Size(182, 33);
this.comboBoxToSell.TabIndex = 1;
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(43, 133);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(107, 25);
this.labelCount.TabIndex = 2;
this.labelCount.Text = "Количество";
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(178, 131);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(150, 31);
this.textBoxCount.TabIndex = 3;
//
// buttonSell
//
this.buttonSell.Location = new System.Drawing.Point(38, 225);
this.buttonSell.Name = "buttonSell";
this.buttonSell.Size = new System.Drawing.Size(112, 34);
this.buttonSell.TabIndex = 4;
this.buttonSell.Text = "Продать";
this.buttonSell.UseVisualStyleBackColor = true;
this.buttonSell.Click += new System.EventHandler(this.buttonSell_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(216, 225);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(112, 34);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// FormSell
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(463, 313);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSell);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.comboBoxToSell);
this.Controls.Add(this.labelFurniture);
this.Name = "FormSell";
this.Text = "Продажа мебели";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelFurniture;
private ComboBox comboBoxToSell;
private Label labelCount;
private TextBox textBoxCount;
private Button buttonSell;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,113 @@
using FurnitureAssemblyDataModels.Models;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FurnitureAssemblyView
{
public partial class FormSell : Form
{
private readonly IShopLogic _shopLogic;
private readonly List<FurnitureViewModel>? _listFurnitures;
public int Id
{
get
{
return Convert.ToInt32(comboBoxToSell.SelectedValue);
}
set
{
comboBoxToSell.SelectedValue = value;
}
}
public IFurnitureModel? FurnitureModel
{
get
{
if (_listFurnitures == null)
{
return null;
}
foreach (var elem in _listFurnitures)
{
if (elem.Id == Id)
{
return elem;
}
}
return null;
}
}
public int Count
{
get
{
return Convert.ToInt32(textBoxCount.Text);
}
set
{
textBoxCount.Text = value.ToString();
}
}
public FormSell(IShopLogic shopLogic, IfurnitureLogic furnitureLogic)
{
InitializeComponent();
_shopLogic = shopLogic;
_listFurnitures = furnitureLogic.ReadList(null);
if (_listFurnitures != null)
{
comboBoxToSell.DisplayMember = "FurnitureName";
comboBoxToSell.ValueMember = "Id";
comboBoxToSell.DataSource = _listFurnitures;
comboBoxToSell.SelectedItem = null;
}
}
private void buttonSell_Click(object sender, EventArgs e)
{
if (FurnitureModel == null)
{
MessageBox.Show("Выберите изделие", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (Count <= 0)
{
MessageBox.Show("Укажите количество изделия", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!_shopLogic.Sell(new() { Id = FurnitureModel.Id }, Count))
{
MessageBox.Show("Не удалось продать изделие " + FurnitureModel.FurnitureName, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
MessageBox.Show("Продажа прошла успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -40,62 +40,71 @@
this.FurnitureId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.FurnitureId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.FurnitureName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.FurnitureName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.labelMaxCount = new System.Windows.Forms.Label();
this.textBoxMaxCount = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// labelShopName // labelShopName
// //
this.labelShopName.AutoSize = true; this.labelShopName.AutoSize = true;
this.labelShopName.Location = new System.Drawing.Point(37, 45); this.labelShopName.Location = new System.Drawing.Point(53, 75);
this.labelShopName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelShopName.Name = "labelShopName"; this.labelShopName.Name = "labelShopName";
this.labelShopName.Size = new System.Drawing.Size(113, 15); this.labelShopName.Size = new System.Drawing.Size(170, 25);
this.labelShopName.TabIndex = 0; this.labelShopName.TabIndex = 0;
this.labelShopName.Text = "Название магазина"; this.labelShopName.Text = "Название магазина";
// //
// textBoxName // textBoxName
// //
this.textBoxName.Location = new System.Drawing.Point(168, 42); this.textBoxName.Location = new System.Drawing.Point(240, 70);
this.textBoxName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxName.Name = "textBoxName"; this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(282, 23); this.textBoxName.Size = new System.Drawing.Size(401, 31);
this.textBoxName.TabIndex = 1; this.textBoxName.TabIndex = 1;
// //
// textBoxAddress // textBoxAddress
// //
this.textBoxAddress.Location = new System.Drawing.Point(168, 83); this.textBoxAddress.Location = new System.Drawing.Point(240, 138);
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxAddress.Name = "textBoxAddress"; this.textBoxAddress.Name = "textBoxAddress";
this.textBoxAddress.Size = new System.Drawing.Size(282, 23); this.textBoxAddress.Size = new System.Drawing.Size(401, 31);
this.textBoxAddress.TabIndex = 3; this.textBoxAddress.TabIndex = 3;
// //
// labelAddress // labelAddress
// //
this.labelAddress.AutoSize = true; this.labelAddress.AutoSize = true;
this.labelAddress.Location = new System.Drawing.Point(37, 86); this.labelAddress.Location = new System.Drawing.Point(53, 143);
this.labelAddress.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelAddress.Name = "labelAddress"; this.labelAddress.Name = "labelAddress";
this.labelAddress.Size = new System.Drawing.Size(40, 15); this.labelAddress.Size = new System.Drawing.Size(62, 25);
this.labelAddress.TabIndex = 2; this.labelAddress.TabIndex = 2;
this.labelAddress.Text = "Адрес"; this.labelAddress.Text = "Адрес";
// //
// labelDate // labelDate
// //
this.labelDate.AutoSize = true; this.labelDate.AutoSize = true;
this.labelDate.Location = new System.Drawing.Point(37, 128); this.labelDate.Location = new System.Drawing.Point(53, 213);
this.labelDate.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelDate.Name = "labelDate"; this.labelDate.Name = "labelDate";
this.labelDate.Size = new System.Drawing.Size(87, 15); this.labelDate.Size = new System.Drawing.Size(131, 25);
this.labelDate.TabIndex = 4; this.labelDate.TabIndex = 4;
this.labelDate.Text = "Дата открытия"; this.labelDate.Text = "Дата открытия";
// //
// dateTimePicker // dateTimePicker
// //
this.dateTimePicker.Location = new System.Drawing.Point(168, 122); this.dateTimePicker.Location = new System.Drawing.Point(240, 203);
this.dateTimePicker.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dateTimePicker.Name = "dateTimePicker"; this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(282, 23); this.dateTimePicker.Size = new System.Drawing.Size(401, 31);
this.dateTimePicker.TabIndex = 6; this.dateTimePicker.TabIndex = 6;
// //
// ButtonSave // ButtonSave
// //
this.ButtonSave.Location = new System.Drawing.Point(382, 490); this.ButtonSave.Location = new System.Drawing.Point(546, 817);
this.ButtonSave.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonSave.Name = "ButtonSave"; this.ButtonSave.Name = "ButtonSave";
this.ButtonSave.Size = new System.Drawing.Size(99, 28); this.ButtonSave.Size = new System.Drawing.Size(141, 47);
this.ButtonSave.TabIndex = 7; this.ButtonSave.TabIndex = 7;
this.ButtonSave.Text = "Сохранить"; this.ButtonSave.Text = "Сохранить";
this.ButtonSave.UseVisualStyleBackColor = true; this.ButtonSave.UseVisualStyleBackColor = true;
@ -103,9 +112,10 @@
// //
// ButtonCancel // ButtonCancel
// //
this.ButtonCancel.Location = new System.Drawing.Point(509, 490); this.ButtonCancel.Location = new System.Drawing.Point(727, 817);
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonCancel.Name = "ButtonCancel"; this.ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(99, 28); this.ButtonCancel.Size = new System.Drawing.Size(141, 47);
this.ButtonCancel.TabIndex = 8; this.ButtonCancel.TabIndex = 8;
this.ButtonCancel.Text = "Отмена"; this.ButtonCancel.Text = "Отмена";
this.ButtonCancel.UseVisualStyleBackColor = true; this.ButtonCancel.UseVisualStyleBackColor = true;
@ -118,33 +128,59 @@
this.FurnitureId, this.FurnitureId,
this.FurnitureName, this.FurnitureName,
this.Count}); this.Count});
this.dataGridView1.Location = new System.Drawing.Point(37, 177); this.dataGridView1.Location = new System.Drawing.Point(53, 371);
this.dataGridView1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersWidth = 62;
this.dataGridView1.RowTemplate.Height = 25; this.dataGridView1.RowTemplate.Height = 25;
this.dataGridView1.Size = new System.Drawing.Size(571, 289); this.dataGridView1.Size = new System.Drawing.Size(816, 406);
this.dataGridView1.TabIndex = 9; this.dataGridView1.TabIndex = 9;
// //
// FurnitureId // FurnitureId
// //
this.FurnitureId.HeaderText = "Id"; this.FurnitureId.HeaderText = "Id";
this.FurnitureId.MinimumWidth = 8;
this.FurnitureId.Name = "FurnitureId"; this.FurnitureId.Name = "FurnitureId";
this.FurnitureId.Visible = false; this.FurnitureId.Visible = false;
this.FurnitureId.Width = 150;
// //
// FurnitureName // FurnitureName
// //
this.FurnitureName.HeaderText = "Название"; this.FurnitureName.HeaderText = "Название";
this.FurnitureName.MinimumWidth = 8;
this.FurnitureName.Name = "FurnitureName"; this.FurnitureName.Name = "FurnitureName";
this.FurnitureName.Width = 150;
// //
// Count // Count
// //
this.Count.HeaderText = "Количество"; this.Count.HeaderText = "Количество";
this.Count.MinimumWidth = 8;
this.Count.Name = "Count"; this.Count.Name = "Count";
this.Count.Width = 150;
//
// labelMaxCount
//
this.labelMaxCount.AutoSize = true;
this.labelMaxCount.Location = new System.Drawing.Point(58, 275);
this.labelMaxCount.Name = "labelMaxCount";
this.labelMaxCount.Size = new System.Drawing.Size(117, 25);
this.labelMaxCount.TabIndex = 10;
this.labelMaxCount.Text = "Вместимость";
//
// textBoxMaxCount
//
this.textBoxMaxCount.Location = new System.Drawing.Point(242, 267);
this.textBoxMaxCount.Name = "textBoxMaxCount";
this.textBoxMaxCount.Size = new System.Drawing.Size(399, 31);
this.textBoxMaxCount.TabIndex = 11;
// //
// FormShop // FormShop
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(631, 530); this.ClientSize = new System.Drawing.Size(901, 883);
this.Controls.Add(this.textBoxMaxCount);
this.Controls.Add(this.labelMaxCount);
this.Controls.Add(this.dataGridView1); this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.ButtonCancel); this.Controls.Add(this.ButtonCancel);
this.Controls.Add(this.ButtonSave); this.Controls.Add(this.ButtonSave);
@ -154,6 +190,7 @@
this.Controls.Add(this.labelAddress); this.Controls.Add(this.labelAddress);
this.Controls.Add(this.textBoxName); this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelShopName); this.Controls.Add(this.labelShopName);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "FormShop"; this.Name = "FormShop";
this.Text = "Магазин"; this.Text = "Магазин";
this.Load += new System.EventHandler(this.FormShop_Load); this.Load += new System.EventHandler(this.FormShop_Load);
@ -177,5 +214,7 @@
private DataGridViewTextBoxColumn FurnitureId; private DataGridViewTextBoxColumn FurnitureId;
private DataGridViewTextBoxColumn FurnitureName; private DataGridViewTextBoxColumn FurnitureName;
private DataGridViewTextBoxColumn Count; private DataGridViewTextBoxColumn Count;
private Label labelMaxCount;
private TextBox textBoxMaxCount;
} }
} }

View File

@ -45,6 +45,12 @@ namespace FurnitureAssembly
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (Convert.ToInt32(textBoxMaxCount.Text) <= 0)
{
MessageBox.Show("Некорректная вместимость", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение магазина"); _logger.LogInformation("Сохранение магазина");
try try
{ {
@ -54,7 +60,8 @@ namespace FurnitureAssembly
ShopName = textBoxName.Text, ShopName = textBoxName.Text,
Address = textBoxAddress.Text, Address = textBoxAddress.Text,
DateOpening = dateTimePicker.Value, DateOpening = dateTimePicker.Value,
Furnitures = _shopFurnitures MaxCount = Convert.ToInt32(textBoxMaxCount.Text)
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult) if (!operationResult)
@ -96,6 +103,7 @@ namespace FurnitureAssembly
textBoxName.Text = view.ShopName; textBoxName.Text = view.ShopName;
textBoxAddress.Text = view.Address.ToString(); textBoxAddress.Text = view.Address.ToString();
dateTimePicker.Value = view.DateOpening; dateTimePicker.Value = view.DateOpening;
textBoxMaxCount.Text = view.MaxCount.ToString();
_shopFurnitures = view.Furnitures ?? new _shopFurnitures = view.Furnitures ?? new
Dictionary<int, (IFurnitureModel, int)>(); Dictionary<int, (IFurnitureModel, int)>();
LoadData(); LoadData();

View File

@ -43,7 +43,6 @@ namespace FurnitureAssembly
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Furnitures"].Visible = false;
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка магазинов"); _logger.LogInformation("Загрузка магазинов");

View File

@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyBusinessLo
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyListImplement", "..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj", "{2A965D1B-CA9F-4268-A157-8A7D539FBDD2}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyListImplement", "..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj", "{2A965D1B-CA9F-4268-A157-8A7D539FBDD2}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyFileImplement", "..\FurnitureAssemblyFileImplement\FurnitureAssemblyFileImplement.csproj", "{6889AE21-61E2-4CAE-88FA-1D28125640BE}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -39,6 +41,10 @@ Global
{2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Debug|Any CPU.Build.0 = Debug|Any CPU {2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Release|Any CPU.Build.0 = Release|Any CPU {2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Release|Any CPU.Build.0 = Release|Any CPU
{6889AE21-61E2-4CAE-88FA-1D28125640BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6889AE21-61E2-4CAE-88FA-1D28125640BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6889AE21-61E2-4CAE-88FA-1D28125640BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6889AE21-61E2-4CAE-88FA-1D28125640BE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -10,10 +10,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" /> <PackageReference Include="NLog.Extensions.Logging" Version="5.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" /> <ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" />
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" /> <ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />

View File

@ -40,6 +40,7 @@
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonSell = new System.Windows.Forms.Button();
buttonReady = new System.Windows.Forms.Button(); buttonReady = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip.SuspendLayout(); this.menuStrip.SuspendLayout();
@ -62,7 +63,7 @@
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 62; this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.RowTemplate.Height = 33; this.dataGridView.RowTemplate.Height = 33;
this.dataGridView.Size = new System.Drawing.Size(1227, 386); this.dataGridView.Size = new System.Drawing.Size(1227, 441);
this.dataGridView.TabIndex = 0; this.dataGridView.TabIndex = 0;
// //
// buttonCreate // buttonCreate
@ -130,21 +131,21 @@
// компонентыToolStripMenuItem // компонентыToolStripMenuItem
// //
this.компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem"; this.компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(270, 34); this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
this.компонентыToolStripMenuItem.Text = "Компоненты"; this.компонентыToolStripMenuItem.Text = "Компоненты";
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click); this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
// //
// изделияToolStripMenuItem // изделияToolStripMenuItem
// //
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(270, 34); this.изделияToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
this.изделияToolStripMenuItem.Text = "Изделия"; this.изделияToolStripMenuItem.Text = "Изделия";
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.изделияToolStripMenuItem_Click); this.изделияToolStripMenuItem.Click += new System.EventHandler(this.изделияToolStripMenuItem_Click);
// //
// магазиныToolStripMenuItem // магазиныToolStripMenuItem
// //
this.магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem"; this.магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(270, 34); this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
this.магазиныToolStripMenuItem.Text = "Магазины"; this.магазиныToolStripMenuItem.Text = "Магазины";
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click); this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click);
// //
@ -155,11 +156,22 @@
this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина"; this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.AddToShopToolStripMenuItem_Click); this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.AddToShopToolStripMenuItem_Click);
// //
// buttonSell
//
this.buttonSell.Location = new System.Drawing.Point(1280, 450);
this.buttonSell.Name = "buttonSell";
this.buttonSell.Size = new System.Drawing.Size(208, 34);
this.buttonSell.TabIndex = 7;
this.buttonSell.Text = "Продать";
this.buttonSell.UseVisualStyleBackColor = true;
this.buttonSell.Click += new System.EventHandler(this.buttonSell_Click);
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1530, 450); this.ClientSize = new System.Drawing.Size(1530, 505);
this.Controls.Add(this.buttonSell);
this.Controls.Add(this.buttonRefresh); this.Controls.Add(this.buttonRefresh);
this.Controls.Add(this.buttonPut); this.Controls.Add(this.buttonPut);
this.Controls.Add(buttonReady); this.Controls.Add(buttonReady);
@ -192,5 +204,6 @@
private ToolStripMenuItem изделияToolStripMenuItem; private ToolStripMenuItem изделияToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem; private ToolStripMenuItem магазиныToolStripMenuItem;
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem; private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
private Button buttonSell;
} }
} }

View File

@ -123,8 +123,7 @@ namespace FurnitureAssemblyView
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try try {
{
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{ {
Id = id, Id = id,
@ -135,10 +134,8 @@ namespace FurnitureAssemblyView
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
}); });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
@ -203,41 +200,20 @@ namespace FurnitureAssemblyView
private void AddToShopToolStripMenuItem_Click(object sender, EventArgs e) private void AddToShopToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormAddToShop)); var service = Program.ServiceProvider?.GetService(typeof(FormAddToShop));
if (service is FormAddToShop form) if (service is FormAddToShop form)
{ {
if (form.ShowDialog() == DialogResult.OK) form.ShowDialog();
{ }
if (form.ShopModel == null || form.FurnitureModel == null) }
{
return;
}
_logger.LogInformation("Добавление в магазин {ShopName} изделия: { FurnitureName}- { Count}", form.ShopModel.ShopName, form.FurnitureModel.FurnitureName, form.Count);
var modelShop = new ShopBindingModel private void buttonSell_Click(object sender, EventArgs e)
{ {
Id = form.Id, var service = Program.ServiceProvider?.GetService(typeof(FormSell));
ShopName = form.ShopModel.ShopName, if (service is FormSell form)
Address = form.ShopModel.Address, {
DateOpening = form.ShopModel.DateOpening, form.ShowDialog();
}; }
var modelFurn = new FurnitureBindingModel
{
Id = form.FurnitureId,
FurnitureName = form.FurnitureModel.FurnitureName,
Price = form.FurnitureModel.Price,
FurnitureComponents = form.FurnitureModel.FurnitureComponents
};
var operationResult = _shopLogic.AddFurniture(modelShop, modelFurn, form.Count);
if (!operationResult)
{
throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах.");
}
}
}
} }
} }
} }

View File

@ -1,11 +1,11 @@
using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyContracts.StoragesContracts;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using FurnitureAssemblyFileImplement.Implements; using FurnitureAssemFileImplement.Implements;
using FurnitureAssemblyBusinessLogic.BusinessLogics; using FurnitureAssemblyBusinessLogic.BusinessLogics;
using FurnitureAssemblyContracts.BusinessLogicsContracts; using FurnitureAssemblyContracts.BusinessLogicsContracts;
using AbstractShopBusinessLogic.BusinessLogics; using ShopBusinessLogic.BusinessLogics;
using NLog.Extensions.Logging;
using FurnitureAssemblyView; using FurnitureAssemblyView;
using NLog.Extensions.Logging;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace FurnitureAssembly namespace FurnitureAssembly
@ -51,6 +51,7 @@ namespace FurnitureAssembly
services.AddTransient<FormShop>(); services.AddTransient<FormShop>();
services.AddTransient<FormShops>(); services.AddTransient<FormShops>();
services.AddTransient<FormAddToShop>(); services.AddTransient<FormAddToShop>();
services.AddTransient<FormSell>();
} }

View File

@ -4,13 +4,8 @@ using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels; using FurnitureAssemblyContracts.ViewModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractShopBusinessLogic.BusinessLogics namespace ShopBusinessLogic.BusinessLogics
{ {
public class FurnitureLogic: IfurnitureLogic public class FurnitureLogic: IfurnitureLogic
{ {

View File

@ -11,16 +11,18 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AbstractShopBusinessLogic.BusinessLogics namespace ShopBusinessLogic.BusinessLogics
{ {
public class OrderLogic : IOrderLogic public class OrderLogic : IOrderLogic
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage) private readonly IShopLogic _shopLogic;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic)
{ {
_logger = logger; _logger = logger;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_shopLogic = shopLogic;
} }
public bool CreateOrder(OrderBindingModel model) public bool CreateOrder(OrderBindingModel model)
@ -40,7 +42,11 @@ namespace AbstractShopBusinessLogic.BusinessLogics
{ {
CheckModel(model); CheckModel(model);
if (model.Status != OrderStatus.Готов) return false; if (model.Status != OrderStatus.Готов) return false;
if (!_shopLogic.AddFurnituresAtShops(new FurnitureBindingModel() { Id = model.FurnitureId }, model.Count))
{
_logger.LogWarning("There are not empty places at shops. Replenishment is impossible");
return false;
}
model.Status = OrderStatus.Выдан; model.Status = OrderStatus.Выдан;
model.DateImplement = DateTime.Now; model.DateImplement = DateTime.Now;
if (_orderStorage.Update(model) == null) if (_orderStorage.Update(model) == null)
@ -48,6 +54,7 @@ namespace AbstractShopBusinessLogic.BusinessLogics
_logger.LogWarning("Update operation failed"); _logger.LogWarning("Update operation failed");
return false; return false;
} }
return true; return true;
} }

View File

@ -10,7 +10,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AbstractShopBusinessLogic.BusinessLogics namespace ShopBusinessLogic.BusinessLogics
{ {
public class ShopLogic : IShopLogic public class ShopLogic : IShopLogic
{ {
@ -109,6 +109,10 @@ namespace AbstractShopBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException("Нет даты открытия магазина", nameof(model.DateOpening)); throw new ArgumentNullException("Нет даты открытия магазина", nameof(model.DateOpening));
} }
if (model.MaxCount <= 0)
{
throw new ArgumentNullException("Нет вместимости магазина", nameof(model.DateOpening));
}
_logger.LogInformation("Shop. ShopName:{ShopName}. Address:{ Address}. DateOpening:{ DateOpening}. Id: { Id}", model.ShopName, model.Address, model.DateOpening, model.Id); _logger.LogInformation("Shop. ShopName:{ShopName}. Address:{ Address}. DateOpening:{ DateOpening}. Id: { Id}", model.ShopName, model.Address, model.DateOpening, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName }); var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName });
if (element != null && element.Id != model.Id) if (element != null && element.Id != model.Id)
@ -126,6 +130,10 @@ namespace AbstractShopBusinessLogic.BusinessLogics
{ {
return false; return false;
} }
if (GetCountFreePlaces(model.Id) < count)
{
return false;
}
if (shop.Furnitures.ContainsKey(furniture.Id)) if (shop.Furnitures.ContainsKey(furniture.Id))
{ {
int prev_count = shop.Furnitures[furniture.Id].Item2; int prev_count = shop.Furnitures[furniture.Id].Item2;
@ -138,6 +146,7 @@ namespace AbstractShopBusinessLogic.BusinessLogics
model.Furnitures = shop.Furnitures; model.Furnitures = shop.Furnitures;
model.DateOpening = shop.DateOpening; model.DateOpening = shop.DateOpening;
model.Address = shop.Address; model.Address = shop.Address;
model.MaxCount = shop.MaxCount;
model.ShopName = shop.ShopName; model.ShopName = shop.ShopName;
if (_shopStorage.Update(model) == null) if (_shopStorage.Update(model) == null)
{ {
@ -146,5 +155,54 @@ namespace AbstractShopBusinessLogic.BusinessLogics
} }
return true; return true;
} }
private int GetCountFreePlaces(int ShopId)
{
var shop = ReadElement(new ShopSearchModel { Id = ShopId });
if (shop == null)
return 0;
int count = shop.MaxCount;
foreach (var f in shop.Furnitures)
{
count -= f.Value.Item2;
if (count <= 0)
{
return 0;
}
}
return count;
}
private int GetCountFreePlaces_All()
{
return _shopStorage.GetFullList().Select(x => GetCountFreePlaces(x.Id)).Sum();
}
public bool AddFurnituresAtShops(FurnitureBindingModel furnitureModel, int count)
{
if (GetCountFreePlaces_All() < count)
{
return false;
}
foreach (var shop in _shopStorage.GetFullList())
{
int countShop = GetCountFreePlaces(shop.Id);
if (countShop >= count)
{
AddFurniture(new() { Id = shop.Id }, furnitureModel, count);
break;
}
else
{
AddFurniture(new() { Id = shop.Id }, furnitureModel, countShop);
}
count -= countShop;
}
return true;
}
public bool Sell(FurnitureBindingModel furnitureBindingModel, int count)
{
return _shopStorage.Sell(furnitureBindingModel, count);
}
} }
} }

View File

@ -6,9 +6,9 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" /> <ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />

View File

@ -15,6 +15,7 @@ namespace FurnitureAssemblyContracts.BindingModels
public string Address { get; set; } = string.Empty; public string Address { get; set; } = string.Empty;
public DateTime DateOpening { get; set; } public DateTime DateOpening { get; set; }
public int MaxCount { get; set; }
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new(); public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
} }

View File

@ -17,5 +17,7 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
bool Update(ShopBindingModel model); bool Update(ShopBindingModel model);
bool Delete(ShopBindingModel model); bool Delete(ShopBindingModel model);
bool AddFurniture(ShopBindingModel model, FurnitureBindingModel furnitureModel, int count); bool AddFurniture(ShopBindingModel model, FurnitureBindingModel furnitureModel, int count);
bool AddFurnituresAtShops(FurnitureBindingModel furnitureModel, int count);
bool Sell(FurnitureBindingModel furnitureModel, int count);
} }
} }

View File

@ -6,6 +6,10 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj" /> <ProjectReference Include="..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -13,5 +13,6 @@ namespace FurnitureAssemblyContracts.StoragesContracts
ShopViewModel? Insert(ShopBindingModel model); ShopViewModel? Insert(ShopBindingModel model);
ShopViewModel? Update(ShopBindingModel model); ShopViewModel? Update(ShopBindingModel model);
ShopViewModel? Delete(ShopBindingModel model); ShopViewModel? Delete(ShopBindingModel model);
bool Sell(FurnitureBindingModel furnitureBindingModel, int count);
} }
} }

View File

@ -17,6 +17,8 @@ namespace FurnitureAssemblyContracts.ViewModels
public string Address { get; set; } = string.Empty; public string Address { get; set; } = string.Empty;
[DisplayName("Дата открытия")] [DisplayName("Дата открытия")]
public DateTime DateOpening { get; set; } public DateTime DateOpening { get; set; }
[DisplayName("Вместимость")]
public int MaxCount { get; set; }
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new(); public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
} }

View File

@ -6,4 +6,10 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
</Project> </Project>

View File

@ -11,6 +11,7 @@ namespace FurnitureAssemblyDataModels.Models
string ShopName { get; } string ShopName { get; }
string Address { get; } string Address { get; }
DateTime DateOpening { get; } DateTime DateOpening { get; }
int MaxCount { get; }
Dictionary<int, (IFurnitureModel, int)> Furnitures { get; } Dictionary<int, (IFurnitureModel, int)> Furnitures { get; }
} }
} }

View File

@ -1,4 +1,5 @@
using FurnitureAssemblyFileImplement.Models; using FurnitureAssemblyFileImplement.Models;
using FurnitureAssemFileImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -6,7 +7,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
namespace FurnitureAssemblyFileImplement namespace FurnitureAssemFileImplement
{ {
public class DataFileSingleton public class DataFileSingleton
{ {
@ -14,9 +15,11 @@ namespace FurnitureAssemblyFileImplement
private readonly string ComponentFileName = "Component.xml"; private readonly string ComponentFileName = "Component.xml";
private readonly string OrderFileName = "Order.xml"; private readonly string OrderFileName = "Order.xml";
private readonly string FurnitureFileName = "Furniture.xml"; private readonly string FurnitureFileName = "Furniture.xml";
private readonly string ShopFileName = "Shop.xml";
public List<Component> Components { get; private set; } public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; } public List<Order> Orders { get; private set; }
public List<Furniture> Furnitures { get; private set; } public List<Furniture> Furnitures { get; private set; }
public List<Shop> Shops { get; private set; }
public static DataFileSingleton GetInstance() public static DataFileSingleton GetInstance()
{ {
if (instance == null) if (instance == null)
@ -28,11 +31,13 @@ namespace FurnitureAssemblyFileImplement
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement); public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
public void SaveFurnitures() => SaveData(Furnitures, FurnitureFileName, "Furnitures", x => x.GetXElement); public void SaveFurnitures() => SaveData(Furnitures, FurnitureFileName, "Furnitures", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
private DataFileSingleton() private DataFileSingleton()
{ {
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!; Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
Furnitures = LoadData(FurnitureFileName, "Furniture", x => Furniture.Create(x)!)!; Furnitures = LoadData(FurnitureFileName, "Furniture", x => Furniture.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
} }
private static List<T>? LoadData<T>(string filename, string xmlNodeName, private static List<T>? LoadData<T>(string filename, string xmlNodeName,
Func<XElement, T> selectFunction) Func<XElement, T> selectFunction)

View File

@ -6,7 +6,9 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj" /> <ProjectReference Include="..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj" />
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" /> <ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />

View File

@ -2,14 +2,14 @@
using FurnitureAssemblyContracts.SearchModels; using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels; using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyFileImplement.Models; using FurnitureAssemFileImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FurnitureAssemblyFileImplement.Implements namespace FurnitureAssemFileImplement.Implements
{ {
public class ComponentStorage : IComponentStorage public class ComponentStorage : IComponentStorage
{ {

View File

@ -2,14 +2,14 @@
using FurnitureAssemblyContracts.SearchModels; using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels; using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyFileImplement.Models; using FurnitureAssemFileImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FurnitureAssemblyFileImplement.Implements namespace FurnitureAssemFileImplement.Implements
{ {
public class FurnitureStorage : IFurnitureStorage public class FurnitureStorage : IFurnitureStorage
{ {

View File

@ -2,14 +2,14 @@
using FurnitureAssemblyContracts.SearchModels; using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels; using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyFileImplement.Models; using FurnitureAssemFileImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FurnitureAssemblyFileImplement.Implements namespace FurnitureAssemFileImplement.Implements
{ {
public class OrderStorage : IOrderStorage public class OrderStorage : IOrderStorage
{ {
@ -21,7 +21,7 @@ namespace FurnitureAssemblyFileImplement.Implements
public List<OrderViewModel> GetFullList() public List<OrderViewModel> GetFullList()
{ {
return source.Orders.Select(x => GetViewModel(x)).ToList(); return source.Orders.Select(x => x.GetViewModel).ToList();
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
@ -32,8 +32,8 @@ namespace FurnitureAssemblyFileImplement.Implements
} }
return source.Orders return source.Orders
.Where(x => x.Id.Equals(model.Id)) .Where(x => x.Id.Equals(model.Id))
.Select(x => GetViewModel(x)) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
@ -44,7 +44,9 @@ namespace FurnitureAssemblyFileImplement.Implements
} }
return source.Orders return source.Orders
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel; .FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
} }
public OrderViewModel? Insert(OrderBindingModel model) public OrderViewModel? Insert(OrderBindingModel model)
@ -57,7 +59,7 @@ namespace FurnitureAssemblyFileImplement.Implements
} }
source.Orders.Add(newOrder); source.Orders.Add(newOrder);
source.SaveOrders(); source.SaveOrders();
return GetViewModel(newOrder); return newOrder.GetViewModel;
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
@ -69,7 +71,7 @@ namespace FurnitureAssemblyFileImplement.Implements
} }
order.Update(model); order.Update(model);
source.SaveOrders(); source.SaveOrders();
return GetViewModel(order); return order.GetViewModel;
} }
public OrderViewModel? Delete(OrderBindingModel model) public OrderViewModel? Delete(OrderBindingModel model)
@ -79,19 +81,9 @@ namespace FurnitureAssemblyFileImplement.Implements
{ {
source.Orders.Remove(element); source.Orders.Remove(element);
source.SaveOrders(); source.SaveOrders();
return GetViewModel(element); return element.GetViewModel;
} }
return null; return null;
} }
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
var furniture = source.Furnitures.FirstOrDefault(x => x.Id == order.FurnitureId);
if (furniture != null)
{
viewModel.FurnitureName = furniture.FurnitureName;
}
return viewModel;
}
} }
} }

View File

@ -0,0 +1,143 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemFileImplement.Implements
{
public class ShopStorage : IShopStorage
{
private readonly DataFileSingleton source;
public ShopStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<ShopViewModel> GetFullList()
{
return source.Shops.Select(x => x.GetViewModel).ToList();
}
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName))
{
return new();
}
return source.Shops.Where(x => x.ShopName.Equals(model.ShopName)).Select(x => x.GetViewModel).ToList();
}
public ShopViewModel? GetElement(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
{
return null;
}
return source.Shops.FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id) || (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName))?.GetViewModel;
}
public ShopViewModel? Insert(ShopBindingModel model)
{
model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1;
var newShop = Shop.Create(model);
if (newShop == null)
{
return null;
}
source.Shops.Add(newShop);
source.SaveShops();
return newShop.GetViewModel;
}
public ShopViewModel? Update(ShopBindingModel model)
{
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
if (shop == null)
{
return null;
}
shop.Update(model);
source.SaveShops();
return shop.GetViewModel;
}
public ShopViewModel? Delete(ShopBindingModel model)
{
var element = source.Shops.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Shops.Remove(element);
source.SaveShops();
return element.GetViewModel;
}
return null;
}
private int GetCountFurnitureAllShops(FurnitureBindingModel furniture)
{
int count = 0;
foreach (var shop in source.Shops)
{
if (shop.Furnitures.ContainsKey(furniture.Id))
{
count += shop.Furnitures[furniture.Id].Item2;
}
}
return count;
}
public bool Sell(FurnitureBindingModel furniture, int count)
{
if (GetCountFurnitureAllShops(furniture) < count)
{
return false;
}
foreach (var shop in source.Shops)
{
if (shop.Furnitures.ContainsKey(furniture.Id))
{
if (shop.Furnitures[furniture.Id].Item2 > count)
{
shop.Furnitures[furniture.Id] = (shop.Furnitures[furniture.Id].Item1, shop.Furnitures[furniture.Id].Item2 - count);
shop.Update(new ShopBindingModel
{
Id = shop.Id,
ShopName = shop.ShopName,
MaxCount = shop.MaxCount,
Furnitures = shop.Furnitures,
Address = shop.Address,
DateOpening = shop.DateOpening,
});
break;
}
count -= shop.Furnitures[furniture.Id].Item2;
shop.Furnitures[furniture.Id] = (shop.Furnitures[furniture.Id].Item1, 0);
shop.Update(new ShopBindingModel
{
Id = shop.Id,
ShopName = shop.ShopName,
MaxCount = shop.MaxCount,
Furnitures = shop.Furnitures,
Address = shop.Address,
DateOpening = shop.DateOpening,
});
}
}
source.SaveShops();
return true;
}
}
}

View File

@ -3,7 +3,7 @@ using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyDataModels.Models; using FurnitureAssemblyDataModels.Models;
using System.Xml.Linq; using System.Xml.Linq;
namespace FurnitureAssemblyFileImplement.Models namespace FurnitureAssemFileImplement.Models
{ {
public class Component : IComponentModel public class Component : IComponentModel
{ {

View File

@ -3,7 +3,7 @@ using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyDataModels.Models; using FurnitureAssemblyDataModels.Models;
using System.Xml.Linq; using System.Xml.Linq;
namespace FurnitureAssemblyFileImplement.Models namespace FurnitureAssemFileImplement.Models
{ {
public class Furniture : IFurnitureModel public class Furniture : IFurnitureModel
{ {

View File

@ -11,12 +11,14 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
namespace FurnitureAssemblyFileImplement.Models namespace FurnitureAssemFileImplement.Models
{ {
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int FurnitureId { get; private set; } public int FurnitureId { get; private set; }
public string FurnitureName { get; private set; } = string.Empty;
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
@ -39,6 +41,7 @@ namespace FurnitureAssemblyFileImplement.Models
{ {
Id = model.Id, Id = model.Id,
FurnitureId = model.FurnitureId, FurnitureId = model.FurnitureId,
FurnitureName = model.FurnitureName,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -57,6 +60,7 @@ namespace FurnitureAssemblyFileImplement.Models
{ {
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value), FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
FurnitureName = element.Element("FurnitureName")!.Value,
Count = Convert.ToInt32(element.Element("Count")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value),
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null), DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
@ -79,7 +83,12 @@ namespace FurnitureAssemblyFileImplement.Models
{ {
return; return;
} }
FurnitureId = model.FurnitureId;
FurnitureName = model.FurnitureName;
Count = model.Count;
Sum = model.Sum;
Status = model.Status; Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
} }
@ -87,6 +96,7 @@ namespace FurnitureAssemblyFileImplement.Models
{ {
Id = Id, Id = Id,
FurnitureId = FurnitureId, FurnitureId = FurnitureId,
FurnitureName = FurnitureName,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,
@ -97,6 +107,7 @@ namespace FurnitureAssemblyFileImplement.Models
public XElement GetXElement => new("Order", public XElement GetXElement => new("Order",
new XAttribute("Id", Id), new XAttribute("Id", Id),
new XElement("FurnitureId", FurnitureId), new XElement("FurnitureId", FurnitureId),
new XElement("FurnitureName", FurnitureName),
new XElement("Count", Count.ToString()), new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()), new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()), new XElement("Status", Status.ToString()),

View File

@ -0,0 +1,120 @@
using FurnitureAssemblyDataModels.Models;
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemFileImplement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace FurnitureAssemblyFileImplement.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; }
private Dictionary<int, (IFurnitureModel, int)>? _furnitures = null;
public Dictionary<int, (IFurnitureModel, int)> Furnitures
{
get
{
if (_furnitures == null)
{
var source = DataFileSingleton.GetInstance();
_furnitures = CurrentCount.ToDictionary(
x => x.Key,
y => (source.Furnitures.FirstOrDefault(z => z.Id == y.Key)! as IFurnitureModel, y.Value));
}
return _furnitures;
}
private set { }
}
public int MaxCount { get; private set; }
public Dictionary<int, int> CurrentCount { 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,
MaxCount = model.MaxCount,
CurrentCount = model.Furnitures.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Shop? Create(XElement element)
{
if (element == null)
{
return null;
}
return new()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ShopName = element.Element("ShopName")!.Value,
Address = element.Element("Address")!.Value,
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
MaxCount = Convert.ToInt32(element.Element("MaxCount")!.Value),
CurrentCount = element.Element("CurrentCount")!.Elements("CurrentCountFurniture")
.ToDictionary(
x => Convert.ToInt32(x.Element("Key")?.Value),
x => Convert.ToInt32(x.Element("Value")?.Value)
)
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Address = model.Address;
MaxCount = model.MaxCount;
DateOpening = model.DateOpening;
if (model.Furnitures.Count > 0)
{
CurrentCount = model.Furnitures.ToDictionary(x => x.Key, x => x.Value.Item2);
_furnitures = null;
}
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
DateOpening = DateOpening,
MaxCount = MaxCount,
Furnitures = Furnitures
};
public XElement GetXElement => new("Shop",
new XAttribute("Id", Id),
new XElement("ShopName", ShopName),
new XElement("Address", Address),
new XElement("DateOpening", DateOpening),
new XElement("MaxCount", MaxCount),
new XElement("CurrentCount",
CurrentCount.Select(
x => new XElement("CurrentCountFurniture", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()));
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -6,6 +6,10 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj" /> <ProjectReference Include="..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj" />
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" /> <ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />

View File

@ -109,5 +109,9 @@ namespace FurnitureAssemblyListImplement.Implements
} }
return null; return null;
} }
public bool Sell(FurnitureBindingModel furnitureBindingModel, int count)
{
throw new NotImplementedException();
}
} }
} }

View File

@ -18,6 +18,7 @@ namespace FurnitureAssemblyListImplement.Models
public string Address { get; private set; } = string.Empty; public string Address { get; private set; } = string.Empty;
public DateTime DateOpening { get; private set; } public DateTime DateOpening { get; private set; }
public int MaxCount { get; private set; }
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; private set; } = new(); public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; private set; } = new();
@ -32,6 +33,7 @@ namespace FurnitureAssemblyListImplement.Models
Id = model.Id, Id = model.Id,
ShopName = model.ShopName, ShopName = model.ShopName,
Address = model.Address, Address = model.Address,
MaxCount = model.MaxCount,
DateOpening = model.DateOpening, DateOpening = model.DateOpening,
Furnitures = model.Furnitures Furnitures = model.Furnitures
}; };
@ -45,6 +47,7 @@ namespace FurnitureAssemblyListImplement.Models
} }
ShopName = model.ShopName; ShopName = model.ShopName;
Address = model.Address; Address = model.Address;
MaxCount = model.MaxCount;
DateOpening = model.DateOpening; DateOpening = model.DateOpening;
Furnitures = model.Furnitures; Furnitures = model.Furnitures;
} }
@ -54,6 +57,7 @@ namespace FurnitureAssemblyListImplement.Models
Id = Id, Id = Id,
ShopName = ShopName, ShopName = ShopName,
Address = Address, Address = Address,
MaxCount = MaxCount,
DateOpening = DateOpening, DateOpening = DateOpening,
Furnitures = Furnitures Furnitures = Furnitures
}; };