This commit is contained in:
shadowik 2023-02-16 07:52:03 +03:00
parent 5b89ca4a8b
commit 09978b4cee
69 changed files with 866 additions and 893 deletions

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankExecutorDataModels.Models
{
public interface IProductModel : IId
{
string ProductName { get; }
double Price { get; }
Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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

@ -1,111 +0,0 @@
using Microsoft.Extensions.Logging;
using BankExecutorContracts.BindingModels;
using BankExecutorContracts.BusinessLogicsContracts;
using BankExecutorContracts.SearchModels;
using BankExecutorContracts.StoragesContracts;
using BankExecutorContracts.ViewModels;
namespace BankExecutorBusinessLogic.BusinessLogics
{
public class ProductLogic : IProductLogic
{
private readonly ILogger _logger;
private readonly IProductStorage _ProductStorage;
public ProductLogic(ILogger<ProductLogic> logger, IProductStorage ProductStorage)
{
_logger = logger;
_ProductStorage= ProductStorage;
}
public List<ProductViewModel>? ReadList(ProductSearchModel? model)
{
_logger.LogInformation("ReadList. ProductName:{ProductName}.Id:{ Id}", model?.ProductName, model?.Id);
var list = model == null ? _ProductStorage.GetFullList() : _ProductStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ProductViewModel? ReadElement(ProductSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ProductName:{ProductName}.Id:{ Id}", model.ProductName, model.Id);
var element = _ProductStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(ProductBindingModel model)
{
CheckModel(model);
if (_ProductStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ProductBindingModel model)
{
CheckModel(model);
if (_ProductStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ProductBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_ProductStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(ProductBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ProductName))
{
throw new ArgumentNullException("Нет названия изделия", nameof(model.ProductName));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
}
if(model.ProductComponents==null || model.ProductComponents.Count == 0)
{
throw new ArgumentNullException("Перечень компонентов не может быть пустым", nameof(model.ProductComponents));
}
_logger.LogInformation("Product. ProductName:{ProductName}.Price:{Price}.Id: { Id}", model.ProductName, model.Price, model.Id);
var element = _ProductStorage.GetElement(new ProductSearchModel
{
ProductName = model.ProductName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Изделие с таким названием уже есть");
}
}
}
}

View File

@ -1,13 +0,0 @@
using BankExecutorDataModels.Models;
namespace BankExecutorContracts.BindingModels
{
public class ProductBindingModel : IProductModel
{
public int Id { get; set; }
public string ProductName { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
}
}

View File

@ -1,15 +0,0 @@
using BankExecutorContracts.BindingModels;
using BankExecutorContracts.SearchModels;
using BankExecutorContracts.ViewModels;
namespace BankExecutorContracts.BusinessLogicsContracts
{
public interface IProductLogic
{
List<ProductViewModel>? ReadList(ProductSearchModel? model);
ProductViewModel? ReadElement(ProductSearchModel model);
bool Create(ProductBindingModel model);
bool Update(ProductBindingModel model);
bool Delete(ProductBindingModel model);
}
}

View File

@ -1,8 +0,0 @@
namespace BankExecutorContracts.SearchModels
{
public class ProductSearchModel
{
public int? Id { get; set; }
public string? ProductName { get; set; }
}
}

View File

@ -1,16 +0,0 @@
using BankExecutorContracts.BindingModels;
using BankExecutorContracts.SearchModels;
using BankExecutorContracts.ViewModels;
namespace BankExecutorContracts.StoragesContracts
{
public interface IProductStorage
{
List<ProductViewModel> GetFullList();
List<ProductViewModel> GetFilteredList(ProductSearchModel model);
ProductViewModel? GetElement(ProductSearchModel model);
ProductViewModel? Insert(ProductBindingModel model);
ProductViewModel? Update(ProductBindingModel model);
ProductViewModel? Delete(ProductBindingModel model);
}
}

View File

@ -1,15 +0,0 @@
using BankExecutorDataModels.Models;
using System.ComponentModel;
namespace BankExecutorContracts.ViewModels
{
public class ProductViewModel : IProductModel
{
public int Id { get; set; }
[DisplayName("Название изделия")]
public string ProductName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get;set;} = new();
}
}

View File

@ -1,101 +0,0 @@
using BankExecutorContracts.BindingModels;
using BankExecutorContracts.SearchModels;
using BankExecutorContracts.StoragesContracts;
using BankExecutorContracts.ViewModels;
using BankExecutorListImplement.Models;
namespace BankExecutorListImplement.Implements
{
public class ProductStorage : IProductStorage
{
private readonly DataListSingleton _source;
public ProductStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<ProductViewModel> GetFullList()
{
var result = new List<ProductViewModel>();
foreach (var products in _source.Products)
{
result.Add(products.GetViewModel);
}
return result;
}
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
{
var result = new List<ProductViewModel>();
if (string.IsNullOrEmpty(model.ProductName))
{
return result;
}
foreach (var products in _source.Products)
{
if (products.ProductName.Contains(model.ProductName))
{
result.Add(products.GetViewModel);
}
}
return result;
}
public ProductViewModel? GetElement(ProductSearchModel model)
{
if (string.IsNullOrEmpty(model.ProductName) && !model.Id.HasValue)
{
return null;
}
foreach (var products in _source.Products)
{
if ((!string.IsNullOrEmpty(model.ProductName) && products.ProductName == model.ProductName) ||
(model.Id.HasValue && products.Id == model.Id))
{
return products.GetViewModel;
}
}
return null;
}
public ProductViewModel? Insert(ProductBindingModel model)
{
model.Id = 1;
foreach (var products in _source.Products)
{
if (model.Id <= products.Id)
{
model.Id = products.Id + 1;
}
}
var newProducts = Product.Create(model);
if (newProducts == null)
{
return null;
}
_source.Products.Add(newProducts);
return newProducts.GetViewModel;
}
public ProductViewModel? Update(ProductBindingModel model)
{
foreach (var products in _source.Products)
{
if (products.Id == model.Id)
{
products.Update(model);
return products.GetViewModel;
}
}
return null;
}
public ProductViewModel? Delete(ProductBindingModel model)
{
for (int i = 0; i < _source.Products.Count; ++i)
{
if (_source.Products[i].Id == model.Id)
{
var element = _source.Products[i];
_source.Products.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -1,45 +0,0 @@
using BankExecutorContracts.BindingModels;
using BankExecutorContracts.ViewModels;
using BankExecutorDataModels.Models;
namespace BankExecutorListImplement.Models
{
public class Product : IProductModel
{
public int Id { get; private set; }
public string ProductName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; private set;} = new Dictionary<int, (IComponentModel, int)>();
public static Product? Create(ProductBindingModel? model)
{
if (model == null)
{
return null;
}
return new Product()
{
Id = model.Id,
ProductName = model.ProductName,
Price = model.Price,
ProductComponents = model.ProductComponents,
};
}
public void Update(ProductBindingModel? model)
{
if (model == null)
{
return;
}
ProductName = model.ProductName;
Price = model.Price;
ProductComponents = model.ProductComponents;
}
public ProductViewModel GetViewModel => new()
{
Id = Id,
ProductName = ProductName,
Price = Price,
ProductComponents = ProductComponents
};
}
}

View File

@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248 VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorView", "BankExecutor\BankExecutorView.csproj", "{88CAFAB3-C95B-4118-896A-10794A1C5FBE}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaView", "Pizzeria\PizzeriaView.csproj", "{88CAFAB3-C95B-4118-896A-10794A1C5FBE}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorDataModels", "AbstractBankDataModels\BankExecutorDataModels.csproj", "{03B275B6-CF13-4B65-973F-059CA2A4709D}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaDataModels", "PizzeriaDataModels\PizzeriaDataModels.csproj", "{03B275B6-CF13-4B65-973F-059CA2A4709D}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorContracts", "BankExecutorContracts\BankExecutorContracts.csproj", "{1FBD781D-AF16-42DE-AE09-E99B898EA0AE}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaContracts", "PizzeriaContracts\PizzeriaContracts.csproj", "{1FBD781D-AF16-42DE-AE09-E99B898EA0AE}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorBusinessLogic", "BankExecutorBusinessLogic\BankExecutorBusinessLogic.csproj", "{6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaBusinessLogic", "PizzeriaBusinessLogic\PizzeriaBusinessLogic.csproj", "{6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorListImplement", "BankExecutorListImplement\BankExecutorListImplement.csproj", "{17269B24-6A77-4C45-B3DD-AA444F22D9B8}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaListImplement", "PizzeriaListImplement\PizzeriaListImplement.csproj", "{17269B24-6A77-4C45-B3DD-AA444F22D9B8}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -1,4 +1,4 @@
namespace BankExecutorView namespace PizzeriaView
{ {
partial class FormComponent partial class FormComponent
{ {
@ -39,40 +39,43 @@
// labelName // labelName
// //
this.labelName.AutoSize = true; this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(12, 9); this.labelName.Location = new System.Drawing.Point(10, 7);
this.labelName.Name = "labelName"; this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(80, 20); this.labelName.Size = new System.Drawing.Size(62, 15);
this.labelName.TabIndex = 0; this.labelName.TabIndex = 0;
this.labelName.Text = "Название:"; this.labelName.Text = "Название:";
// //
// textBoxName // textBoxName
// //
this.textBoxName.Location = new System.Drawing.Point(98, 9); this.textBoxName.Location = new System.Drawing.Point(86, 7);
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxName.Name = "textBoxName"; this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(366, 27); this.textBoxName.Size = new System.Drawing.Size(321, 23);
this.textBoxName.TabIndex = 1; this.textBoxName.TabIndex = 1;
// //
// textBoxCost // textBoxCost
// //
this.textBoxCost.Location = new System.Drawing.Point(98, 42); this.textBoxCost.Location = new System.Drawing.Point(86, 32);
this.textBoxCost.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxCost.Name = "textBoxCost"; this.textBoxCost.Name = "textBoxCost";
this.textBoxCost.Size = new System.Drawing.Size(133, 27); this.textBoxCost.Size = new System.Drawing.Size(117, 23);
this.textBoxCost.TabIndex = 3; this.textBoxCost.TabIndex = 3;
// //
// labelCost // labelCost
// //
this.labelCost.AutoSize = true; this.labelCost.AutoSize = true;
this.labelCost.Location = new System.Drawing.Point(12, 42); this.labelCost.Location = new System.Drawing.Point(10, 32);
this.labelCost.Name = "labelCost"; this.labelCost.Name = "labelCost";
this.labelCost.Size = new System.Drawing.Size(45, 20); this.labelCost.Size = new System.Drawing.Size(35, 15);
this.labelCost.TabIndex = 2; this.labelCost.TabIndex = 2;
this.labelCost.Text = "Цена"; this.labelCost.Text = "Цена";
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(171, 90); this.buttonSave.Location = new System.Drawing.Point(150, 68);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave"; this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(130, 40); this.buttonSave.Size = new System.Drawing.Size(114, 30);
this.buttonSave.TabIndex = 4; this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить"; this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseVisualStyleBackColor = true;
@ -80,9 +83,10 @@
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(328, 90); this.buttonCancel.Location = new System.Drawing.Point(287, 68);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(136, 40); this.buttonCancel.Size = new System.Drawing.Size(119, 30);
this.buttonCancel.TabIndex = 5; this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена"; this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.UseVisualStyleBackColor = true;
@ -90,17 +94,18 @@
// //
// FormComponent // FormComponent
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(478, 142); this.ClientSize = new System.Drawing.Size(418, 106);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxCost); this.Controls.Add(this.textBoxCost);
this.Controls.Add(this.labelCost); this.Controls.Add(this.labelCost);
this.Controls.Add(this.textBoxName); this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelName); this.Controls.Add(this.labelName);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormComponent"; this.Name = "FormComponent";
this.Text = "Компонент"; this.Text = "Ингридиент";
this.Load += new System.EventHandler(this.FormComponent_Load); this.Load += new System.EventHandler(this.FormComponent_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -1,10 +1,10 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using System.Windows.Forms; using System.Windows.Forms;
namespace BankExecutorView namespace PizzeriaView
{ {
public partial class FormComponent : Form public partial class FormComponent : Form
{ {
@ -24,7 +24,7 @@ namespace BankExecutorView
{ {
try try
{ {
_logger.LogInformation("Получение компонента"); _logger.LogInformation("Получение ингридиента");
var view = _logic.ReadElement(new ComponentSearchModel var view = _logic.ReadElement(new ComponentSearchModel
{ {
Id = _id.Value Id = _id.Value
@ -37,7 +37,7 @@ namespace BankExecutorView
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения компонента"); _logger.LogError(ex, "Ошибка получения ингридиента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
@ -49,7 +49,7 @@ namespace BankExecutorView
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Сохранение компонента"); _logger.LogInformation("Сохранение ингридиента");
try try
{ {
var model = new ComponentBindingModel var model = new ComponentBindingModel
@ -69,7 +69,7 @@ namespace BankExecutorView
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка сохранения компонента"); _logger.LogError(ex, "Ошибка сохранения ингридиента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,MessageBoxIcon.Error);
} }
} }

View File

@ -1,4 +1,4 @@
namespace BankExecutorView namespace PizzeriaView
{ {
partial class FormComponents partial class FormComponents
{ {
@ -30,9 +30,9 @@
{ {
this.dataGridView = new System.Windows.Forms.DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.ToolsPanel = new System.Windows.Forms.Panel(); this.ToolsPanel = new System.Windows.Forms.Panel();
this.buttonRef = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button(); this.buttonDelete = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button(); this.buttonEdit = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.ToolsPanel.SuspendLayout(); this.ToolsPanel.SuspendLayout();
@ -43,60 +43,66 @@
this.dataGridView.AllowUserToAddRows = false; this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false; this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 12); this.dataGridView.Location = new System.Drawing.Point(10, 9);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true; this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29; this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(590, 426); this.dataGridView.Size = new System.Drawing.Size(516, 320);
this.dataGridView.TabIndex = 0; this.dataGridView.TabIndex = 0;
// //
// ToolsPanel // ToolsPanel
// //
this.ToolsPanel.Controls.Add(this.buttonRef); this.ToolsPanel.Controls.Add(this.buttonUpdate);
this.ToolsPanel.Controls.Add(this.buttonDel); this.ToolsPanel.Controls.Add(this.buttonDelete);
this.ToolsPanel.Controls.Add(this.buttonUpd); this.ToolsPanel.Controls.Add(this.buttonEdit);
this.ToolsPanel.Controls.Add(this.buttonAdd); this.ToolsPanel.Controls.Add(this.buttonAdd);
this.ToolsPanel.Location = new System.Drawing.Point(608, 12); this.ToolsPanel.Location = new System.Drawing.Point(532, 9);
this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.ToolsPanel.Name = "ToolsPanel"; this.ToolsPanel.Name = "ToolsPanel";
this.ToolsPanel.Size = new System.Drawing.Size(180, 426); this.ToolsPanel.Size = new System.Drawing.Size(158, 320);
this.ToolsPanel.TabIndex = 1; this.ToolsPanel.TabIndex = 1;
// //
// buttonRef // buttonUpdate
// //
this.buttonRef.Location = new System.Drawing.Point(31, 206); this.buttonUpdate.Location = new System.Drawing.Point(27, 154);
this.buttonRef.Name = "buttonRef"; this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRef.Size = new System.Drawing.Size(126, 36); this.buttonUpdate.Name = "buttonUpdate";
this.buttonRef.TabIndex = 3; this.buttonUpdate.Size = new System.Drawing.Size(110, 27);
this.buttonRef.Text = "Обновить"; this.buttonUpdate.TabIndex = 3;
this.buttonRef.UseVisualStyleBackColor = true; this.buttonUpdate.Text = "Обновить";
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
// //
// buttonDel // buttonDelete
// //
this.buttonDel.Location = new System.Drawing.Point(31, 142); this.buttonDelete.Location = new System.Drawing.Point(27, 106);
this.buttonDel.Name = "buttonDel"; this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDel.Size = new System.Drawing.Size(126, 36); this.buttonDelete.Name = "buttonDelete";
this.buttonDel.TabIndex = 2; this.buttonDelete.Size = new System.Drawing.Size(110, 27);
this.buttonDel.Text = "Удалить"; this.buttonDelete.TabIndex = 2;
this.buttonDel.UseVisualStyleBackColor = true; this.buttonDelete.Text = "Удалить";
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
// //
// buttonUpd // buttonEdit
// //
this.buttonUpd.Location = new System.Drawing.Point(31, 76); this.buttonEdit.Location = new System.Drawing.Point(27, 57);
this.buttonUpd.Name = "buttonUpd"; this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpd.Size = new System.Drawing.Size(126, 36); this.buttonEdit.Name = "buttonEdit";
this.buttonUpd.TabIndex = 1; this.buttonEdit.Size = new System.Drawing.Size(110, 27);
this.buttonUpd.Text = "Изменить"; this.buttonEdit.TabIndex = 1;
this.buttonUpd.UseVisualStyleBackColor = true; this.buttonEdit.Text = "Изменить";
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
// //
// buttonAdd // buttonAdd
// //
this.buttonAdd.Location = new System.Drawing.Point(31, 16); this.buttonAdd.Location = new System.Drawing.Point(27, 12);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd"; this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(126, 36); this.buttonAdd.Size = new System.Drawing.Size(110, 27);
this.buttonAdd.TabIndex = 0; this.buttonAdd.TabIndex = 0;
this.buttonAdd.Text = "Добавить"; this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true; this.buttonAdd.UseVisualStyleBackColor = true;
@ -104,13 +110,14 @@
// //
// FormComponents // FormComponents
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(700, 338);
this.Controls.Add(this.ToolsPanel); this.Controls.Add(this.ToolsPanel);
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormComponents"; this.Name = "FormComponents";
this.Text = "Компоненты"; this.Text = "Ингредиенты";
this.Load += new System.EventHandler(this.FormComponents_Load); this.Load += new System.EventHandler(this.FormComponents_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ToolsPanel.ResumeLayout(false); this.ToolsPanel.ResumeLayout(false);
@ -122,9 +129,9 @@
private DataGridView dataGridView; private DataGridView dataGridView;
private Panel ToolsPanel; private Panel ToolsPanel;
private Button buttonRef; private Button buttonUpdate;
private Button buttonDel; private Button buttonDelete;
private Button buttonUpd; private Button buttonEdit;
private Button buttonAdd; private Button buttonAdd;
} }
} }

View File

@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BankExecutor; using Pizzeria;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -12,7 +12,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace BankExecutorView namespace PizzeriaView
{ {
public partial class FormComponents : Form public partial class FormComponents : Form
{ {
@ -40,11 +40,11 @@ namespace BankExecutorView
dataGridView.Columns["ComponentName"].AutoSizeMode = dataGridView.Columns["ComponentName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill; DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка компонентов"); _logger.LogInformation("Загрузка ингридиентов");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки компонентов"); _logger.LogError(ex, "Ошибка загрузки ингридиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
@ -85,7 +85,7 @@ namespace BankExecutorView
{ {
int id = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента"); _logger.LogInformation("Удаление ингридиента");
try try
{ {
if (!_logic.Delete(new ComponentBindingModel if (!_logic.Delete(new ComponentBindingModel
@ -99,7 +99,7 @@ namespace BankExecutorView
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка удаления компонента"); _logger.LogError(ex, "Ошибка удаления ингридиента");
MessageBox.Show(ex.Message, "Ошибка", MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
} }

View File

@ -1,4 +1,4 @@
namespace BankExecutorView namespace PizzeriaView
{ {
partial class FormCreateOrder partial class FormCreateOrder
{ {
@ -28,8 +28,8 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.labelProduct = new System.Windows.Forms.Label(); this.labelPizza = new System.Windows.Forms.Label();
this.comboBoxProduct = new System.Windows.Forms.ComboBox(); this.comboBoxPizza = new System.Windows.Forms.ComboBox();
this.labelCount = new System.Windows.Forms.Label(); this.labelCount = new System.Windows.Forms.Label();
this.textBoxCount = new System.Windows.Forms.TextBox(); this.textBoxCount = new System.Windows.Forms.TextBox();
this.labelSum = new System.Windows.Forms.Label(); this.labelSum = new System.Windows.Forms.Label();
@ -38,24 +38,24 @@
this.buttonSave = new System.Windows.Forms.Button(); this.buttonSave = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// labelProduct // labelPizza
// //
this.labelProduct.AutoSize = true; this.labelPizza.AutoSize = true;
this.labelProduct.Location = new System.Drawing.Point(10, 11); this.labelPizza.Location = new System.Drawing.Point(10, 11);
this.labelProduct.Name = "labelProduct"; this.labelPizza.Name = "labelPizza";
this.labelProduct.Size = new System.Drawing.Size(59, 15); this.labelPizza.Size = new System.Drawing.Size(43, 15);
this.labelProduct.TabIndex = 0; this.labelPizza.TabIndex = 0;
this.labelProduct.Text = "Изделие: "; this.labelPizza.Text = "Пицца";
// //
// comboBoxProduct // comboBoxPizza
// //
this.comboBoxProduct.FormattingEnabled = true; this.comboBoxPizza.FormattingEnabled = true;
this.comboBoxProduct.Location = new System.Drawing.Point(101, 9); this.comboBoxPizza.Location = new System.Drawing.Point(101, 9);
this.comboBoxProduct.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.comboBoxPizza.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxProduct.Name = "comboBoxProduct"; this.comboBoxPizza.Name = "comboBoxPizza";
this.comboBoxProduct.Size = new System.Drawing.Size(314, 23); this.comboBoxPizza.Size = new System.Drawing.Size(314, 23);
this.comboBoxProduct.TabIndex = 1; this.comboBoxPizza.TabIndex = 1;
this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged); this.comboBoxPizza.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPizza_SelectedIndexChanged);
// //
// labelCount // labelCount
// //
@ -126,8 +126,8 @@
this.Controls.Add(this.labelSum); this.Controls.Add(this.labelSum);
this.Controls.Add(this.textBoxCount); this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.labelCount); this.Controls.Add(this.labelCount);
this.Controls.Add(this.comboBoxProduct); this.Controls.Add(this.comboBoxPizza);
this.Controls.Add(this.labelProduct); this.Controls.Add(this.labelPizza);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormCreateOrder"; this.Name = "FormCreateOrder";
this.Text = "Заказ"; this.Text = "Заказ";
@ -139,8 +139,8 @@
#endregion #endregion
private Label labelProduct; private Label labelPizza;
private ComboBox comboBoxProduct; private ComboBox comboBoxPizza;
private Label labelCount; private Label labelCount;
private TextBox textBoxCount; private TextBox textBoxCount;
private Label labelSum; private Label labelSum;

View File

@ -1,10 +1,10 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.Logging; using Microsoft.VisualBasic.Logging;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
using BankExecutorListImplement.Models; using PizzeriaListImplement.Models;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -16,15 +16,15 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace BankExecutorView namespace PizzeriaView
{ {
public partial class FormCreateOrder : Form public partial class FormCreateOrder : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IProductLogic _logicP; private readonly IPizzaLogic _logicP;
private readonly IOrderLogic _logicO; private readonly IOrderLogic _logicO;
private List<ProductViewModel>? _list; private List<PizzaViewModel>? _list;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IProductLogic logicP, IOrderLogic logicO) public FormCreateOrder(ILogger<FormCreateOrder> logger, IPizzaLogic logicP, IOrderLogic logicO)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
@ -36,26 +36,26 @@ namespace BankExecutorView
_list = _logicP.ReadList(null); _list = _logicP.ReadList(null);
if (_list != null) if (_list != null)
{ {
comboBoxProduct.DisplayMember = "ProductName"; comboBoxPizza.DisplayMember = "PizzaName";
comboBoxProduct.ValueMember = "Id"; comboBoxPizza.ValueMember = "Id";
comboBoxProduct.DataSource = _list; comboBoxPizza.DataSource = _list;
comboBoxProduct.SelectedItem = null; comboBoxPizza.SelectedItem = null;
_logger.LogInformation("Загрузка изделий для заказа"); _logger.LogInformation("Загрузка пиццы для заказа");
} }
} }
private void CalcSum() private void CalcSum()
{ {
if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) if (comboBoxPizza.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
{ {
try try
{ {
int id = Convert.ToInt32(comboBoxProduct.SelectedValue); int id = Convert.ToInt32(comboBoxPizza.SelectedValue);
var Product = _logicP.ReadElement(new ProductSearchModel var Pizza = _logicP.ReadElement(new PizzaSearchModel
{ {
Id = id Id = id
}); });
int count = Convert.ToInt32(textBoxCount.Text); int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (Product?.Price ?? 0), 2).ToString(); textBoxSum.Text = Math.Round(count * (Pizza?.Price ?? 0), 2).ToString();
_logger.LogInformation("Расчет суммы заказа"); _logger.LogInformation("Расчет суммы заказа");
} }
catch (Exception ex) catch (Exception ex)
@ -69,7 +69,7 @@ namespace BankExecutorView
{ {
CalcSum(); CalcSum();
} }
private void ComboBoxProduct_SelectedIndexChanged(object sender, EventArgs e) private void ComboBoxPizza_SelectedIndexChanged(object sender, EventArgs e)
{ {
CalcSum(); CalcSum();
} }
@ -80,9 +80,9 @@ namespace BankExecutorView
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (comboBoxProduct.SelectedValue == null) if (comboBoxPizza.SelectedValue == null)
{ {
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Создание заказа"); _logger.LogInformation("Создание заказа");
@ -90,7 +90,7 @@ namespace BankExecutorView
{ {
var operationResult = _logicO.CreateOrder(new OrderBindingModel var operationResult = _logicO.CreateOrder(new OrderBindingModel
{ {
ProductId = Convert.ToInt32(comboBoxProduct.SelectedValue), PizzaId = Convert.ToInt32(comboBoxPizza.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text), Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text) Sum = Convert.ToDouble(textBoxSum.Text)
}); });

View File

@ -1,4 +1,4 @@
namespace BankExecutorView namespace PizzeriaView
{ {
partial class FormMain partial class FormMain
{ {
@ -29,9 +29,9 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.справочникToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.bookToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ingridientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pizzasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
@ -46,54 +46,57 @@
// //
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникToolStripMenuItem}); this.bookToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1313, 28); this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
this.menuStrip1.Size = new System.Drawing.Size(1149, 24);
this.menuStrip1.TabIndex = 0; this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
// справочникToolStripMenuItem // bookToolStripMenuItem
// //
this.справочникToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.bookToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.компонентыToolStripMenuItem, this.ingridientsToolStripMenuItem,
this.изделияToolStripMenuItem}); this.pizzasToolStripMenuItem});
this.справочникToolStripMenuItem.Name = "справочникToolStripMenuItem"; this.bookToolStripMenuItem.Name = "bookToolStripMenuItem";
this.справочникToolStripMenuItem.Size = new System.Drawing.Size(108, 24); this.bookToolStripMenuItem.Size = new System.Drawing.Size(87, 20);
this.справочникToolStripMenuItem.Text = "Справочник"; this.bookToolStripMenuItem.Text = "Справочник";
// //
// компонентыToolStripMenuItem // ingridientsToolStripMenuItem
// //
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; this.ingridientsToolStripMenuItem.Name = "ingridientsToolStripMenuItem";
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26); this.ingridientsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.компонентыToolStripMenuItem.Text = "Компоненты"; this.ingridientsToolStripMenuItem.Text = "Ингредиенты";
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); this.ingridientsToolStripMenuItem.Click += new System.EventHandler(this.IngridentsToolStripMenuItem_Click);
// //
// изделияToolStripMenuItem // pizzasToolStripMenuItem
// //
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; this.pizzasToolStripMenuItem.Name = "pizzasToolStripMenuItem";
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(182, 26); this.pizzasToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.изделияToolStripMenuItem.Text = "Изделия"; this.pizzasToolStripMenuItem.Text = "Пиццы";
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click); this.pizzasToolStripMenuItem.Click += new System.EventHandler(this.PizzasToolStripMenuItem_Click);
// //
// dataGridView // dataGridView
// //
this.dataGridView.AllowUserToAddRows = false; this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false; this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 31); this.dataGridView.Location = new System.Drawing.Point(10, 23);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true; this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29; this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(977, 382); this.dataGridView.Size = new System.Drawing.Size(855, 286);
this.dataGridView.TabIndex = 1; this.dataGridView.TabIndex = 1;
// //
// buttonCreateOrder // buttonCreateOrder
// //
this.buttonCreateOrder.Location = new System.Drawing.Point(1026, 71); this.buttonCreateOrder.Location = new System.Drawing.Point(898, 53);
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(247, 29); this.buttonCreateOrder.Size = new System.Drawing.Size(216, 22);
this.buttonCreateOrder.TabIndex = 2; this.buttonCreateOrder.TabIndex = 2;
this.buttonCreateOrder.Text = "Создать заказ"; this.buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true; this.buttonCreateOrder.UseVisualStyleBackColor = true;
@ -101,9 +104,10 @@
// //
// buttonTakeOrderInWork // buttonTakeOrderInWork
// //
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(1026, 122); this.buttonTakeOrderInWork.Location = new System.Drawing.Point(898, 92);
this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(247, 29); this.buttonTakeOrderInWork.Size = new System.Drawing.Size(216, 22);
this.buttonTakeOrderInWork.TabIndex = 3; this.buttonTakeOrderInWork.TabIndex = 3;
this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
@ -111,9 +115,10 @@
// //
// buttonOrderReady // buttonOrderReady
// //
this.buttonOrderReady.Location = new System.Drawing.Point(1026, 172); this.buttonOrderReady.Location = new System.Drawing.Point(898, 129);
this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonOrderReady.Name = "buttonOrderReady"; this.buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.Size = new System.Drawing.Size(247, 29); this.buttonOrderReady.Size = new System.Drawing.Size(216, 22);
this.buttonOrderReady.TabIndex = 4; this.buttonOrderReady.TabIndex = 4;
this.buttonOrderReady.Text = "Заказ готов"; this.buttonOrderReady.Text = "Заказ готов";
this.buttonOrderReady.UseVisualStyleBackColor = true; this.buttonOrderReady.UseVisualStyleBackColor = true;
@ -121,9 +126,10 @@
// //
// buttonIssuedOrder // buttonIssuedOrder
// //
this.buttonIssuedOrder.Location = new System.Drawing.Point(1026, 225); this.buttonIssuedOrder.Location = new System.Drawing.Point(898, 169);
this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonIssuedOrder.Name = "buttonIssuedOrder"; this.buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.Size = new System.Drawing.Size(247, 29); this.buttonIssuedOrder.Size = new System.Drawing.Size(216, 22);
this.buttonIssuedOrder.TabIndex = 5; this.buttonIssuedOrder.TabIndex = 5;
this.buttonIssuedOrder.Text = "Заказ выдан"; this.buttonIssuedOrder.Text = "Заказ выдан";
this.buttonIssuedOrder.UseVisualStyleBackColor = true; this.buttonIssuedOrder.UseVisualStyleBackColor = true;
@ -131,9 +137,10 @@
// //
// buttonRef // buttonRef
// //
this.buttonRef.Location = new System.Drawing.Point(1026, 280); this.buttonRef.Location = new System.Drawing.Point(898, 210);
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRef.Name = "buttonRef"; this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(247, 29); this.buttonRef.Size = new System.Drawing.Size(216, 22);
this.buttonRef.TabIndex = 6; this.buttonRef.TabIndex = 6;
this.buttonRef.Text = "Обновить список"; this.buttonRef.Text = "Обновить список";
this.buttonRef.UseVisualStyleBackColor = true; this.buttonRef.UseVisualStyleBackColor = true;
@ -141,9 +148,9 @@
// //
// FormMain // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1313, 425); this.ClientSize = new System.Drawing.Size(1149, 319);
this.Controls.Add(this.buttonRef); this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonIssuedOrder); this.Controls.Add(this.buttonIssuedOrder);
this.Controls.Add(this.buttonOrderReady); this.Controls.Add(this.buttonOrderReady);
@ -152,8 +159,9 @@
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1; this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormMain"; this.Name = "FormMain";
this.Text = "Завод железобетонных изделий"; this.Text = "Пиццерия";
this.Load += new System.EventHandler(this.FormMain_Load); this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout(); this.menuStrip1.PerformLayout();
@ -166,9 +174,9 @@
#endregion #endregion
private MenuStrip menuStrip1; private MenuStrip menuStrip1;
private ToolStripMenuItem справочникToolStripMenuItem; private ToolStripMenuItem bookToolStripMenuItem;
private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem ingridientsToolStripMenuItem;
private ToolStripMenuItem изделияToolStripMenuItem; private ToolStripMenuItem pizzasToolStripMenuItem;
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonTakeOrderInWork; private Button buttonTakeOrderInWork;

View File

@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BankExecutor; using Pizzeria;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -12,7 +12,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace BankExecutorView namespace PizzeriaView
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
@ -36,8 +36,8 @@ namespace BankExecutorView
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["ProductId"].Visible = false; dataGridView.Columns["PizzaId"].Visible = false;
dataGridView.Columns["ProductName"].AutoSizeMode = dataGridView.Columns["PizzaName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill; DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
@ -48,7 +48,7 @@ namespace BankExecutorView
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) private void IngridentsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form) if (service is FormComponents form)
@ -56,10 +56,10 @@ namespace BankExecutorView
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) private void PizzasToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormProducts)); var service = Program.ServiceProvider?.GetService(typeof(FormPizzas));
if (service is FormProducts form) if (service is FormPizzas form)
{ {
form.ShowDialog(); form.ShowDialog();
} }

View File

@ -1,6 +1,6 @@
namespace BankExecutorView namespace PizzeriaView
{ {
partial class FormProduct partial class FormPizza
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -50,33 +50,35 @@
// labelName // labelName
// //
this.labelName.AutoSize = true; this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(16, 15); this.labelName.Location = new System.Drawing.Point(14, 11);
this.labelName.Name = "labelName"; this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(84, 20); this.labelName.Size = new System.Drawing.Size(65, 15);
this.labelName.TabIndex = 0; this.labelName.TabIndex = 0;
this.labelName.Text = "Название: "; this.labelName.Text = "Название: ";
// //
// textBoxName // textBoxName
// //
this.textBoxName.Location = new System.Drawing.Point(112, 12); this.textBoxName.Location = new System.Drawing.Point(98, 9);
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxName.Name = "textBoxName"; this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(293, 27); this.textBoxName.Size = new System.Drawing.Size(257, 23);
this.textBoxName.TabIndex = 1; this.textBoxName.TabIndex = 1;
// //
// labelPrice // labelPrice
// //
this.labelPrice.AutoSize = true; this.labelPrice.AutoSize = true;
this.labelPrice.Location = new System.Drawing.Point(16, 51); this.labelPrice.Location = new System.Drawing.Point(14, 38);
this.labelPrice.Name = "labelPrice"; this.labelPrice.Name = "labelPrice";
this.labelPrice.Size = new System.Drawing.Size(90, 20); this.labelPrice.Size = new System.Drawing.Size(73, 15);
this.labelPrice.TabIndex = 2; this.labelPrice.TabIndex = 2;
this.labelPrice.Text = "Стоимость: "; this.labelPrice.Text = "Стоимость: ";
// //
// textBoxPrice // textBoxPrice
// //
this.textBoxPrice.Location = new System.Drawing.Point(112, 51); this.textBoxPrice.Location = new System.Drawing.Point(98, 38);
this.textBoxPrice.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxPrice.Name = "textBoxPrice"; this.textBoxPrice.Name = "textBoxPrice";
this.textBoxPrice.Size = new System.Drawing.Size(171, 27); this.textBoxPrice.Size = new System.Drawing.Size(150, 23);
this.textBoxPrice.TabIndex = 3; this.textBoxPrice.TabIndex = 3;
// //
// groupBoxComponents // groupBoxComponents
@ -86,18 +88,21 @@
this.groupBoxComponents.Controls.Add(this.buttonUpd); this.groupBoxComponents.Controls.Add(this.buttonUpd);
this.groupBoxComponents.Controls.Add(this.buttonAdd); this.groupBoxComponents.Controls.Add(this.buttonAdd);
this.groupBoxComponents.Controls.Add(this.dataGridView); this.groupBoxComponents.Controls.Add(this.dataGridView);
this.groupBoxComponents.Location = new System.Drawing.Point(12, 84); this.groupBoxComponents.Location = new System.Drawing.Point(10, 63);
this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxComponents.Name = "groupBoxComponents"; this.groupBoxComponents.Name = "groupBoxComponents";
this.groupBoxComponents.Size = new System.Drawing.Size(661, 319); this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxComponents.Size = new System.Drawing.Size(578, 239);
this.groupBoxComponents.TabIndex = 4; this.groupBoxComponents.TabIndex = 4;
this.groupBoxComponents.TabStop = false; this.groupBoxComponents.TabStop = false;
this.groupBoxComponents.Text = "Компоненты"; this.groupBoxComponents.Text = "Ингредиенты";
// //
// buttonRef // buttonRef
// //
this.buttonRef.Location = new System.Drawing.Point(502, 211); this.buttonRef.Location = new System.Drawing.Point(439, 158);
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRef.Name = "buttonRef"; this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(126, 34); this.buttonRef.Size = new System.Drawing.Size(110, 26);
this.buttonRef.TabIndex = 4; this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить"; this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true; this.buttonRef.UseVisualStyleBackColor = true;
@ -105,9 +110,10 @@
// //
// buttonDel // buttonDel
// //
this.buttonDel.Location = new System.Drawing.Point(502, 157); this.buttonDel.Location = new System.Drawing.Point(439, 118);
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDel.Name = "buttonDel"; this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(126, 34); this.buttonDel.Size = new System.Drawing.Size(110, 26);
this.buttonDel.TabIndex = 3; this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить"; this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true; this.buttonDel.UseVisualStyleBackColor = true;
@ -115,9 +121,10 @@
// //
// buttonUpd // buttonUpd
// //
this.buttonUpd.Location = new System.Drawing.Point(502, 102); this.buttonUpd.Location = new System.Drawing.Point(439, 76);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpd.Name = "buttonUpd"; this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(126, 34); this.buttonUpd.Size = new System.Drawing.Size(110, 26);
this.buttonUpd.TabIndex = 2; this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить"; this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true; this.buttonUpd.UseVisualStyleBackColor = true;
@ -125,9 +132,10 @@
// //
// buttonAdd // buttonAdd
// //
this.buttonAdd.Location = new System.Drawing.Point(502, 47); this.buttonAdd.Location = new System.Drawing.Point(439, 35);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd"; this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(126, 34); this.buttonAdd.Size = new System.Drawing.Size(110, 26);
this.buttonAdd.TabIndex = 1; this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить"; this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true; this.buttonAdd.UseVisualStyleBackColor = true;
@ -143,19 +151,21 @@
this.id, this.id,
this.Component, this.Component,
this.Count}); this.Count});
this.dataGridView.Location = new System.Drawing.Point(6, 26); this.dataGridView.Location = new System.Drawing.Point(5, 20);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true; this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29; this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(476, 287); this.dataGridView.Size = new System.Drawing.Size(416, 215);
this.dataGridView.TabIndex = 0; this.dataGridView.TabIndex = 0;
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(514, 417); this.buttonCancel.Location = new System.Drawing.Point(450, 313);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(126, 34); this.buttonCancel.Size = new System.Drawing.Size(110, 26);
this.buttonCancel.TabIndex = 5; this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена"; this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.UseVisualStyleBackColor = true;
@ -163,9 +173,10 @@
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(368, 417); this.buttonSave.Location = new System.Drawing.Point(322, 313);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave"; this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(126, 34); this.buttonSave.Size = new System.Drawing.Size(110, 26);
this.buttonSave.TabIndex = 6; this.buttonSave.TabIndex = 6;
this.buttonSave.Text = "Сохранить"; this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseVisualStyleBackColor = true;
@ -181,7 +192,7 @@
// //
// Component // Component
// //
this.Component.HeaderText = "Компонент"; this.Component.HeaderText = "Ингредиент";
this.Component.MinimumWidth = 6; this.Component.MinimumWidth = 6;
this.Component.Name = "Component"; this.Component.Name = "Component";
this.Component.ReadOnly = true; this.Component.ReadOnly = true;
@ -193,11 +204,11 @@
this.Count.Name = "Count"; this.Count.Name = "Count";
this.Count.ReadOnly = true; this.Count.ReadOnly = true;
// //
// FormProduct // FormPizza
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(685, 463); this.ClientSize = new System.Drawing.Size(599, 347);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.groupBoxComponents); this.Controls.Add(this.groupBoxComponents);
@ -205,9 +216,10 @@
this.Controls.Add(this.labelPrice); this.Controls.Add(this.labelPrice);
this.Controls.Add(this.textBoxName); this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelName); this.Controls.Add(this.labelName);
this.Name = "FormProduct"; this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Text = "Изделие"; this.Name = "FormPizza";
this.Load += new System.EventHandler(this.FormProduct_Load); this.Text = "Пицца";
this.Load += new System.EventHandler(this.FormPizza_Load);
this.groupBoxComponents.ResumeLayout(false); this.groupBoxComponents.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
@ -228,10 +240,10 @@
private Button buttonUpd; private Button buttonUpd;
private Button buttonAdd; private Button buttonAdd;
private DataGridView dataGridView; private DataGridView dataGridView;
private DataGridViewTextBoxColumn Component;
private DataGridViewTextBoxColumn Count;
private Button buttonCancel; private Button buttonCancel;
private Button buttonSave; private Button buttonSave;
private DataGridViewTextBoxColumn id; private DataGridViewTextBoxColumn id;
private DataGridViewTextBoxColumn Component;
private DataGridViewTextBoxColumn Count;
} }
} }

View File

@ -1,9 +1,9 @@
using BankExecutorDataModels.Models; using PizzeriaDataModels.Models;
using BankExecutor; using Pizzeria;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -14,45 +14,45 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace BankExecutorView namespace PizzeriaView
{ {
public partial class FormProduct : Form public partial class FormPizza : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IProductLogic _logic; private readonly IPizzaLogic _logic;
private int? _id; private int? _id;
private Dictionary<int, (IComponentModel, int)> _ProductComponents; private Dictionary<int, (IComponentModel, int)> _PizzaComponents;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
public FormProduct(ILogger<FormProduct> logger, IProductLogic logic) public FormPizza(ILogger<FormPizza> logger, IPizzaLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
_ProductComponents = new Dictionary<int, (IComponentModel, int)>(); _PizzaComponents = new Dictionary<int, (IComponentModel, int)>();
} }
private void FormProduct_Load(object sender, EventArgs e) private void FormPizza_Load(object sender, EventArgs e)
{ {
if (_id.HasValue) if (_id.HasValue)
{ {
_logger.LogInformation("Загрузка изделия"); _logger.LogInformation("Загрузка пиццы");
try try
{ {
var view = _logic.ReadElement(new ProductSearchModel var view = _logic.ReadElement(new PizzaSearchModel
{ {
Id = _id.Value Id = _id.Value
}); });
if (view != null) if (view != null)
{ {
textBoxName.Text = view.ProductName; textBoxName.Text = view.PizzaName;
textBoxPrice.Text = view.Price.ToString(); textBoxPrice.Text = view.Price.ToString();
_ProductComponents = view.ProductComponents ?? new _PizzaComponents = view.PizzaComponents ?? new
Dictionary<int, (IComponentModel, int)>(); Dictionary<int, (IComponentModel, int)>();
LoadData(); LoadData();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки изделия"); _logger.LogError(ex, "Ошибка загрузки пиццы");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
@ -60,13 +60,13 @@ namespace BankExecutorView
} }
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка компонент изделия"); _logger.LogInformation("Загрузка ингредиент пиццы");
try try
{ {
if (_ProductComponents != null) if (_PizzaComponents != null)
{ {
dataGridView.Rows.Clear(); dataGridView.Rows.Clear();
foreach (var pc in _ProductComponents) foreach (var pc in _PizzaComponents)
{ {
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
} }
@ -75,15 +75,15 @@ namespace BankExecutorView
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки компонент изделия"); _logger.LogError(ex, "Ошибка загрузки ингредиента пиццы");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent)); var service = Program.ServiceProvider?.GetService(typeof(FormPizzaComponent));
if (service is FormProductComponent form) if (service is FormPizzaComponent form)
{ {
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
@ -91,15 +91,15 @@ namespace BankExecutorView
{ {
return; return;
} }
_logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); _logger.LogInformation("Добавление нового ингредиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count);
if (_ProductComponents.ContainsKey(form.Id)) if (_PizzaComponents.ContainsKey(form.Id))
{ {
_ProductComponents[form.Id] = (form.ComponentModel, _PizzaComponents[form.Id] = (form.ComponentModel,
form.Count); form.Count);
} }
else else
{ {
_ProductComponents.Add(form.Id, (form.ComponentModel, _PizzaComponents.Add(form.Id, (form.ComponentModel,
form.Count)); form.Count));
} }
LoadData(); LoadData();
@ -110,20 +110,20 @@ namespace BankExecutorView
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent)); var service = Program.ServiceProvider?.GetService(typeof(FormPizzaComponent));
if (service is FormProductComponent form) if (service is FormPizzaComponent form)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id; form.Id = id;
form.Count = _ProductComponents[id].Item2; form.Count = _PizzaComponents[id].Item2;
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
if (form.ComponentModel == null) if (form.ComponentModel == null)
{ {
return; return;
} }
_logger.LogInformation("Изменение компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); _logger.LogInformation("Изменение ингредиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count);
_ProductComponents[form.Id] = (form.ComponentModel, form.Count); _PizzaComponents[form.Id] = (form.ComponentModel, form.Count);
LoadData(); LoadData();
} }
} }
@ -137,8 +137,8 @@ namespace BankExecutorView
{ {
try try
{ {
_logger.LogInformation("Удаление компонента:{ ComponentName}-{ Count}", dataGridView.SelectedRows[0].Cells[1].Value); _logger.LogInformation("Удаление ингредиента:{ ComponentName}-{ Count}", dataGridView.SelectedRows[0].Cells[1].Value);
_ProductComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); _PizzaComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -165,20 +165,20 @@ namespace BankExecutorView
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (_ProductComponents == null || _ProductComponents.Count == 0) if (_PizzaComponents == null || _PizzaComponents.Count == 0)
{ {
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните ингредиенты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Сохранение изделия"); _logger.LogInformation("Сохранение пиццы");
try try
{ {
var model = new ProductBindingModel var model = new PizzaBindingModel
{ {
Id = _id ?? 0, Id = _id ?? 0,
ProductName = textBoxName.Text, PizzaName = textBoxName.Text,
Price = Convert.ToDouble(textBoxPrice.Text), Price = Convert.ToDouble(textBoxPrice.Text),
ProductComponents = _ProductComponents PizzaComponents = _PizzaComponents
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : var operationResult = _id.HasValue ? _logic.Update(model) :
_logic.Create(model); _logic.Create(model);
@ -192,7 +192,7 @@ namespace BankExecutorView
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка сохранения изделия"); _logger.LogError(ex, "Ошибка сохранения пиццы");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
@ -204,7 +204,7 @@ namespace BankExecutorView
private double CalcPrice() private double CalcPrice()
{ {
double price = 0; double price = 0;
foreach (var elem in _ProductComponents) foreach (var elem in _PizzaComponents)
{ {
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
} }

View File

@ -1,6 +1,6 @@
namespace BankExecutorView namespace PizzeriaView
{ {
partial class FormProductComponent partial class FormPizzaComponent
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -39,41 +39,44 @@
// labelComponent // labelComponent
// //
this.labelComponent.AutoSize = true; this.labelComponent.AutoSize = true;
this.labelComponent.Location = new System.Drawing.Point(12, 9); this.labelComponent.Location = new System.Drawing.Point(10, 7);
this.labelComponent.Name = "labelComponent"; this.labelComponent.Name = "labelComponent";
this.labelComponent.Size = new System.Drawing.Size(91, 20); this.labelComponent.Size = new System.Drawing.Size(75, 15);
this.labelComponent.TabIndex = 0; this.labelComponent.TabIndex = 0;
this.labelComponent.Text = "Компонент:"; this.labelComponent.Text = "Ингредиент:";
// //
// comboBoxComponent // comboBoxComponent
// //
this.comboBoxComponent.FormattingEnabled = true; this.comboBoxComponent.FormattingEnabled = true;
this.comboBoxComponent.Location = new System.Drawing.Point(119, 9); this.comboBoxComponent.Location = new System.Drawing.Point(104, 7);
this.comboBoxComponent.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxComponent.Name = "comboBoxComponent"; this.comboBoxComponent.Name = "comboBoxComponent";
this.comboBoxComponent.Size = new System.Drawing.Size(355, 28); this.comboBoxComponent.Size = new System.Drawing.Size(311, 23);
this.comboBoxComponent.TabIndex = 1; this.comboBoxComponent.TabIndex = 1;
// //
// labelCount // labelCount
// //
this.labelCount.AutoSize = true; this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(12, 51); this.labelCount.Location = new System.Drawing.Point(10, 38);
this.labelCount.Name = "labelCount"; this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(93, 20); this.labelCount.Size = new System.Drawing.Size(75, 15);
this.labelCount.TabIndex = 2; this.labelCount.TabIndex = 2;
this.labelCount.Text = "Количество:"; this.labelCount.Text = "Количество:";
// //
// textBoxCount // textBoxCount
// //
this.textBoxCount.Location = new System.Drawing.Point(119, 51); this.textBoxCount.Location = new System.Drawing.Point(104, 38);
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(355, 27); this.textBoxCount.Size = new System.Drawing.Size(311, 23);
this.textBoxCount.TabIndex = 3; this.textBoxCount.TabIndex = 3;
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(317, 94); this.buttonCancel.Location = new System.Drawing.Point(277, 70);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(136, 41); this.buttonCancel.Size = new System.Drawing.Size(119, 31);
this.buttonCancel.TabIndex = 4; this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Отмена"; this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.UseVisualStyleBackColor = true;
@ -81,27 +84,29 @@
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(175, 94); this.buttonSave.Location = new System.Drawing.Point(153, 70);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave"; this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(136, 41); this.buttonSave.Size = new System.Drawing.Size(119, 31);
this.buttonSave.TabIndex = 5; this.buttonSave.TabIndex = 5;
this.buttonSave.Text = "Сохранить"; this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
// //
// FormProductComponent // FormPizzaComponent
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(486, 147); this.ClientSize = new System.Drawing.Size(425, 110);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.textBoxCount); this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.labelCount); this.Controls.Add(this.labelCount);
this.Controls.Add(this.comboBoxComponent); this.Controls.Add(this.comboBoxComponent);
this.Controls.Add(this.labelComponent); this.Controls.Add(this.labelComponent);
this.Name = "FormProductComponent"; this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Text = "Компонент изделия"; this.Name = "FormPizzaComponent";
this.Text = "Ингридиент пиццы";
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -1,7 +1,7 @@
using BankExecutorDataModels.Models; using PizzeriaDataModels.Models;
using Microsoft.VisualBasic.Logging; using Microsoft.VisualBasic.Logging;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -12,9 +12,9 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace BankExecutorView namespace PizzeriaView
{ {
public partial class FormProductComponent : Form public partial class FormPizzaComponent : Form
{ {
private readonly List<ComponentViewModel>? _list; private readonly List<ComponentViewModel>? _list;
public int Id public int Id
@ -47,7 +47,7 @@ namespace BankExecutorView
} }
} }
public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set{ textBoxCount.Text = value.ToString(); }} public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set{ textBoxCount.Text = value.ToString(); }}
public FormProductComponent(IComponentLogic logic) public FormPizzaComponent(IComponentLogic logic)
{ {
InitializeComponent(); InitializeComponent();
@ -69,7 +69,7 @@ namespace BankExecutorView
} }
if (comboBoxComponent.SelectedValue == null) if (comboBoxComponent.SelectedValue == null)
{ {
MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Выберите ингредиент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;

View File

@ -1,6 +1,6 @@
namespace BankExecutorView namespace PizzeriaView
{ {
partial class FormProducts partial class FormPizzas
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -102,16 +102,16 @@
this.dataGridView.Size = new System.Drawing.Size(590, 426); this.dataGridView.Size = new System.Drawing.Size(590, 426);
this.dataGridView.TabIndex = 2; this.dataGridView.TabIndex = 2;
// //
// FormProducts // FormPizzas
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.ToolsPanel); this.Controls.Add(this.ToolsPanel);
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
this.Name = "FormProducts"; this.Name = "FormPizzas";
this.Text = "Изделия"; this.Text = "Пицца";
this.Load += new System.EventHandler(this.FormProduct_Load); this.Load += new System.EventHandler(this.FormPizza_Load);
this.ToolsPanel.ResumeLayout(false); this.ToolsPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BankExecutor; using Pizzeria;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -12,19 +12,19 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace BankExecutorView namespace PizzeriaView
{ {
public partial class FormProducts : Form public partial class FormPizzas : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IProductLogic _logic; private readonly IPizzaLogic _logic;
public FormProducts(ILogger<FormProducts> logger, IProductLogic logic) public FormPizzas(ILogger<FormPizzas> logger, IPizzaLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void FormProduct_Load(object sender, EventArgs e) private void FormPizza_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
@ -37,22 +37,22 @@ namespace BankExecutorView
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ProductComponents"].Visible = false; dataGridView.Columns["PizzaComponents"].Visible = false;
dataGridView.Columns["ProductName"].AutoSizeMode = dataGridView.Columns["PizzaName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill; DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка изделий"); _logger.LogInformation("Загрузка пиццы");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки изделий"); _logger.LogError(ex, "Ошибка загрузки пиццы");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormProduct)); var service = Program.ServiceProvider?.GetService(typeof(FormPizza));
if (service is FormProduct form) if (service is FormPizza form)
{ {
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
@ -64,8 +64,8 @@ namespace BankExecutorView
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormProduct)); var service = Program.ServiceProvider?.GetService(typeof(FormPizza));
if (service is FormProduct form) if (service is FormPizza form)
{ {
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
@ -82,10 +82,10 @@ namespace BankExecutorView
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление изделия"); _logger.LogInformation("Удаление пиццы");
try try
{ {
if (!_logic.Delete(new ProductBindingModel if (!_logic.Delete(new PizzaBindingModel
{ {
Id = id Id = id
})) }))
@ -96,7 +96,7 @@ namespace BankExecutorView
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка удаления изделия"); _logger.LogError(ex, "Ошибка удаления пиццы");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }

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

@ -14,10 +14,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\AbstractBankDataModels\BankExecutorDataModels.csproj" /> <ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
<ProjectReference Include="..\BankExecutorBusinessLogic\BankExecutorBusinessLogic.csproj" /> <ProjectReference Include="..\PizzeriaBusinessLogic\PizzeriaBusinessLogic.csproj" />
<ProjectReference Include="..\BankExecutorContracts\BankExecutorContracts.csproj" /> <ProjectReference Include="..\PizzeriaContracts\PizzeriaContracts.csproj" />
<ProjectReference Include="..\BankExecutorListImplement\BankExecutorListImplement.csproj" /> <ProjectReference Include="..\PizzeriaListImplement\PizzeriaListImplement.csproj" />
<ProjectReference Include="..\PizzeriaContracts\PizzeriaContracts.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,16 +1,16 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
using BankExecutorBusinessLogic.BusinessLogics; using PizzeriaBusinessLogic.BusinessLogics;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using BankExecutorContracts.StoragesContracts; using PizzeriaContracts.StoragesContracts;
using BankExecutorListImplement.Implements; using PizzeriaListImplement.Implements;
using BankExecutorView; using PizzeriaView;
using System; using System;
using System.Drawing; using System.Drawing;
using BankExecutortBusinessLogic.BusinessLogics; using PizzeriatBusinessLogic.BusinessLogics;
namespace BankExecutor namespace Pizzeria
{ {
internal static class Program internal static class Program
{ {
@ -40,17 +40,17 @@ namespace BankExecutor
services.AddTransient<IComponentStorage, ComponentStorage>(); services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IProductStorage, ProductStorage>(); services.AddTransient<IPizzaStorage, PizzaStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IProductLogic, ProductLogic>(); services.AddTransient<IPizzaLogic, PizzaLogic>();
services.AddTransient<FormComponent>(); services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>(); services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>(); services.AddTransient<FormCreateOrder>();
services.AddTransient<FormProduct>(); services.AddTransient<FormPizza>();
services.AddTransient<FormProductComponent>(); services.AddTransient<FormPizzaComponent>();
services.AddTransient<FormProducts>(); services.AddTransient<FormPizzas>();
} }
} }
} }

View File

@ -1,11 +1,11 @@
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using BankExecutorContracts.StoragesContracts; using PizzeriaContracts.StoragesContracts;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
namespace BankExecutorBusinessLogic.BusinessLogics namespace PizzeriaBusinessLogic.BusinessLogics
{ {
public class ComponentLogic : IComponentLogic public class ComponentLogic : IComponentLogic
{ {
@ -87,11 +87,11 @@ namespace BankExecutorBusinessLogic.BusinessLogics
} }
if (string.IsNullOrEmpty(model.ComponentName)) if (string.IsNullOrEmpty(model.ComponentName))
{ {
throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName)); throw new ArgumentNullException("Нет названия ингредиента", nameof(model.ComponentName));
} }
if (model.Cost <= 0) if (model.Cost <= 0)
{ {
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); throw new ArgumentNullException("Цена ингредиента должна быть больше 0", nameof(model.Cost));
} }
_logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}.Id: { Id}", model.ComponentName, model.Cost, model.Id); _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}.Id: { Id}", model.ComponentName, model.Cost, model.Id);
var element = _componentStorage.GetElement(new ComponentSearchModel var element = _componentStorage.GetElement(new ComponentSearchModel
@ -100,7 +100,7 @@ namespace BankExecutorBusinessLogic.BusinessLogics
}); });
if (element != null && element.Id != model.Id) if (element != null && element.Id != model.Id)
{ {
throw new InvalidOperationException("Компонент с таким названием уже есть"); throw new InvalidOperationException("Ингредиент с таким названием уже есть");
} }
} }
} }

View File

@ -1,12 +1,12 @@
using BankExecutorDataModels.Enums; using PizzeriaDataModels.Enums;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using BankExecutorContracts.StoragesContracts; using PizzeriaContracts.StoragesContracts;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
namespace BankExecutortBusinessLogic.BusinessLogics namespace PizzeriatBusinessLogic.BusinessLogics
{ {
public class OrderLogic : IOrderLogic public class OrderLogic : IOrderLogic
{ {
@ -66,7 +66,7 @@ namespace BankExecutortBusinessLogic.BusinessLogics
} }
if (model.Count <= 0) if (model.Count <= 0)
{ {
throw new ArgumentException("Колличество изделий в заказе не может быть меньше 1", nameof(model.Count)); throw new ArgumentException("Колличество пиццы в заказе не может быть меньше 1", nameof(model.Count));
} }
if (model.Sum <= 0) if (model.Sum <= 0)
{ {
@ -76,8 +76,8 @@ namespace BankExecutortBusinessLogic.BusinessLogics
{ {
throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}"); throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}");
} }
_logger.LogInformation("Product. ProductId:{ProductId}.Count:{Count}.Sum:{Sum}Id:{Id}", _logger.LogInformation("Pizza. PizzaId:{PizzaId}.Count:{Count}.Sum:{Sum}Id:{Id}",
model.ProductId, model.Count,model.Sum, model.Id); model.PizzaId, model.Count,model.Sum, model.Id);
} }
private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) { private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) {
CheckModel(model, false); CheckModel(model, false);
@ -90,7 +90,7 @@ namespace BankExecutortBusinessLogic.BusinessLogics
throw new ArgumentNullException(nameof(element)); throw new ArgumentNullException(nameof(element));
} }
model.DateCreate = element.DateCreate; model.DateCreate = element.DateCreate;
model.ProductId = element.ProductId; model.PizzaId = element.PizzaId;
model.DateImplement = element.DateImplement; model.DateImplement = element.DateImplement;
model.Status = element.Status; model.Status = element.Status;
model.Count = element.Count; model.Count = element.Count;

View File

@ -0,0 +1,111 @@
using Microsoft.Extensions.Logging;
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
namespace PizzeriaBusinessLogic.BusinessLogics
{
public class PizzaLogic : IPizzaLogic
{
private readonly ILogger _logger;
private readonly IPizzaStorage _PizzaStorage;
public PizzaLogic(ILogger<PizzaLogic> logger, IPizzaStorage PizzaStorage)
{
_logger = logger;
_PizzaStorage= PizzaStorage;
}
public List<PizzaViewModel>? ReadList(PizzaSearchModel? model)
{
_logger.LogInformation("ReadList. PizzaName:{PizzaName}.Id:{ Id}", model?.PizzaName, model?.Id);
var list = model == null ? _PizzaStorage.GetFullList() : _PizzaStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public PizzaViewModel? ReadElement(PizzaSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. PizzaName:{PizzaName}.Id:{ Id}", model.PizzaName, model.Id);
var element = _PizzaStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(PizzaBindingModel model)
{
CheckModel(model);
if (_PizzaStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(PizzaBindingModel model)
{
CheckModel(model);
if (_PizzaStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(PizzaBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_PizzaStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(PizzaBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.PizzaName))
{
throw new ArgumentNullException("Нет названия пиццы", nameof(model.PizzaName));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена пиццы должна быть больше 0", nameof(model.Price));
}
if(model.PizzaComponents==null || model.PizzaComponents.Count == 0)
{
throw new ArgumentNullException("Перечень ингредиентов не может быть пустым", nameof(model.PizzaComponents));
}
_logger.LogInformation("Pizza. PizzaName:{PizzaName}.Price:{Price}.Id: { Id}", model.PizzaName, model.Price, model.Id);
var element = _PizzaStorage.GetElement(new PizzaSearchModel
{
PizzaName = model.PizzaName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Пицца с таким названием уже есть");
}
}
}
}

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>
@ -11,7 +11,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\BankExecutorContracts\BankExecutorContracts.csproj" /> <ProjectReference Include="..\PizzeriaContracts\PizzeriaContracts.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,6 +1,6 @@
using BankExecutorDataModels.Models; using PizzeriaDataModels.Models;
namespace BankExecutorContracts.BindingModels namespace PizzeriaContracts.BindingModels
{ {
public class ComponentBindingModel : IComponentModel public class ComponentBindingModel : IComponentModel
{ {

View File

@ -1,12 +1,12 @@
using BankExecutorDataModels.Enums; using PizzeriaDataModels.Enums;
using BankExecutorDataModels.Models; using PizzeriaDataModels.Models;
namespace BankExecutorContracts.BindingModels namespace PizzeriaContracts.BindingModels
{ {
public class OrderBindingModel : IOrderModel public class OrderBindingModel : IOrderModel
{ {
public int Id { get; set; } public int Id { get; set; }
public int ProductId { get; set; } public int PizzaId { get; set; }
public int Count { get; set; } public int Count { get; set; }
public double Sum { get; set; } public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;

View File

@ -0,0 +1,13 @@
using PizzeriaDataModels.Models;
namespace PizzeriaContracts.BindingModels
{
public class PizzaBindingModel : IPizzaModel
{
public int Id { get; set; }
public string PizzaName { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> PizzaComponents { get; set; } = new();
}
}

View File

@ -1,8 +1,8 @@
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
namespace BankExecutorContracts.BusinessLogicsContracts namespace PizzeriaContracts.BusinessLogicsContracts
{ {
public interface IComponentLogic public interface IComponentLogic
{ {

View File

@ -1,8 +1,8 @@
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
namespace BankExecutorContracts.BusinessLogicsContracts namespace PizzeriaContracts.BusinessLogicsContracts
{ {
public interface IOrderLogic public interface IOrderLogic
{ {

View File

@ -0,0 +1,15 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.ViewModels;
namespace PizzeriaContracts.BusinessLogicsContracts
{
public interface IPizzaLogic
{
List<PizzaViewModel>? ReadList(PizzaSearchModel? model);
PizzaViewModel? ReadElement(PizzaSearchModel model);
bool Create(PizzaBindingModel model);
bool Update(PizzaBindingModel model);
bool Delete(PizzaBindingModel model);
}
}

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>
@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\AbstractBankDataModels\BankExecutorDataModels.csproj" /> <ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
namespace BankExecutorContracts.SearchModels namespace PizzeriaContracts.SearchModels
{ {
public class ComponentSearchModel public class ComponentSearchModel
{ {

View File

@ -1,4 +1,4 @@
namespace BankExecutorContracts.SearchModels namespace PizzeriaContracts.SearchModels
{ {
public class OrderSearchModel public class OrderSearchModel
{ {

View File

@ -0,0 +1,8 @@
namespace PizzeriaContracts.SearchModels
{
public class PizzaSearchModel
{
public int? Id { get; set; }
public string? PizzaName { get; set; }
}
}

View File

@ -1,8 +1,8 @@
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
namespace BankExecutorContracts.StoragesContracts namespace PizzeriaContracts.StoragesContracts
{ {
public interface IComponentStorage public interface IComponentStorage
{ {

View File

@ -1,9 +1,9 @@
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
namespace BankExecutorContracts.StoragesContracts namespace PizzeriaContracts.StoragesContracts
{ {
public interface IOrderStorage public interface IOrderStorage
{ {

View File

@ -0,0 +1,16 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.ViewModels;
namespace PizzeriaContracts.StoragesContracts
{
public interface IPizzaStorage
{
List<PizzaViewModel> GetFullList();
List<PizzaViewModel> GetFilteredList(PizzaSearchModel model);
PizzaViewModel? GetElement(PizzaSearchModel model);
PizzaViewModel? Insert(PizzaBindingModel model);
PizzaViewModel? Update(PizzaBindingModel model);
PizzaViewModel? Delete(PizzaBindingModel model);
}
}

View File

@ -1,12 +1,12 @@
using BankExecutorDataModels.Models; using PizzeriaDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace BankExecutorContracts.ViewModels namespace PizzeriaContracts.ViewModels
{ {
public class ComponentViewModel : IComponentModel public class ComponentViewModel : IComponentModel
{ {
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название компонента")] [DisplayName("Название ингредиента")]
public string ComponentName { get; set; } = string.Empty; public string ComponentName { get; set; } = string.Empty;
[DisplayName("Цена")] [DisplayName("Цена")]
public double Cost { get; set; } public double Cost { get; set; }

View File

@ -1,18 +1,18 @@
using BankExecutorDataModels.Enums; using PizzeriaDataModels.Enums;
using BankExecutorDataModels.Models; using PizzeriaDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace BankExecutorContracts.ViewModels namespace PizzeriaContracts.ViewModels
{ {
public class OrderViewModel : IOrderModel public class OrderViewModel : IOrderModel
{ {
[DisplayName("Номер")] [DisplayName("Номер")]
public int Id { get; set; } public int Id { get; set; }
public int ProductId { get; set; } public int PizzaId { get; set; }
[DisplayName("Изделие")] [DisplayName("Пицца")]
public string ProductName { get; set; } = string.Empty; public string PizzaName { get; set; } = string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }

View File

@ -0,0 +1,15 @@
using PizzeriaDataModels.Models;
using System.ComponentModel;
namespace PizzeriaContracts.ViewModels
{
public class PizzaViewModel : IPizzaModel
{
public int Id { get; set; }
[DisplayName("Название пиццы")]
public string PizzaName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> PizzaComponents { get;set;} = new();
}
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankExecutorDataModels.Enums namespace PizzeriaDataModels.Enums
{ {
public enum OrderStatus public enum OrderStatus
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankExecutorDataModels namespace PizzeriaDataModels
{ {
public interface IId public interface IId
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankExecutorDataModels.Models namespace PizzeriaDataModels.Models
{ {
public interface IComponentModel : IId public interface IComponentModel : IId
{ {

View File

@ -1,15 +1,15 @@
using BankExecutorDataModels.Enums; using PizzeriaDataModels.Enums;
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 BankExecutorDataModels.Models namespace PizzeriaDataModels.Models
{ {
public interface IOrderModel : IId public interface IOrderModel : IId
{ {
int ProductId { get; } int PizzaId { get; }
int Count { get; } int Count { get; }
double Sum { get; } double Sum { get; }
OrderStatus Status { get; } OrderStatus Status { get; }

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaDataModels.Models
{
public interface IPizzaModel : IId
{
string PizzaName { get; }
double Price { get; }
Dictionary<int, (IComponentModel, int)> PizzaComponents { get; }
}
}

View File

@ -1,18 +1,18 @@
using BankExecutorListImplement.Models; using PizzeriaListImplement.Models;
namespace BankExecutorListImplement namespace PizzeriaListImplement
{ {
public class DataListSingleton public class DataListSingleton
{ {
private static DataListSingleton? _instance; private static DataListSingleton? _instance;
public List<Component> Components { get; set; } public List<Component> Components { get; set; }
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Product> Products { get; set; } public List<Pizza> Pizzas { get; set; }
private DataListSingleton() private DataListSingleton()
{ {
Components = new List<Component>(); Components = new List<Component>();
Orders = new List<Order>(); Orders = new List<Order>();
Products = new List<Product>(); Pizzas = new List<Pizza>();
} }
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()
{ {

View File

@ -1,10 +1,10 @@
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using BankExecutorContracts.StoragesContracts; using PizzeriaContracts.StoragesContracts;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
using BankExecutorListImplement.Models; using PizzeriaListImplement.Models;
namespace BankExecutorListImplement.Implements namespace PizzeriaListImplement.Implements
{ {
public class ComponentStorage : IComponentStorage public class ComponentStorage : IComponentStorage
{ {

View File

@ -1,10 +1,10 @@
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.SearchModels; using PizzeriaContracts.SearchModels;
using BankExecutorContracts.StoragesContracts; using PizzeriaContracts.StoragesContracts;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
using BankExecutorListImplement.Models; using PizzeriaListImplement.Models;
namespace BankExecutorListImplement.Implements namespace PizzeriaListImplement.Implements
{ {
public class OrderStorage : IOrderStorage public class OrderStorage : IOrderStorage
{ {
@ -17,7 +17,7 @@ namespace BankExecutorListImplement.Implements
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
result.Add(AttachProductName(order.GetViewModel)); result.Add(AttachPizzaName(order.GetViewModel));
} }
return result; return result;
} }
@ -33,7 +33,7 @@ namespace BankExecutorListImplement.Implements
{ {
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
result.Add(AttachProductName(order.GetViewModel)); result.Add(AttachPizzaName(order.GetViewModel));
} }
} }
return result; return result;
@ -49,7 +49,7 @@ namespace BankExecutorListImplement.Implements
{ {
if (model.Id.HasValue && order.Id == model.Id) if (model.Id.HasValue && order.Id == model.Id)
{ {
return AttachProductName(order.GetViewModel); return AttachPizzaName(order.GetViewModel);
} }
} }
return null; return null;
@ -71,7 +71,7 @@ namespace BankExecutorListImplement.Implements
return null; return null;
} }
_source.Orders.Add(newOrder); _source.Orders.Add(newOrder);
return AttachProductName(newOrder.GetViewModel); return AttachPizzaName(newOrder.GetViewModel);
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
{ {
@ -80,7 +80,7 @@ namespace BankExecutorListImplement.Implements
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
order.Update(model); order.Update(model);
return AttachProductName(order.GetViewModel); return AttachPizzaName(order.GetViewModel);
} }
} }
return null; return null;
@ -93,18 +93,18 @@ namespace BankExecutorListImplement.Implements
{ {
var element = _source.Orders[i]; var element = _source.Orders[i];
_source.Orders.RemoveAt(i); _source.Orders.RemoveAt(i);
return AttachProductName(element.GetViewModel); return AttachPizzaName(element.GetViewModel);
} }
} }
return null; return null;
} }
private OrderViewModel AttachProductName(OrderViewModel model) private OrderViewModel AttachPizzaName(OrderViewModel model)
{ {
foreach (var product in _source.Products) foreach (var pizza in _source.Pizzas)
{ {
if (product.Id == model.ProductId) if (pizza.Id == model.PizzaId)
{ {
model.ProductName = product.ProductName; model.PizzaName = pizza.PizzaName;
return model; return model;
} }
} }

View File

@ -0,0 +1,101 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using PizzeriaListImplement.Models;
namespace PizzeriaListImplement.Implements
{
public class PizzaStorage : IPizzaStorage
{
private readonly DataListSingleton _source;
public PizzaStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<PizzaViewModel> GetFullList()
{
var result = new List<PizzaViewModel>();
foreach (var pizzas in _source.Pizzas)
{
result.Add(pizzas.GetViewModel);
}
return result;
}
public List<PizzaViewModel> GetFilteredList(PizzaSearchModel model)
{
var result = new List<PizzaViewModel>();
if (string.IsNullOrEmpty(model.PizzaName))
{
return result;
}
foreach (var pizzas in _source.Pizzas)
{
if (pizzas.PizzaName.Contains(model.PizzaName))
{
result.Add(pizzas.GetViewModel);
}
}
return result;
}
public PizzaViewModel? GetElement(PizzaSearchModel model)
{
if (string.IsNullOrEmpty(model.PizzaName) && !model.Id.HasValue)
{
return null;
}
foreach (var pizzas in _source.Pizzas)
{
if ((!string.IsNullOrEmpty(model.PizzaName) && pizzas.PizzaName == model.PizzaName) ||
(model.Id.HasValue && pizzas.Id == model.Id))
{
return pizzas.GetViewModel;
}
}
return null;
}
public PizzaViewModel? Insert(PizzaBindingModel model)
{
model.Id = 1;
foreach (var pizzas in _source.Pizzas)
{
if (model.Id <= pizzas.Id)
{
model.Id = pizzas.Id + 1;
}
}
var newPizzas = Pizza.Create(model);
if (newPizzas == null)
{
return null;
}
_source.Pizzas.Add(newPizzas);
return newPizzas.GetViewModel;
}
public PizzaViewModel? Update(PizzaBindingModel model)
{
foreach (var pizzas in _source.Pizzas)
{
if (pizzas.Id == model.Id)
{
pizzas.Update(model);
return pizzas.GetViewModel;
}
}
return null;
}
public PizzaViewModel? Delete(PizzaBindingModel model)
{
for (int i = 0; i < _source.Pizzas.Count; ++i)
{
if (_source.Pizzas[i].Id == model.Id)
{
var element = _source.Pizzas[i];
_source.Pizzas.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -1,8 +1,8 @@
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
using BankExecutorDataModels.Models; using PizzeriaDataModels.Models;
namespace BankExecutorListImplement.Models namespace PizzeriaListImplement.Models
{ {
public class Component : IComponentModel public class Component : IComponentModel
{ {

View File

@ -1,14 +1,14 @@
using BankExecutorDataModels.Enums; using PizzeriaDataModels.Enums;
using BankExecutorDataModels.Models; using PizzeriaDataModels.Models;
using BankExecutorContracts.BindingModels; using PizzeriaContracts.BindingModels;
using BankExecutorContracts.ViewModels; using PizzeriaContracts.ViewModels;
namespace BankExecutorListImplement.Models namespace PizzeriaListImplement.Models
{ {
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int Id { get; private set; } public int Id { get; private set; }
public int ProductId { get; private set; } public int PizzaId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@ -23,7 +23,7 @@ namespace BankExecutorListImplement.Models
return new Order() return new Order()
{ {
Id = model.Id, Id = model.Id,
ProductId = model.ProductId, PizzaId = model.PizzaId,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -37,21 +37,16 @@ namespace BankExecutorListImplement.Models
{ {
return; return;
} }
ProductId= model.ProductId; Status = model.Status;
Count= model.Count;
Sum= model.Sum;
Status= model.Status;
DateCreate= model.DateCreate;
DateImplement= model.DateImplement;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,
ProductId = ProductId, PizzaId = PizzaId,
Count= Count, Count = Count,
Sum= Sum, Sum = Sum,
Status= Status, Status = Status,
DateCreate= DateCreate, DateCreate = DateCreate,
DateImplement = DateImplement, DateImplement = DateImplement,
}; };
} }

View File

@ -0,0 +1,45 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.ViewModels;
using PizzeriaDataModels.Models;
namespace PizzeriaListImplement.Models
{
public class Pizza : IPizzaModel
{
public int Id { get; private set; }
public string PizzaName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> PizzaComponents { get; private set;} = new Dictionary<int, (IComponentModel, int)>();
public static Pizza? Create(PizzaBindingModel? model)
{
if (model == null)
{
return null;
}
return new Pizza()
{
Id = model.Id,
PizzaName = model.PizzaName,
Price = model.Price,
PizzaComponents = model.PizzaComponents,
};
}
public void Update(PizzaBindingModel? model)
{
if (model == null)
{
return;
}
PizzaName = model.PizzaName;
Price = model.Price;
PizzaComponents = model.PizzaComponents;
}
public PizzaViewModel GetViewModel => new()
{
Id = Id,
PizzaName = PizzaName,
Price = Price,
PizzaComponents = PizzaComponents
};
}
}

View File

@ -7,8 +7,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\AbstractBankDataModels\BankExecutorDataModels.csproj" /> <ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
<ProjectReference Include="..\BankExecutorContracts\BankExecutorContracts.csproj" /> <ProjectReference Include="..\PizzeriaContracts\PizzeriaContracts.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>