дело сделано
This commit is contained in:
parent
f0ccd349ca
commit
ca694284f4
@ -14,9 +14,11 @@ namespace ComputersShopFileImplements
|
||||
public readonly string ComponentFileName = "Component.xml";
|
||||
public readonly string OrderFileName = "Order.xml";
|
||||
public readonly string ComputerFileName = "Computer.xml";
|
||||
public readonly string ShopFileName = "Shop.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Computer> Computers { get; private set; }
|
||||
public List<Shop> Shops { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -31,14 +33,16 @@ namespace ComputersShopFileImplements
|
||||
"Computers", 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()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Computers = LoadData(ComputerFileName, "Computer", x => Computer.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,
|
||||
Func<XElement, T> selectFunction)
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
|
@ -0,0 +1,127 @@
|
||||
using ComputersShopContracts.BindingModels;
|
||||
using ComputersShopContracts.SearchModels;
|
||||
using ComputersShopContracts.StoragesContracts;
|
||||
using ComputersShopContracts.ViewModels;
|
||||
using ComputersShopDataModels.Models;
|
||||
using ComputersShopFileImplements.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputersShopFileImplements.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> GetFiltredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Shops
|
||||
.Where(x => x.ShopName.Contains(model.Name))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Shops
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) &&
|
||||
x.ShopName == model.Name) || (model.Id.HasValue &&
|
||||
x.Id == model.Id))?.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.SaveComputers();
|
||||
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.SaveComputers();
|
||||
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.SaveComputers();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public bool CheckAvailability(int computerId, int count)
|
||||
{
|
||||
int store = source.Shops.Select(x => x.ShopComputers.Select(y => (y.Value.Item1.Id == computerId ? y.Value.Item2 : 0)).Sum()).Sum();
|
||||
return store >= count;
|
||||
}
|
||||
public bool SellComputers(IComputerModel model, int count)
|
||||
{
|
||||
var computer = source.Computers.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (computer == null || !CheckAvailability(model.Id, count))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < source.Shops.Count; i++)
|
||||
{
|
||||
var shop = source.Shops[i];
|
||||
var computers = shop.ShopComputers;
|
||||
foreach (var comp in computers.Where(x => x.Value.Item1.Id == computer.Id))
|
||||
{
|
||||
var selling = Math.Min(comp.Value.Item2, count);
|
||||
computers[comp.Value.Item1.Id] = (comp.Value.Item1, comp.Value.Item2 - selling);
|
||||
|
||||
count -= selling;
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
shop.Update(new ShopBindingModel
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
MaxCount = shop.MaxCount,
|
||||
DateOpen = shop.DateOpen,
|
||||
ShopComputers = computers
|
||||
});
|
||||
}
|
||||
source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
102
ComputersShop/ComputerShopFileImplements/Models/Shop.cs
Normal file
102
ComputersShop/ComputerShopFileImplements/Models/Shop.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using ComputersShopContracts.BindingModels;
|
||||
using ComputersShopContracts.ViewModels;
|
||||
using ComputersShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ComputersShopFileImplements.Models
|
||||
{
|
||||
public class Shop: IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShopName { get; set;}
|
||||
public string Address { get; set;}
|
||||
public DateTime DateOpen { get; set;}
|
||||
public int MaxCount { get; set;}
|
||||
public Dictionary<int, int> Computers { get; private set; } = new();
|
||||
private Dictionary<int, (IComputerModel, int)>? _shopComputers = null;
|
||||
public Dictionary<int, (IComputerModel, int)> ShopComputers
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopComputers == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_shopComputers = Computers.ToDictionary(x => x.Key, y => ((source.Computers.FirstOrDefault(z => z.Id == y.Key) as IComputerModel)!, y.Value));
|
||||
}
|
||||
return _shopComputers;
|
||||
}
|
||||
}
|
||||
public static Shop? Create(ShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
MaxCount = model.MaxCount,
|
||||
DateOpen = model.DateOpen,
|
||||
Computers = model.ShopComputers.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||
};
|
||||
}
|
||||
public static Shop? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
MaxCount = Convert.ToInt32(element.Element("MaxCount")!.Value),
|
||||
ShopName = element.Element("ShopName")!.Value,
|
||||
Address = element.Element("Address")!.Value,
|
||||
DateOpen = Convert.ToDateTime(element.Element("DateOpen")!.Value),
|
||||
|
||||
Computers = element.Element("ShopComputers")!.Elements("ShopComputer").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;
|
||||
DateOpen = model.DateOpen;
|
||||
if (model.ShopComputers.Count > 0)
|
||||
{
|
||||
Computers = model.ShopComputers.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_shopComputers = null;
|
||||
}
|
||||
}
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
MaxCount = MaxCount,
|
||||
DateOpen = DateOpen,
|
||||
ShopComputers = ShopComputers
|
||||
};
|
||||
public XElement GetXElement => new("Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Address", Address.ToString()),
|
||||
new XElement("MaxCount", MaxCount.ToString()),
|
||||
new XElement("DateOpen", DateOpen.ToString()),
|
||||
new XElement("ShopComputers", Computers.Select(x => new XElement("ShopComputer", new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value))).ToArray()));
|
||||
}
|
||||
}
|
20
ComputersShop/ComputersShop/FormMain.Designer.cs
generated
20
ComputersShop/ComputersShop/FormMain.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonSupplyShop = new Button();
|
||||
buttonSell = new Button();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -63,21 +64,21 @@
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(180, 22);
|
||||
компонентыToolStripMenuItem.Size = new Size(145, 22);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// комьютерыToolStripMenuItem
|
||||
//
|
||||
комьютерыToolStripMenuItem.Name = "комьютерыToolStripMenuItem";
|
||||
комьютерыToolStripMenuItem.Size = new Size(180, 22);
|
||||
комьютерыToolStripMenuItem.Size = new Size(145, 22);
|
||||
комьютерыToolStripMenuItem.Text = "Комьютеры";
|
||||
комьютерыToolStripMenuItem.Click += КомпьютерыToolStripMenuItem_Click;
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
магазиныToolStripMenuItem.Size = new Size(180, 22);
|
||||
магазиныToolStripMenuItem.Size = new Size(145, 22);
|
||||
магазиныToolStripMenuItem.Text = "Магазины";
|
||||
магазиныToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click;
|
||||
//
|
||||
@ -157,11 +158,22 @@
|
||||
buttonSupplyShop.UseVisualStyleBackColor = true;
|
||||
buttonSupplyShop.Click += buttonSupplyShop_Click;
|
||||
//
|
||||
// buttonSell
|
||||
//
|
||||
buttonSell.Location = new Point(792, 387);
|
||||
buttonSell.Name = "buttonSell";
|
||||
buttonSell.Size = new Size(180, 35);
|
||||
buttonSell.TabIndex = 8;
|
||||
buttonSell.Text = "Продажа";
|
||||
buttonSell.UseVisualStyleBackColor = true;
|
||||
buttonSell.Click += buttonSell_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(984, 450);
|
||||
Controls.Add(buttonSell);
|
||||
Controls.Add(buttonSupplyShop);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
@ -173,6 +185,7 @@
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
Text = "Компьютерный магазин";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
@ -194,5 +207,6 @@
|
||||
private Button buttonUpdate;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private Button buttonSupplyShop;
|
||||
private Button buttonSell;
|
||||
}
|
||||
}
|
@ -115,10 +115,12 @@ namespace ComputersShop
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var computerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ComputerId"].Value);
|
||||
var count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value);
|
||||
_logger.LogInformation("Order №{id}. Status changes to 'Готов'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id, ComputerId = computerId, Count = count });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
@ -170,5 +172,14 @@ namespace ComputersShop
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSell_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSell));
|
||||
if (service is FormSell form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
119
ComputersShop/ComputersShop/FormSell.Designer.cs
generated
Normal file
119
ComputersShop/ComputersShop/FormSell.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace ComputersShop
|
||||
{
|
||||
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()
|
||||
{
|
||||
labelComputer = new Label();
|
||||
comboBoxComputer = new ComboBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxCount = new TextBox();
|
||||
labelCount = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelComputer
|
||||
//
|
||||
labelComputer.AutoSize = true;
|
||||
labelComputer.Location = new Point(12, 9);
|
||||
labelComputer.Name = "labelComputer";
|
||||
labelComputer.Size = new Size(74, 15);
|
||||
labelComputer.TabIndex = 23;
|
||||
labelComputer.Text = "Компьютер:";
|
||||
//
|
||||
// comboBoxComputer
|
||||
//
|
||||
comboBoxComputer.FormattingEnabled = true;
|
||||
comboBoxComputer.Location = new Point(90, 6);
|
||||
comboBoxComputer.Margin = new Padding(3, 2, 3, 2);
|
||||
comboBoxComputer.Name = "comboBoxComputer";
|
||||
comboBoxComputer.Size = new Size(280, 23);
|
||||
comboBoxComputer.TabIndex = 22;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(270, 70);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(100, 30);
|
||||
buttonCancel.TabIndex = 19;
|
||||
buttonCancel.Text = "Отменить";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(160, 70);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(100, 30);
|
||||
buttonSave.TabIndex = 18;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(90, 34);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(280, 23);
|
||||
textBoxCount.TabIndex = 17;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(12, 37);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(75, 15);
|
||||
labelCount.TabIndex = 16;
|
||||
labelCount.Text = "Количество:";
|
||||
//
|
||||
// FormSell
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(385, 116);
|
||||
Controls.Add(labelComputer);
|
||||
Controls.Add(comboBoxComputer);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(labelCount);
|
||||
Name = "FormSell";
|
||||
Text = "FormSell";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelComputer;
|
||||
private ComboBox comboBoxComputer;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxCount;
|
||||
private Label labelCount;
|
||||
}
|
||||
}
|
124
ComputersShop/ComputersShop/FormSell.cs
Normal file
124
ComputersShop/ComputersShop/FormSell.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using ComputersShopContracts.BuisnessLogicsContracts;
|
||||
using ComputersShopContracts.BusinessLogicsContracts;
|
||||
using ComputersShopContracts.ViewModels;
|
||||
using ComputersShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ComputersShop
|
||||
{
|
||||
public partial class FormSell : Form
|
||||
{
|
||||
private readonly List<ComputerViewModel>? _computerList;
|
||||
IShopLogic _shopLogic;
|
||||
IComputerLogic _computerLogic;
|
||||
public FormSell(IComputerLogic computerLogic, IShopLogic shopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_computerLogic = computerLogic;
|
||||
_shopLogic = shopLogic;
|
||||
_computerList = computerLogic.ReadList(null);
|
||||
if (_computerList != null)
|
||||
{
|
||||
comboBoxComputer.DisplayMember = "ComputerName";
|
||||
comboBoxComputer.ValueMember = "Id";
|
||||
comboBoxComputer.DataSource = _computerList;
|
||||
comboBoxComputer.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int ComputerId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxComputer.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxComputer.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IComputerModel? ComputerModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_computerList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _computerList)
|
||||
{
|
||||
if (elem.Id == ComputerId)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(textBoxCount.Text);
|
||||
}
|
||||
set
|
||||
{
|
||||
textBoxCount.Text = value.ToString();
|
||||
}
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxComputer.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите компьютер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
|
||||
bool res = _shopLogic.MakeSell(_computerLogic.ReadElement(new()
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxComputer.SelectedValue)
|
||||
}),
|
||||
count
|
||||
);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
throw new Exception("Ошибка при продаже.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Продажа прошла успешно");
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
MessageBox.Show("Ошибка продажи");
|
||||
return;
|
||||
}
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
ComputersShop/ComputersShop/FormSell.resx
Normal file
60
ComputersShop/ComputersShop/FormSell.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>
|
32
ComputersShop/ComputersShop/FormShop.Designer.cs
generated
32
ComputersShop/ComputersShop/FormShop.Designer.cs
generated
@ -40,7 +40,10 @@
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxAddress = new TextBox();
|
||||
labelMaxCount = new Label();
|
||||
numericUpDownMaxCount = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxCount).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxName
|
||||
@ -91,7 +94,7 @@
|
||||
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnComputer, ColumnCount });
|
||||
dataGridView.Location = new Point(12, 110);
|
||||
dataGridView.Location = new Point(12, 160);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
@ -123,7 +126,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(447, 369);
|
||||
buttonCancel.Location = new Point(445, 420);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(100, 30);
|
||||
buttonCancel.TabIndex = 19;
|
||||
@ -133,7 +136,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(337, 369);
|
||||
buttonSave.Location = new Point(335, 420);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(100, 30);
|
||||
buttonSave.TabIndex = 18;
|
||||
@ -148,11 +151,29 @@
|
||||
textBoxAddress.Size = new Size(235, 23);
|
||||
textBoxAddress.TabIndex = 20;
|
||||
//
|
||||
// labelMaxCount
|
||||
//
|
||||
labelMaxCount.AutoSize = true;
|
||||
labelMaxCount.Location = new Point(12, 108);
|
||||
labelMaxCount.Name = "labelMaxCount";
|
||||
labelMaxCount.Size = new Size(80, 15);
|
||||
labelMaxCount.TabIndex = 21;
|
||||
labelMaxCount.Text = "Макс. кол-во";
|
||||
//
|
||||
// numericUpDownMaxCount
|
||||
//
|
||||
numericUpDownMaxCount.Location = new Point(105, 105);
|
||||
numericUpDownMaxCount.Name = "numericUpDownMaxCount";
|
||||
numericUpDownMaxCount.Size = new Size(235, 23);
|
||||
numericUpDownMaxCount.TabIndex = 22;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(559, 411);
|
||||
ClientSize = new Size(559, 461);
|
||||
Controls.Add(numericUpDownMaxCount);
|
||||
Controls.Add(labelMaxCount);
|
||||
Controls.Add(textBoxAddress);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
@ -166,6 +187,7 @@
|
||||
Text = "Магазин";
|
||||
Load += FormShop_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxCount).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -184,5 +206,7 @@
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxAddress;
|
||||
private Label labelMaxCount;
|
||||
private NumericUpDown numericUpDownMaxCount;
|
||||
}
|
||||
}
|
@ -46,6 +46,7 @@ namespace ComputersShop
|
||||
textBoxName.Text = shop.ShopName;
|
||||
textBoxAddress.Text = shop.Address;
|
||||
DateTimePickerDateOpen.Value = shop.DateOpen;
|
||||
numericUpDownMaxCount.Value = shop.MaxCount;
|
||||
_shopComputers = shop.ShopComputers ?? new Dictionary<int, (IComputerModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
@ -104,6 +105,7 @@ namespace ComputersShop
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpen = DateTimePickerDateOpen.Value,
|
||||
MaxCount = (int)numericUpDownMaxCount.Value,
|
||||
ShopComputers = _shopComputers
|
||||
};
|
||||
|
||||
|
@ -66,4 +66,13 @@
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnComputer.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -62,7 +62,7 @@
|
||||
//
|
||||
textBoxCount.Location = new Point(90, 64);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(282, 23);
|
||||
textBoxCount.Size = new Size(280, 23);
|
||||
textBoxCount.TabIndex = 9;
|
||||
//
|
||||
// labelCount
|
||||
|
12
ComputersShop/ComputersShop/FormShops.Designer.cs
generated
12
ComputersShop/ComputersShop/FormShops.Designer.cs
generated
@ -41,7 +41,7 @@
|
||||
//
|
||||
// buttonReload
|
||||
//
|
||||
buttonReload.Location = new Point(332, 123);
|
||||
buttonReload.Location = new Point(432, 123);
|
||||
buttonReload.Name = "buttonReload";
|
||||
buttonReload.Size = new Size(140, 30);
|
||||
buttonReload.TabIndex = 13;
|
||||
@ -51,7 +51,7 @@
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(332, 87);
|
||||
buttonDelete.Location = new Point(432, 87);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(140, 30);
|
||||
buttonDelete.TabIndex = 12;
|
||||
@ -61,7 +61,7 @@
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(332, 51);
|
||||
buttonUpdate.Location = new Point(432, 51);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(140, 30);
|
||||
buttonUpdate.TabIndex = 11;
|
||||
@ -71,7 +71,7 @@
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(332, 15);
|
||||
buttonAdd.Location = new Point(432, 15);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(140, 30);
|
||||
buttonAdd.TabIndex = 10;
|
||||
@ -117,14 +117,14 @@
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(300, 361);
|
||||
dataGridView.Size = new Size(400, 361);
|
||||
dataGridView.TabIndex = 9;
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(484, 361);
|
||||
ClientSize = new Size(584, 361);
|
||||
Controls.Add(buttonReload);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
|
@ -55,6 +55,7 @@ namespace ComputersShop
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormShopSupply>();
|
||||
services.AddTransient<FormSell>();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
using ComputersShopContracts.BindingModels;
|
||||
using ComputersShopContracts.BuisnessLogicsContracts;
|
||||
using ComputersShopContracts.BusinessLogicsContracts;
|
||||
using ComputersShopContracts.SearchModels;
|
||||
using ComputersShopContracts.StoragesContracts;
|
||||
using ComputersShopContracts.ViewModels;
|
||||
using ComputersShopDataModels.Enums;
|
||||
using ComputersShopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -17,10 +19,18 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly IComputerStorage _computerStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage,
|
||||
IShopStorage shopStorage, IShopLogic shopLogic, IComputerStorage computerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopStorage = shopStorage;
|
||||
_shopLogic = shopLogic;
|
||||
_computerStorage = computerStorage;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
@ -63,25 +73,26 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newStatus == OrderStatus.Готов)
|
||||
{
|
||||
var computer = _computerStorage.GetElement(new ComputerSearchModel() { Id = model.ComputerId });
|
||||
if (computer == null)
|
||||
{
|
||||
_logger.LogWarning("Status change error. Dress not found");
|
||||
return false;
|
||||
}
|
||||
if (!CheckSupply(computer, model.Count))
|
||||
{
|
||||
_logger.LogWarning("Status change error. Shop doesnt have dresses");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
model.Status = newStatus;
|
||||
model.ComputerId = viewModel.ComputerId;
|
||||
model.Count = viewModel.Count;
|
||||
model.Sum = viewModel.Sum;
|
||||
model.DateCreate = viewModel.DateCreate;
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.DateImplement = viewModel.DateImplement;
|
||||
}
|
||||
CheckModel(model, false);
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Status change operation failed");
|
||||
return false;
|
||||
}
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
@ -120,5 +131,64 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
||||
}
|
||||
_logger.LogInformation("Order. Id:{Id}. Sum:{Sum}. ComputerId:{ComputerId}", model.Id, model.Sum, model.ComputerId);
|
||||
}
|
||||
public bool CheckSupply(IComputerModel computer, int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
_logger.LogWarning("Check supply operation error. Dress count < 0");
|
||||
return false;
|
||||
}
|
||||
int sumCapacity = _shopStorage.GetFullList().Select(x => x.MaxCount).Sum();
|
||||
int sumCount = _shopStorage.GetFullList().Select(x => x.ShopComputers.Select(y => y.Value.Item2).Sum()).Sum();
|
||||
int free = sumCapacity - sumCount;
|
||||
|
||||
if (free < count)
|
||||
{
|
||||
_logger.LogWarning("Check supply error. No place for new Computers");
|
||||
return false;
|
||||
}
|
||||
foreach (var shop in _shopStorage.GetFullList())
|
||||
{
|
||||
free = shop.MaxCount;
|
||||
foreach (var comp in shop.ShopComputers)
|
||||
{
|
||||
free -= comp.Value.Item2;
|
||||
}
|
||||
if (free == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (free >= count)
|
||||
{
|
||||
if (_shopLogic.SupplyComputers(new()
|
||||
{
|
||||
Id = shop.Id
|
||||
}, computer, count))
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Supply error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_shopLogic.SupplyComputers(new() { Id = shop.Id }, computer, free))
|
||||
count -= free;
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Supply error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,6 +114,10 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
public bool MakeSell(IComputerModel model, int count)
|
||||
{
|
||||
return _shopStorage.SellComputers(model, count);
|
||||
}
|
||||
|
||||
public bool SupplyComputers(ShopSearchModel model, IComputerModel computer, int count)
|
||||
{
|
||||
@ -137,6 +141,13 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
||||
}
|
||||
_logger.LogInformation("Make Supply. Id: {Id}. ShopName: {Name}", model.Id, model.Name);
|
||||
|
||||
var countItems = currentShop.ShopComputers.Select(x => x.Value.Item2).Sum();
|
||||
if (currentShop.MaxCount - countItems < count)
|
||||
{
|
||||
_logger.LogWarning("Shop is full");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentShop.ShopComputers.TryGetValue(computer.Id, out var pair))
|
||||
{
|
||||
currentShop.ShopComputers[computer.Id] = (pair.Item1, pair.Item2 + count);
|
||||
@ -154,6 +165,7 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
||||
ShopName = currentShop.ShopName,
|
||||
DateOpen = currentShop.DateOpen,
|
||||
Address = currentShop.Address,
|
||||
MaxCount = currentShop.MaxCount,
|
||||
ShopComputers = currentShop.ShopComputers,
|
||||
});
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace ComputersShopContracts.BindingModels
|
||||
public string ShopName { get; set; }
|
||||
public string Address { get; set; }
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
public int MaxCount { get; set; }
|
||||
public Dictionary<int, (IComputerModel, int)> ShopComputers{ get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,6 @@ namespace ComputersShopContracts.BusinessLogicsContracts
|
||||
bool Update(ShopBindingModel model);
|
||||
bool Delete(ShopBindingModel model);
|
||||
bool SupplyComputers(ShopSearchModel model, IComputerModel computer, int count);
|
||||
bool MakeSell(IComputerModel model, int count);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using ComputersShopContracts.BindingModels;
|
||||
using ComputersShopContracts.SearchModels;
|
||||
using ComputersShopContracts.ViewModels;
|
||||
using ComputersShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -17,5 +18,6 @@ namespace ComputersShopContracts.StoragesContracts
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
bool SellComputers(IComputerModel model, int count);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ namespace ComputersShopContracts.ViewModels
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
[DisplayName("Макс кол-во компьютеров")]
|
||||
public int MaxCount { get; set; }
|
||||
|
||||
public Dictionary<int, (IComputerModel, int)> ShopComputers { get; set; } = new();
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ namespace ComputersShopDataModels.Models
|
||||
string ShopName { get; }
|
||||
string Address { get; }
|
||||
DateTime DateOpen { get; }
|
||||
int MaxCount { get; }
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using ComputersShopContracts.SearchModels;
|
||||
using ComputersShopContracts.StoragesContracts;
|
||||
using ComputersShopContracts.ViewModels;
|
||||
using ComputersShopDataModels.Models;
|
||||
using ComputersShopListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -102,5 +103,13 @@ namespace ComputersShopListImplement.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public bool CheckAvailability(int computerId, int count)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public bool SellComputers(IComputerModel model, int count)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ namespace ComputersShopListImplement.Models
|
||||
public string ShopName { get; private set; }
|
||||
public string Address { get; private set; }
|
||||
public DateTime DateOpen { get; private set; }
|
||||
public int MaxCount { get; private set; }
|
||||
public Dictionary<int, (IComputerModel, int)> ShopComputers { get; private set; } = new();
|
||||
|
||||
public static Shop? Create(ShopBindingModel model)
|
||||
@ -29,6 +30,7 @@ namespace ComputersShopListImplement.Models
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
MaxCount = model.MaxCount,
|
||||
ShopComputers = new()
|
||||
};
|
||||
}
|
||||
@ -41,6 +43,7 @@ namespace ComputersShopListImplement.Models
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
MaxCount = model.MaxCount;
|
||||
ShopComputers = model.ShopComputers;
|
||||
}
|
||||
|
||||
@ -50,6 +53,7 @@ namespace ComputersShopListImplement.Models
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
MaxCount = MaxCount,
|
||||
ShopComputers = ShopComputers
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user