готово

This commit is contained in:
ker73rus 2023-03-09 08:39:13 +04:00
parent c7f95787bd
commit 24d535afbf
79 changed files with 3408 additions and 710 deletions

View File

@ -1,7 +0,0 @@
namespace BusinessLogic
{
public class Class1
{
}
}

View File

@ -0,0 +1,152 @@
namespace SecureShopView
{
partial class FormCreateOrder
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelName = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.labelSum = new System.Windows.Forms.Label();
this.comboBoxSecure = new System.Windows.Forms.ComboBox();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.textBoxSum = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(12, 18);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(136, 15);
this.labelName.TabIndex = 0;
this.labelName.Text = "Система безопасности:";
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(12, 53);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(75, 15);
this.labelCount.TabIndex = 1;
this.labelCount.Text = "Количество:";
//
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(12, 87);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(48, 15);
this.labelSum.TabIndex = 2;
this.labelSum.Text = "Сумма:";
//
// comboBoxSecure
//
this.comboBoxSecure.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSecure.FormattingEnabled = true;
this.comboBoxSecure.Location = new System.Drawing.Point(150, 15);
this.comboBoxSecure.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxSecure.Name = "comboBoxSecure";
this.comboBoxSecure.Size = new System.Drawing.Size(230, 23);
this.comboBoxSecure.TabIndex = 3;
this.comboBoxSecure.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSecure_SelectedIndexChanged);
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(150, 50);
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(230, 23);
this.textBoxCount.TabIndex = 4;
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
//
// textBoxSum
//
this.textBoxSum.Enabled = false;
this.textBoxSum.Location = new System.Drawing.Point(150, 84);
this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.Size = new System.Drawing.Size(230, 23);
this.textBoxSum.TabIndex = 5;
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(209, 123);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22);
this.buttonSave.TabIndex = 6;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(297, 123);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormCreateOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(394, 159);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxSum);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.comboBoxSecure);
this.Controls.Add(this.labelSum);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelName);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormCreateOrder";
this.Text = "Заказ";
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelName;
private Label labelCount;
private Label labelSum;
private ComboBox comboBoxSecure;
private TextBox textBoxCount;
private TextBox textBoxSum;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,118 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace SecureShopView
{
public partial class FormCreateOrder : Form
{
private readonly ILogger _logger;
private readonly ISecureLogic _logicI;
private readonly IOrderLogic _logicO;
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISecureLogic logicI, IOrderLogic logicO)
{
InitializeComponent();
_logger = logger;
_logicI = logicI;
_logicO = logicO;
}
private void FormCreateOrder_Load(object sender, EventArgs e)
{
_logger.LogInformation("Загрузка списка мороженого для заказа");
try
{
var list = _logicI.ReadList(null);
if (list != null)
{
comboBoxSecure.DisplayMember = "SecureName";
comboBoxSecure.ValueMember = "Id";
comboBoxSecure.DataSource = list;
comboBoxSecure.SelectedItem = null;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка мороженого");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CalcSum()
{
if (comboBoxSecure.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
{
try
{
int id = Convert.ToInt32(comboBoxSecure.SelectedValue);
var Secure = _logicI.ReadElement(new SecureSearchModel
{
Id = id
});
int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (Secure?.Price ?? 0), 2).ToString();
_logger.LogInformation("Расчет суммы заказа");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка расчета суммы заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void TextBoxCount_TextChanged(object sender, EventArgs e)
{
CalcSum();
}
private void ComboBoxSecure_SelectedIndexChanged(object sender, EventArgs e)
{
CalcSum();
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxSecure.SelectedValue == null)
{
MessageBox.Show("Выберите мороженое", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание заказа");
try
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
SecureId = Convert.ToInt32(comboBoxSecure.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text)
});
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

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

@ -0,0 +1,124 @@
namespace SecureShopView
{
partial class FormFacilitie
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelFacilitiesName = new System.Windows.Forms.Label();
this.labelCost = new System.Windows.Forms.Label();
this.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxCost = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelFacilitiesName
//
this.labelFacilitiesName.AutoSize = true;
this.labelFacilitiesName.Location = new System.Drawing.Point(27, 14);
this.labelFacilitiesName.Name = "labelFacilitiesName";
this.labelFacilitiesName.Size = new System.Drawing.Size(62, 15);
this.labelFacilitiesName.TabIndex = 0;
this.labelFacilitiesName.Text = "Название:";
//
// labelCost
//
this.labelCost.AutoSize = true;
this.labelCost.Location = new System.Drawing.Point(27, 73);
this.labelCost.Name = "labelCost";
this.labelCost.Size = new System.Drawing.Size(38, 15);
this.labelCost.TabIndex = 1;
this.labelCost.Text = "Цена:";
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(127, 12);
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(263, 23);
this.textBoxName.TabIndex = 2;
//
// textBoxCost
//
this.textBoxCost.Location = new System.Drawing.Point(127, 70);
this.textBoxCost.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxCost.Name = "textBoxCost";
this.textBoxCost.Size = new System.Drawing.Size(128, 23);
this.textBoxCost.TabIndex = 3;
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(127, 116);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(254, 116);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormFacilitie
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(454, 155);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxCost);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelCost);
this.Controls.Add(this.labelFacilitiesName);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormFacilitie";
this.Text = "Оборудование";
this.Load += new System.EventHandler(this.FormFacilities_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelFacilitiesName;
private Label labelCost;
private TextBox textBoxName;
private TextBox textBoxCost;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,86 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace SecureShopView
{
public partial class FormFacilitie : Form
{
private readonly ILogger _logger;
private readonly IFacilitiesLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormFacilitie(ILogger<FormFacilitie> logger, IFacilitiesLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormFacilities_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение добавки");
var view = _logic.ReadElement(new FacilitiesSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.FacilitiesName;
textBoxCost.Text = view.Cost.ToString();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения добавки");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение добавки");
try
{
var model = new FacilitiesBindingModel
{
Id = _id ?? 0,
FacilitiesName = textBoxName.Text,
Cost = Convert.ToDouble(textBoxCost.Text)
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения добавки");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

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

@ -0,0 +1,121 @@
namespace SecureShopView
{
partial class FormFacilitiess
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(10, 9);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(444, 320);
this.dataGridView.TabIndex = 0;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(471, 9);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(133, 22);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(471, 35);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(133, 22);
this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(471, 62);
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(133, 22);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(471, 88);
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(133, 22);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// FormFacilitiess
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(614, 338);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormFacilitiess";
this.Text = "Оборудования";
this.Load += new System.EventHandler(this.FormFacilitiess_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonRef;
}
}

View File

@ -0,0 +1,105 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace SecureShopView
{
public partial class FormFacilitiess : Form
{
private readonly ILogger _logger;
private readonly IFacilitiesLogic _logic;
public FormFacilitiess(ILogger<FormFacilitiess> logger, IFacilitiesLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormFacilitiess_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["FacilitiesName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка добавок");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки добавок");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormFacilitie));
if (service is FormFacilitie form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormFacilitie));
if (service is FormFacilitie form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление добавки");
try
{
if (!_logic.Delete(new FacilitiesBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления добавки");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

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>

184
Secure/IceCreamShop/FormMain.Designer.cs generated Normal file
View File

@ -0,0 +1,184 @@
namespace SecureShopView
{
partial class FormMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FacilitiessToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SecuresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
this.buttonOrderReady = new System.Windows.Forms.Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// menuStrip
//
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
this.menuStrip.Size = new System.Drawing.Size(997, 24);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "Справочники";
//
// справочникиToolStripMenuItem
//
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FacilitiessToolStripMenuItem,
this.SecuresToolStripMenuItem});
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
this.справочникиToolStripMenuItem.Text = "Справочники";
//
// FacilitiessToolStripMenuItem
//
this.FacilitiessToolStripMenuItem.Name = "FacilitiessToolStripMenuItem";
this.FacilitiessToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
this.FacilitiessToolStripMenuItem.Text = "Оборудование";
this.FacilitiessToolStripMenuItem.Click += new System.EventHandler(this.FacilitiessToolStripMenuItem_Click);
//
// SecuresToolStripMenuItem
//
this.SecuresToolStripMenuItem.Name = "SecuresToolStripMenuItem";
this.SecuresToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
this.SecuresToolStripMenuItem.Text = "Система Безопасности";
this.SecuresToolStripMenuItem.Click += new System.EventHandler(this.SecuresToolStripMenuItem_Click);
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
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.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(801, 305);
this.dataGridView.TabIndex = 1;
//
// buttonCreateOrder
//
this.buttonCreateOrder.Location = new System.Drawing.Point(816, 34);
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(170, 22);
this.buttonCreateOrder.TabIndex = 2;
this.buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
//
// buttonTakeOrderInWork
//
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(816, 60);
this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(170, 22);
this.buttonTakeOrderInWork.TabIndex = 3;
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
//
// buttonOrderReady
//
this.buttonOrderReady.Location = new System.Drawing.Point(816, 86);
this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.Size = new System.Drawing.Size(170, 22);
this.buttonOrderReady.TabIndex = 4;
this.buttonOrderReady.Text = "Заказ готов";
this.buttonOrderReady.UseVisualStyleBackColor = true;
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
//
// buttonIssuedOrder
//
this.buttonIssuedOrder.Location = new System.Drawing.Point(816, 112);
this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.Size = new System.Drawing.Size(170, 22);
this.buttonIssuedOrder.TabIndex = 5;
this.buttonIssuedOrder.Text = "Заказ выдан";
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(816, 138);
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(170, 22);
this.buttonRef.TabIndex = 6;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(997, 338);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonIssuedOrder);
this.Controls.Add(this.buttonOrderReady);
this.Controls.Add(this.buttonTakeOrderInWork);
this.Controls.Add(this.buttonCreateOrder);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormMain";
this.Text = "Магазин систем безопасности";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem FacilitiessToolStripMenuItem;
private ToolStripMenuItem SecuresToolStripMenuItem;
private DataGridView dataGridView;
private Button buttonCreateOrder;
private Button buttonTakeOrderInWork;
private Button buttonOrderReady;
private Button buttonIssuedOrder;
private Button buttonRef;
}
}

View File

@ -0,0 +1,158 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopDataModels.Enums;
using Microsoft.Extensions.Logging;
namespace SecureShopView
{
public partial class FormMain : Form
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["SecureId"].Visible = false;
dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FacilitiessToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormFacilitiess));
if (service is FormFacilitiess form)
{
form.ShowDialog();
}
}
private void SecuresToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSecures));
if (service is FormSecures form)
{
form.ShowDialog();
}
}
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.ShowDialog();
LoadData();
}
}
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
{
Id = id
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonOrderReady_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try
{
var operationResult = _orderLogic.OrderReady(new OrderBindingModel
{
Id = id
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
var operationResult = _orderLogic.IssuedOrder(new OrderBindingModel
{
Id = id
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
_logger.LogInformation("Заказ №{id} выдан", id);
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,63 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

245
Secure/IceCreamShop/FormSecure.Designer.cs generated Normal file
View File

@ -0,0 +1,245 @@
namespace SecureShopView
{
partial class FormSecure
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelName = new System.Windows.Forms.Label();
this.labelPrice = new System.Windows.Forms.Label();
this.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxPrice = new System.Windows.Forms.TextBox();
this.groupBoxFacilitiess = new System.Windows.Forms.GroupBox();
this.buttonRef = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnFacilitiesName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBoxFacilitiess.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(10, 7);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(62, 15);
this.labelName.TabIndex = 0;
this.labelName.Text = "Название:";
//
// labelPrice
//
this.labelPrice.AutoSize = true;
this.labelPrice.Location = new System.Drawing.Point(10, 34);
this.labelPrice.Name = "labelPrice";
this.labelPrice.Size = new System.Drawing.Size(70, 15);
this.labelPrice.TabIndex = 1;
this.labelPrice.Text = "Стоимость:";
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(86, 4);
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(276, 23);
this.textBoxName.TabIndex = 2;
//
// textBoxPrice
//
this.textBoxPrice.Enabled = false;
this.textBoxPrice.Location = new System.Drawing.Point(86, 29);
this.textBoxPrice.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxPrice.Name = "textBoxPrice";
this.textBoxPrice.Size = new System.Drawing.Size(138, 23);
this.textBoxPrice.TabIndex = 3;
//
// groupBoxFacilitiess
//
this.groupBoxFacilitiess.Controls.Add(this.buttonRef);
this.groupBoxFacilitiess.Controls.Add(this.buttonDel);
this.groupBoxFacilitiess.Controls.Add(this.buttonUpd);
this.groupBoxFacilitiess.Controls.Add(this.buttonAdd);
this.groupBoxFacilitiess.Controls.Add(this.dataGridView);
this.groupBoxFacilitiess.Location = new System.Drawing.Point(13, 62);
this.groupBoxFacilitiess.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxFacilitiess.Name = "groupBoxFacilitiess";
this.groupBoxFacilitiess.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxFacilitiess.Size = new System.Drawing.Size(612, 206);
this.groupBoxFacilitiess.TabIndex = 4;
this.groupBoxFacilitiess.TabStop = false;
this.groupBoxFacilitiess.Text = "Оборудование";
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(456, 98);
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(136, 22);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(456, 72);
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(136, 22);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(456, 46);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(136, 22);
this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(456, 20);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(136, 22);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ID,
this.ColumnFacilitiesName,
this.ColumnCount});
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.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(429, 182);
this.dataGridView.TabIndex = 0;
this.dataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellContentClick);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(312, 284);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(136, 22);
this.buttonSave.TabIndex = 5;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(469, 284);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(136, 22);
this.buttonCancel.TabIndex = 6;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// ID
//
this.ID.HeaderText = "ID";
this.ID.Name = "ID";
this.ID.Visible = false;
//
// ColumnFacilitiesName
//
this.ColumnFacilitiesName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ColumnFacilitiesName.HeaderText = "Оборудование";
this.ColumnFacilitiesName.MinimumWidth = 6;
this.ColumnFacilitiesName.Name = "ColumnFacilitiesName";
this.ColumnFacilitiesName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
//
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
this.ColumnCount.MinimumWidth = 6;
this.ColumnCount.Name = "ColumnCount";
this.ColumnCount.Width = 125;
//
// FormSecure
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(635, 320);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.groupBoxFacilitiess);
this.Controls.Add(this.textBoxPrice);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelPrice);
this.Controls.Add(this.labelName);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormSecure";
this.Text = "Система безопасности";
this.Load += new System.EventHandler(this.FormSecure_Load);
this.groupBoxFacilitiess.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelName;
private Label labelPrice;
private TextBox textBoxName;
private TextBox textBoxPrice;
private GroupBox groupBoxFacilitiess;
private DataGridView dataGridView;
private Button buttonRef;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private Button buttonSave;
private Button buttonCancel;
private DataGridViewTextBoxColumn ID;
private DataGridViewTextBoxColumn ColumnFacilitiesName;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -0,0 +1,213 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.SearchModels;
using SecureShopDataModels.Models;
using Microsoft.Extensions.Logging;
namespace SecureShopView
{
public partial class FormSecure : Form
{
private readonly ILogger _logger;
private readonly ISecureLogic _logic;
private int? _id;
private Dictionary<int, (IFacilitiesModel, int)> _SecureFacilitiess;
public int Id { set { _id = value; } }
public FormSecure(ILogger<FormSecure> logger, ISecureLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
_SecureFacilitiess = new Dictionary<int, (IFacilitiesModel, int)>();
}
private void FormSecure_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
_logger.LogInformation("Загрузка мороженого");
try
{
var view = _logic.ReadElement(new SecureSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.SecureName;
textBoxPrice.Text = view.Price.ToString();
_SecureFacilitiess = view.SecureFacilitiess ?? new Dictionary<int, (IFacilitiesModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки мороженого");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void LoadData()
{
_logger.LogInformation("Загрузка добавок мороженого");
try
{
if (_SecureFacilitiess != null)
{
dataGridView.Rows.Clear();
foreach (var element in _SecureFacilitiess)
{
dataGridView.Rows.Add(new object[] { element.Key, element.Value.Item1.FacilitiesName, element.Value.Item2 });
}
textBoxPrice.Text = CalcPrice().ToString();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки добавок мороженого");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSecureFacilities));
if (service is FormSecureFacilities form)
{
if (form.ShowDialog() == DialogResult.OK)
{
if (form.FacilitiesModel == null)
{
return;
}
_logger.LogInformation("Добавление новой добавки: {FacilitiesName} - {Count}", form.FacilitiesModel.FacilitiesName, form.Count);
if (_SecureFacilitiess.ContainsKey(form.Id))
{
_SecureFacilitiess[form.Id] = (form.FacilitiesModel, form.Count);
}
else
{
_SecureFacilitiess.Add(form.Id, (form.FacilitiesModel, form.Count));
}
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSecureFacilities));
if (service is FormSecureFacilities form)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.Count = _SecureFacilitiess[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
{
if (form.FacilitiesModel == null)
{
return;
}
_logger.LogInformation("Изменение добавки: {FacilitiesName} - {Count}", form.FacilitiesModel.FacilitiesName, form.Count);
_SecureFacilitiess[form.Id] = (form.FacilitiesModel, form.Count);
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
_logger.LogInformation("Удаление добавки:{FacilitiesName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value);
_SecureFacilitiess?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxPrice.Text))
{
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (_SecureFacilitiess == null || _SecureFacilitiess.Count == 0)
{
MessageBox.Show("Заполните добавки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение мороженого");
try
{
var model = new SecureBindingModel
{
Id = _id ?? 0,
SecureName = textBoxName.Text,
Price = Convert.ToDouble(textBoxPrice.Text),
SecureFacilitiess = _SecureFacilitiess
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения мороженого");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private double CalcPrice()
{
double price = 0;
foreach (var elem in _SecureFacilitiess)
{
price += (elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2;
}
return Math.Round(price * 1.1, 2);
}
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}

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

@ -0,0 +1,125 @@
namespace SecureShopView
{
partial class FormSecureFacilities
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelFacilities = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.comboBoxFacilities = new System.Windows.Forms.ComboBox();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelFacilities
//
this.labelFacilities.AutoSize = true;
this.labelFacilities.Location = new System.Drawing.Point(22, 20);
this.labelFacilities.Name = "labelFacilities";
this.labelFacilities.Size = new System.Drawing.Size(92, 15);
this.labelFacilities.TabIndex = 0;
this.labelFacilities.Text = "Обородование:";
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(22, 70);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(75, 15);
this.labelCount.TabIndex = 1;
this.labelCount.Text = "Количество:";
//
// comboBoxFacilities
//
this.comboBoxFacilities.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFacilities.FormattingEnabled = true;
this.comboBoxFacilities.Location = new System.Drawing.Point(128, 20);
this.comboBoxFacilities.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxFacilities.Name = "comboBoxFacilities";
this.comboBoxFacilities.Size = new System.Drawing.Size(282, 23);
this.comboBoxFacilities.TabIndex = 2;
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(128, 68);
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(282, 23);
this.textBoxCount.TabIndex = 3;
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(128, 111);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(125, 22);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(284, 111);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(125, 22);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormSecureFacilities
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(447, 142);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.comboBoxFacilities);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelFacilities);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormSecureFacilities";
this.Text = "Оборудование Системы безопасности";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelFacilities;
private Label labelCount;
private ComboBox comboBoxFacilities;
private TextBox textBoxCount;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,86 @@
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.ViewModels;
using SecureShopDataModels.Models;
namespace SecureShopView
{
public partial class FormSecureFacilities : Form
{
private readonly List<FacilitiesViewModel>? _list;
public int Id
{
get
{
return Convert.ToInt32(comboBoxFacilities.SelectedValue);
}
set
{
comboBoxFacilities.SelectedValue = value;
}
}
public IFacilitiesModel? FacilitiesModel
{
get
{
if (_list == null)
{
return null;
}
foreach (var elem in _list)
{
if (elem.Id == Id)
{
return elem;
}
}
return null;
}
}
public int Count
{
get
{
return Convert.ToInt32(textBoxCount.Text);
}
set
{
textBoxCount.Text = value.ToString();
}
}
public FormSecureFacilities(IFacilitiesLogic logic)
{
InitializeComponent();
_list = logic.ReadList(null);
if (_list != null)
{
comboBoxFacilities.DisplayMember = "FacilitiesName";
comboBoxFacilities.ValueMember = "Id";
comboBoxFacilities.DataSource = _list;
comboBoxFacilities.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxFacilities.SelectedValue == null)
{
MessageBox.Show("Выберите добавку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
DialogResult = DialogResult.OK;
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,121 @@
namespace SecureShopView
{
partial class FormSecures
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(10, 9);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(444, 320);
this.dataGridView.TabIndex = 1;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(466, 9);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(133, 22);
this.buttonAdd.TabIndex = 2;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(466, 35);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(133, 22);
this.buttonUpd.TabIndex = 3;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(466, 62);
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(133, 22);
this.buttonDel.TabIndex = 4;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(466, 88);
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(133, 22);
this.buttonRef.TabIndex = 5;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// FormSecures
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(610, 338);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormSecures";
this.Text = "Системы безопасности";
this.Load += new System.EventHandler(this.FormSecures_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonRef;
}
}

View File

@ -0,0 +1,106 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace SecureShopView
{
public partial class FormSecures : Form
{
private readonly ILogger _logger;
private readonly ISecureLogic _logic;
public FormSecures(ILogger<FormSecures> logger, ISecureLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormSecures_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["SecureFacilitiess"].Visible = false;
dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка мороженых");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки мороженых");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSecure));
if (service is FormSecure form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSecure));
if (service is FormSecure form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление мороженого");
try
{
if (!_logic.Delete(new SecureBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления мороженого");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

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

@ -0,0 +1,52 @@
using SecureShopBusinessLogic.BusinessLogics;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.StoragesContracts;
using SecureShopListImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
namespace SecureShopView
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IFacilitiesStorage, FacilitiesStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<ISecureStorage, SecureStorage>();
services.AddTransient<IFacilitiesLogic, FacilitiesLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ISecureLogic, SecureLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormFacilitie>();
services.AddTransient<FormFacilitiess>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormSecure>();
services.AddTransient<FormSecureFacilities>();
services.AddTransient<FormSecures>();
}
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IceCreamShopBusinessLogic\SecureShopBusinessLogic.csproj" />
<ProjectReference Include="..\IceCreamShopContracts\SecureShopContracts.csproj" />
<ProjectReference Include="..\IceCreamShopListImplement\SecureShopListImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,114 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.SearchModels;
using SecureShopContracts.StoragesContracts;
using SecureShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace SecureShopBusinessLogic.BusinessLogics
{
public class FacilitiesLogic : IFacilitiesLogic
{
private readonly ILogger _logger;
private readonly IFacilitiesStorage _FacilitiesStorage;
public FacilitiesLogic(ILogger<FacilitiesLogic> logger, IFacilitiesStorage FacilitiesStorage)
{
_logger = logger;
_FacilitiesStorage = FacilitiesStorage;
}
public List<FacilitiesViewModel>? ReadList(FacilitiesSearchModel? model)
{
_logger.LogInformation("ReadList. FacilitiesName:{FacilitiesName}. Id:{Id}", model?.FacilitiesName, model?.Id);
var list = model == null ? _FacilitiesStorage.GetFullList() : _FacilitiesStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public FacilitiesViewModel? ReadElement(FacilitiesSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. FacilitiesName:{FacilitiesName}. Id:{Id}", model.FacilitiesName, model.Id);
var element = _FacilitiesStorage.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(FacilitiesBindingModel model)
{
CheckModel(model);
if (_FacilitiesStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(FacilitiesBindingModel model)
{
CheckModel(model);
if (_FacilitiesStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(FacilitiesBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_FacilitiesStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(FacilitiesBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.FacilitiesName))
{
throw new ArgumentNullException("Нет названия оборудования", nameof(model.FacilitiesName));
}
if (model.Cost <= 0)
{
throw new ArgumentNullException("Цена оборудования должна быть больше 0", nameof(model.Cost));
}
_logger.LogInformation("Facilities. FacilitiesName:{FacilitiesName}. Cost:{Cost}. Id: {Id}", model.FacilitiesName, model.Cost, model.Id);
var element = _FacilitiesStorage.GetElement(new FacilitiesSearchModel
{
FacilitiesName = model.FacilitiesName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Оборудование с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,126 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.SearchModels;
using SecureShopContracts.StoragesContracts;
using SecureShopContracts.ViewModels;
using SecureShopDataModels.Enums;
using Microsoft.Extensions.Logging;
namespace SecureShopBusinessLogic.BusinessLogics
{
public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
{
_logger = logger;
_orderStorage = orderStorage;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
_logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.SecureId < 0)
{
throw new ArgumentNullException("Нет системы безопасности с таким ид", nameof(model.SecureId));
}
if (model.Count <= 0)
{
throw new ArgumentNullException("Количество систем безопасности в заказе должно быть больше 0", nameof(model.Count));
}
if (model.Sum <= 0)
{
throw new ArgumentException("Сумма заказа должна быть больше 0", nameof(model.Sum));
}
_logger.LogInformation("Order. OrderId: {Id}. SecureId: {SecureId}. Count: {Count} Sum: {Sum}.", model.Id, model.SecureId, model.Count, model.Sum);
}
public bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Неизвестен)
{
_logger.LogWarning("Insert operation failed");
return false;
}
model.Status = OrderStatus.Принят;
if (_orderStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
{
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (viewModel == null)
{
throw new ArgumentNullException(nameof(model));
}
if (viewModel.Status + 1 != newStatus)
{
_logger.LogWarning("Change status operation failed");
return false;
}
model.Status = newStatus;
model.SecureId = viewModel.SecureId;
model.Count = viewModel.Count;
model.Sum = viewModel.Sum;
model.DateCreate = viewModel.DateCreate;
if (model.Status == OrderStatus.Готов)
{
model.DateImplement = DateTime.Now;
}
else
{
model.DateImplement = viewModel.DateImplement;
}
CheckModel(model);
if (_orderStorage.Update(model) == null)
{
_logger.LogWarning("Change status operation failed");
return false;
}
return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
return ChangeStatus(model, OrderStatus.Выполняется);
}
public bool IssuedOrder(OrderBindingModel model)
{
return ChangeStatus(model, OrderStatus.Выдан);
}
public bool OrderReady(OrderBindingModel model)
{
return ChangeStatus(model, OrderStatus.Готов);
}
}
}

View File

@ -0,0 +1,114 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.SearchModels;
using SecureShopContracts.StoragesContracts;
using SecureShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace SecureShopBusinessLogic.BusinessLogics
{
public class SecureLogic : ISecureLogic
{
private readonly ILogger _logger;
private readonly ISecureStorage _SecureStorage;
public SecureLogic(ILogger<SecureLogic> logger, ISecureStorage SecureStorage)
{
_logger = logger;
_SecureStorage = SecureStorage;
}
public List<SecureViewModel>? ReadList(SecureSearchModel? model)
{
_logger.LogInformation("ReadList. SecureName:{SecureName}.Id:{Id}", model?.SecureName, model?.Id);
var list = model == null ? _SecureStorage.GetFullList() : _SecureStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public SecureViewModel? ReadElement(SecureSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. SecureName:{SecureName}. Id:{Id}", model.SecureName, model.Id);
var element = _SecureStorage.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(SecureBindingModel model)
{
CheckModel(model);
if (_SecureStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(SecureBindingModel model)
{
CheckModel(model);
if (_SecureStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(SecureBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_SecureStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(SecureBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.SecureName))
{
throw new ArgumentNullException("Нет названия Сиситемы безопасности ", nameof(model.SecureName));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена Сиситемы безопасности должна быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Secure. SecureName:{SecureName}. Cost:{Cost}. Id: {Id}", model.SecureName, model.Price, model.Id);
var element = _SecureStorage.GetElement(new SecureSearchModel
{
SecureName = model.SecureName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Сиситема безопасности с таким названием уже есть");
}
}
}
}

View File

@ -11,7 +11,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SecureShopContracts\SecureShopContracts\SecureShopContracts.csproj" />
<ProjectReference Include="..\IceCreamShopContracts\SecureShopContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -1,11 +1,11 @@
using SecureShopDataModels.Models;
namespace SecureShopContracts.BindingModels
{
public class ComponentBindingModel : IComponentModel
public class FacilitiesBindingModel : IFacilitiesModel
{
public int Id { get; set; }
public string ComponentName { get; set; } = string.Empty;
public string FacilitiesName { get; set; } = string.Empty;
public double Cost { get; set; }
}
}

View File

@ -1,10 +1,5 @@
using SecureShopDataModels.Enum;
using SecureShopDataModels.Enums;
using SecureShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.BindingModels
{
@ -18,5 +13,4 @@ namespace SecureShopContracts.BindingModels
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; }
}
}
}

View File

@ -1,9 +1,4 @@
using SecureShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.BindingModels
{
@ -12,10 +7,6 @@ namespace SecureShopContracts.BindingModels
public int Id { get; set; }
public string SecureName { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> SecureComponents
{
get;
set;
} = new();
public Dictionary<int, (IFacilitiesModel, int)> SecureFacilitiess { get; set; } = new();
}
}
}

View File

@ -0,0 +1,15 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.ViewModels;
namespace SecureShopContracts.BusinessLogicsContracts
{
public interface IFacilitiesLogic
{
List<FacilitiesViewModel>? ReadList(FacilitiesSearchModel? model);
FacilitiesViewModel? ReadElement(FacilitiesSearchModel model);
bool Create(FacilitiesBindingModel model);
bool Update(FacilitiesBindingModel model);
bool Delete(FacilitiesBindingModel model);
}
}

View File

@ -1,11 +1,6 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.BusinessLogicsContracts
{
@ -14,7 +9,7 @@ namespace SecureShopContracts.BusinessLogicsContracts
List<OrderViewModel>? ReadList(OrderSearchModel? model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
bool OrderReady(OrderBindingModel model);
bool IssuedOrder(OrderBindingModel model);
}
}
}

View File

@ -1,11 +1,6 @@
using SecureShopContracts.SearchModels;
using SecureShopContracts.BindingModels;
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.BusinessLogicsContracts
{
@ -17,5 +12,4 @@ namespace SecureShopContracts.BusinessLogicsContracts
bool Update(SecureBindingModel model);
bool Delete(SecureBindingModel model);
}
}
}

View File

@ -0,0 +1,8 @@
namespace SecureShopContracts.SearchModels
{
public class FacilitiesSearchModel
{
public int? Id { get; set; }
public string? FacilitiesName { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace SecureShopContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace SecureShopContracts.SearchModels
{
public class SecureSearchModel
{
public int? Id { get; set; }
public string? SecureName { get; set; }
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\SecureShopDataModels\SecureShopDataModels\SecureShopDataModels.csproj" />
<ProjectReference Include="..\IceCreamShopDataModels\SecureShopDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,16 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.ViewModels;
namespace SecureShopContracts.StoragesContracts
{
public interface IFacilitiesStorage
{
List<FacilitiesViewModel> GetFullList();
List<FacilitiesViewModel> GetFilteredList(FacilitiesSearchModel model);
FacilitiesViewModel? GetElement(FacilitiesSearchModel model);
FacilitiesViewModel? Insert(FacilitiesBindingModel model);
FacilitiesViewModel? Update(FacilitiesBindingModel model);
FacilitiesViewModel? Delete(FacilitiesBindingModel model);
}
}

View File

@ -1,13 +1,8 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.StorageContracts
namespace SecureShopContracts.StoragesContracts
{
public interface IOrderStorage
{
@ -18,5 +13,4 @@ namespace SecureShopContracts.StorageContracts
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
}
}
}

View File

@ -1,13 +1,8 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.StorageContracts
namespace SecureShopContracts.StoragesContracts
{
public interface ISecureStorage
{
@ -18,4 +13,4 @@ namespace SecureShopContracts.StorageContracts
SecureViewModel? Update(SecureBindingModel model);
SecureViewModel? Delete(SecureBindingModel model);
}
}
}

View File

@ -0,0 +1,16 @@
using SecureShopDataModels.Models;
using System.ComponentModel;
namespace SecureShopContracts.ViewModels
{
public class FacilitiesViewModel : IFacilitiesModel
{
public int Id { get; set; }
[DisplayName("Название оборудования")]
public string FacilitiesName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Cost { get; set; }
}
}

View File

@ -1,11 +1,6 @@
using SecureShopDataModels.Enum;
using SecureShopDataModels.Enums;
using SecureShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.ViewModels
{
@ -13,19 +8,25 @@ namespace SecureShopContracts.ViewModels
{
[DisplayName("Номер")]
public int Id { get; set; }
public int SecureId { get; set; }
[DisplayName("Изделие")]
[DisplayName("Система безопасности")]
public string SecureName { get; set; } = string.Empty;
[DisplayName("Количество")]
public int Count { get; set; }
[DisplayName("Сумма")]
public double Sum { get; set; }
[DisplayName("Статус")]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; }
}
}
}

View File

@ -1,25 +1,18 @@
using SecureShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.ViewModels
{
public class SecureViewModel : ISecureModel
{
public int Id { get; set; }
[DisplayName("Название изделия")]
[DisplayName("Название Сиситемы безопасности")]
public string SecureName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> SecureComponents
{
get;
set;
} = new();
}
}
public Dictionary<int, (IFacilitiesModel, int)> SecureFacilitiess { get; set; } = new();
}
}

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopDataModels.Enum
namespace SecureShopDataModels.Enums
{
public enum OrderStatus
{
@ -13,6 +7,5 @@ namespace SecureShopDataModels.Enum
Выполняется = 1,
Готов = 2,
Выдан = 3
}
}
}

View File

@ -0,0 +1,7 @@
namespace SecureShopDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,8 @@
namespace SecureShopDataModels.Models
{
public interface IFacilitiesModel : IId
{
string FacilitiesName { get; }
double Cost { get; }
}
}

View File

@ -1,13 +1,8 @@
using SecureShopDataModels.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SecureShopDataModels.Enums;
namespace SecureShopDataModels.Models
{
public interface IOrderModel:IId
public interface IOrderModel : IId
{
int SecureId { get; }
int Count { get; }
@ -16,4 +11,4 @@ namespace SecureShopDataModels.Models
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
}
}
}

View File

@ -0,0 +1,9 @@
namespace SecureShopDataModels.Models
{
public interface ISecureModel : IId
{
string SecureName { get; }
double Price { get; }
Dictionary<int, (IFacilitiesModel, int)> SecureFacilitiess { get; }
}
}

View File

@ -1,24 +1,21 @@
using SecureShopListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopListImplement
{
public class DataListSingleton
{
private static DataListSingleton? _instance;
public List<Component> Components { get; set; }
public List<Facilities> Facilitiess { get; set; }
public List<Order> Orders { get; set; }
public List<Secure> Products { get; set; }
public List<Secure> Secures { get; set; }
private DataListSingleton()
{
Components = new List<Component>();
Facilitiess = new List<Facilities>();
Orders = new List<Order>();
Products = new List<Secure>();
Secures = new List<Secure>();
}
public static DataListSingleton GetInstance()
{
if (_instance == null)
@ -28,4 +25,4 @@ namespace SecureShopListImplement
return _instance;
}
}
}
}

View File

@ -0,0 +1,107 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.StoragesContracts;
using SecureShopContracts.ViewModels;
using SecureShopListImplement.Models;
namespace SecureShopListImplement.Implements
{
public class FacilitiesStorage : IFacilitiesStorage
{
private readonly DataListSingleton _source;
public FacilitiesStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<FacilitiesViewModel> GetFullList()
{
var result = new List<FacilitiesViewModel>();
foreach (var Facilities in _source.Facilitiess)
{
result.Add(Facilities.GetViewModel);
}
return result;
}
public List<FacilitiesViewModel> GetFilteredList(FacilitiesSearchModel model)
{
var result = new List<FacilitiesViewModel>();
if (string.IsNullOrEmpty(model.FacilitiesName))
{
return result;
}
foreach (var Facilities in _source.Facilitiess)
{
if (Facilities.FacilitiesName.Contains(model.FacilitiesName))
{
result.Add(Facilities.GetViewModel);
}
}
return result;
}
public FacilitiesViewModel? GetElement(FacilitiesSearchModel model)
{
if (string.IsNullOrEmpty(model.FacilitiesName) && !model.Id.HasValue)
{
return null;
}
foreach (var Facilities in _source.Facilitiess)
{
if ((!string.IsNullOrEmpty(model.FacilitiesName) && Facilities.FacilitiesName == model.FacilitiesName) || (model.Id.HasValue && Facilities.Id == model.Id))
{
return Facilities.GetViewModel;
}
}
return null;
}
public FacilitiesViewModel? Insert(FacilitiesBindingModel model)
{
model.Id = 1;
foreach (var Facilities in _source.Facilitiess)
{
if (model.Id <= Facilities.Id)
{
model.Id = Facilities.Id + 1;
}
}
var newFacilities = Facilities.Create(model);
if (newFacilities == null)
{
return null;
}
_source.Facilitiess.Add(newFacilities);
return newFacilities.GetViewModel;
}
public FacilitiesViewModel? Update(FacilitiesBindingModel model)
{
foreach (var Facilities in _source.Facilitiess)
{
if (Facilities.Id == model.Id)
{
Facilities.Update(model);
return Facilities.GetViewModel;
}
}
return null;
}
public FacilitiesViewModel? Delete(FacilitiesBindingModel model)
{
for (int i = 0; i < _source.Facilitiess.Count; ++i)
{
if (_source.Facilitiess[i].Id == model.Id)
{
var element = _source.Facilitiess[i];
_source.Facilitiess.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -0,0 +1,121 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.StoragesContracts;
using SecureShopContracts.ViewModels;
using SecureShopListImplement.Models;
namespace SecureShopListImplement.Implements
{
public class OrderStorage : IOrderStorage
{
private readonly DataListSingleton _source;
public OrderStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<OrderViewModel> GetFullList()
{
var result = new List<OrderViewModel>();
foreach (var order in _source.Orders)
{
result.Add(GetViewModel(order));
}
return result;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (!model.Id.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
result.Add(GetViewModel(order));
}
}
return result;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
return GetViewModel(order);
}
}
return null;
}
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var Secure in _source.Secures)
{
if (Secure.Id == order.SecureId)
{
viewModel.SecureName = Secure.SecureName;
break;
}
}
return viewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)
{
model.Id = 1;
foreach (var order in _source.Orders)
{
if (model.Id <= order.Id)
{
model.Id = order.Id + 1;
}
}
var newOrder = Order.Create(model);
if (newOrder == null)
{
return null;
}
_source.Orders.Add(newOrder);
return GetViewModel(newOrder);
}
public OrderViewModel? Update(OrderBindingModel model)
{
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
order.Update(model);
return GetViewModel(order);
}
}
return null;
}
public OrderViewModel? Delete(OrderBindingModel model)
{
for (int i = 0; i < _source.Orders.Count; ++i)
{
if (_source.Orders[i].Id == model.Id)
{
var element = _source.Orders[i];
_source.Orders.RemoveAt(i);
return GetViewModel(element);
}
}
return null;
}
}
}

View File

@ -0,0 +1,107 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.StoragesContracts;
using SecureShopContracts.ViewModels;
using SecureShopListImplement.Models;
namespace SecureShopListImplement.Implements
{
public class SecureStorage : ISecureStorage
{
private readonly DataListSingleton _source;
public SecureStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<SecureViewModel> GetFullList()
{
var result = new List<SecureViewModel>();
foreach (var Secure in _source.Secures)
{
result.Add(Secure.GetViewModel);
}
return result;
}
public List<SecureViewModel> GetFilteredList(SecureSearchModel model)
{
var result = new List<SecureViewModel>();
if (string.IsNullOrEmpty(model.SecureName))
{
return result;
}
foreach (var Secure in _source.Secures)
{
if (Secure.SecureName.Contains(model.SecureName))
{
result.Add(Secure.GetViewModel);
}
}
return result;
}
public SecureViewModel? GetElement(SecureSearchModel model)
{
if (string.IsNullOrEmpty(model.SecureName) && !model.Id.HasValue)
{
return null;
}
foreach (var Secure in _source.Secures)
{
if ((!string.IsNullOrEmpty(model.SecureName) && Secure.SecureName == model.SecureName) || (model.Id.HasValue && Secure.Id == model.Id))
{
return Secure.GetViewModel;
}
}
return null;
}
public SecureViewModel? Insert(SecureBindingModel model)
{
model.Id = 1;
foreach (var Secure in _source.Secures)
{
if (model.Id <= Secure.Id)
{
model.Id = Secure.Id + 1;
}
}
var newSecure = Secure.Create(model);
if (newSecure == null)
{
return null;
}
_source.Secures.Add(newSecure);
return newSecure.GetViewModel;
}
public SecureViewModel? Update(SecureBindingModel model)
{
foreach (var Secure in _source.Secures)
{
if (Secure.Id == model.Id)
{
Secure.Update(model);
return Secure.GetViewModel;
}
}
return null;
}
public SecureViewModel? Delete(SecureBindingModel model)
{
for (int i = 0; i < _source.Secures.Count; ++i)
{
if (_source.Secures[i].Id == model.Id)
{
var element = _source.Secures[i];
_source.Secures.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -4,39 +4,41 @@ using SecureShopDataModels.Models;
namespace SecureShopListImplement.Models
{
public class Component : IComponentModel
public class Facilities : IFacilitiesModel
{
public int Id { get; private set; }
public string ComponentName { get; private set; } = string.Empty;
public string FacilitiesName { get; private set; } = string.Empty;
public double Cost { get; set; }
public static Component? Create(ComponentBindingModel? model)
public static Facilities? Create(FacilitiesBindingModel? model)
{
if (model == null)
{
return null;
}
return new Component()
return new Facilities()
{
Id = model.Id,
ComponentName = model.ComponentName,
FacilitiesName = model.FacilitiesName,
Cost = model.Cost
};
}
public void Update(ComponentBindingModel? model)
public void Update(FacilitiesBindingModel? model)
{
if (model == null)
{
return;
}
ComponentName = model.ComponentName;
FacilitiesName = model.FacilitiesName;
Cost = model.Cost;
}
public ComponentViewModel GetViewModel => new()
public FacilitiesViewModel GetViewModel => new()
{
Id = Id,
ComponentName = ComponentName,
FacilitiesName = FacilitiesName,
Cost = Cost
};
}
}

View File

@ -0,0 +1,61 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.ViewModels;
using SecureShopDataModels.Enums;
using SecureShopDataModels.Models;
namespace SecureShopListImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; private set; }
public int SecureId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; }
public DateTime DateCreate { get; private set; }
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
Id = model.Id,
SecureId = model.SecureId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
};
}
public void Update(OrderBindingModel? model)
{
if (model == null)
{
return;
}
SecureId = model.SecureId;
Count = model.Count;
Sum = model.Sum;
Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
SecureId = SecureId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
}
}

View File

@ -1,11 +1,6 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.ViewModels;
using SecureShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopListImplement.Models
{
@ -14,11 +9,8 @@ namespace SecureShopListImplement.Models
public int Id { get; private set; }
public string SecureName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> SecureComponents
{
get;
private set;
} = new Dictionary<int, (IComponentModel, int)>();
public Dictionary<int, (IFacilitiesModel, int)> SecureFacilitiess{ get; private set; } = new Dictionary<int, (IFacilitiesModel, int)>();
public static Secure? Create(SecureBindingModel? model)
{
if (model == null)
@ -27,12 +19,13 @@ namespace SecureShopListImplement.Models
}
return new Secure()
{
Id = model.Id,
SecureName = model.SecureName,
Price = model.Price,
SecureComponents = model.SecureComponents
Id = model.Id,
SecureName = model.SecureName,
Price = model.Price,
SecureFacilitiess = model.SecureFacilitiess
};
}
public void Update(SecureBindingModel? model)
{
if (model == null)
@ -41,14 +34,15 @@ namespace SecureShopListImplement.Models
}
SecureName = model.SecureName;
Price = model.Price;
SecureComponents = model.SecureComponents;
SecureFacilitiess = model.SecureFacilitiess;
}
public SecureViewModel GetViewModel => new()
{
Id = Id,
SecureName = SecureName,
Price = Price,
SecureComponents = SecureComponents
SecureFacilitiess = SecureFacilitiess
};
}
}
}

View File

@ -7,8 +7,8 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SecureShopContracts\SecureShopContracts\SecureShopContracts.csproj" />
<ProjectReference Include="..\SecureShopDataModels\SecureShopDataModels\SecureShopDataModels.csproj" />
<ProjectReference Include="..\IceCreamShopContracts\SecureShopContracts.csproj" />
<ProjectReference Include="..\IceCreamShopDataModels\SecureShopDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -1,49 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Secure", "Secure\Secure.csproj", "{12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopContracts", "SecureShopContracts\SecureShopContracts\SecureShopContracts.csproj", "{5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopDataModels", "SecureShopDataModels\SecureShopDataModels\SecureShopDataModels.csproj", "{3278670B-B887-4C00-B8A4-BAEED8C4F020}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureShopBusinessLogic", "SecureShopBusinessLogic\SecureShopBusinessLogic.csproj", "{BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureShopListImplement", "SecureShopListImplement\SecureShopListImplement.csproj", "{52CEC57F-E90F-4406-BB70-2B43B97D2358}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}.Release|Any CPU.Build.0 = Release|Any CPU
{5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}.Release|Any CPU.Build.0 = Release|Any CPU
{3278670B-B887-4C00-B8A4-BAEED8C4F020}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3278670B-B887-4C00-B8A4-BAEED8C4F020}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3278670B-B887-4C00-B8A4-BAEED8C4F020}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3278670B-B887-4C00-B8A4-BAEED8C4F020}.Release|Any CPU.Build.0 = Release|Any CPU
{BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}.Release|Any CPU.Build.0 = Release|Any CPU
{52CEC57F-E90F-4406-BB70-2B43B97D2358}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52CEC57F-E90F-4406-BB70-2B43B97D2358}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52CEC57F-E90F-4406-BB70-2B43B97D2358}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52CEC57F-E90F-4406-BB70-2B43B97D2358}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {91A88ACE-177C-4A5D-BA80-5580140BF7E9}
EndGlobalSection
EndGlobal

View File

@ -1,39 +0,0 @@
namespace Secure
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace Secure
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

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,17 +0,0 @@
namespace Secure
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}

View File

@ -1,11 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

49
Secure/SecureShop.sln Normal file
View File

@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32421.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopView", "IceCreamShop\SecureShopView.csproj", "{5364D1DA-47C2-45E4-9022-DCDEFD5D3BE5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopDataModels", "IceCreamShopDataModels\SecureShopDataModels.csproj", "{565CCA80-81C4-4581-879F-05B870AA8AC9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopContracts", "IceCreamShopContracts\SecureShopContracts.csproj", "{5BED4A3C-2BA8-41AA-8EEA-23F08A77C9DB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopBusinessLogic", "IceCreamShopBusinessLogic\SecureShopBusinessLogic.csproj", "{8863CC31-0B08-4149-8DFF-6BBFC1F65814}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopListImplement", "IceCreamShopListImplement\SecureShopListImplement.csproj", "{91B8625D-ED80-4C09-966E-9C8F46B6477B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5364D1DA-47C2-45E4-9022-DCDEFD5D3BE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5364D1DA-47C2-45E4-9022-DCDEFD5D3BE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5364D1DA-47C2-45E4-9022-DCDEFD5D3BE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5364D1DA-47C2-45E4-9022-DCDEFD5D3BE5}.Release|Any CPU.Build.0 = Release|Any CPU
{565CCA80-81C4-4581-879F-05B870AA8AC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{565CCA80-81C4-4581-879F-05B870AA8AC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{565CCA80-81C4-4581-879F-05B870AA8AC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{565CCA80-81C4-4581-879F-05B870AA8AC9}.Release|Any CPU.Build.0 = Release|Any CPU
{5BED4A3C-2BA8-41AA-8EEA-23F08A77C9DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BED4A3C-2BA8-41AA-8EEA-23F08A77C9DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BED4A3C-2BA8-41AA-8EEA-23F08A77C9DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BED4A3C-2BA8-41AA-8EEA-23F08A77C9DB}.Release|Any CPU.Build.0 = Release|Any CPU
{8863CC31-0B08-4149-8DFF-6BBFC1F65814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8863CC31-0B08-4149-8DFF-6BBFC1F65814}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8863CC31-0B08-4149-8DFF-6BBFC1F65814}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8863CC31-0B08-4149-8DFF-6BBFC1F65814}.Release|Any CPU.Build.0 = Release|Any CPU
{91B8625D-ED80-4C09-966E-9C8F46B6477B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91B8625D-ED80-4C09-966E-9C8F46B6477B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91B8625D-ED80-4C09-966E-9C8F46B6477B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91B8625D-ED80-4C09-966E-9C8F46B6477B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {03723299-E9A9-4557-B252-F7DE584EED8F}
EndGlobalSection
EndGlobal

View File

@ -1,111 +0,0 @@
using Microsoft.Extensions.Logging;
using SecureShopContracts.BindingModels;
using SecureShopContracts.BusinessLogicsContracts;
using SecureShopContracts.SearchModels;
using SecureShopContracts.StorageContracts;
using SecureShopContracts.ViewModels;
namespace SecureShopBusinessLogic.BusinessLogic
{
public class ComponentLogic : IComponentLogic
{
private readonly ILogger _logger;
private readonly IComponentStorage _componentStorage;
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage
componentStorage)
{
_logger = logger;
_componentStorage = componentStorage;
}
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
{
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
var list = model == null ? _componentStorage.GetFullList() :
_componentStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ComponentViewModel? ReadElement(ComponentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id);
var element = _componentStorage.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(ComponentBindingModel model)
{
CheckModel(model);
if (_componentStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ComponentBindingModel model)
{
CheckModel(model);
if (_componentStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ComponentBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_componentStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(ComponentBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ComponentName))
{
throw new ArgumentNullException("Нет названия компонента",
nameof(model.ComponentName));
}
if (model.Cost <= 0)
{
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
}
_logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id);
var element = _componentStorage.GetElement(new ComponentSearchModel
{
ComponentName = model.ComponentName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Компонент с таким названием уже есть");
}
}
}
}

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureShopContracts", "SecureShopContracts\SecureShopContracts.csproj", "{06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E76FFD02-B2F5-428E-950B-132138F2E535}
EndGlobalSection
EndGlobal

View File

@ -1,21 +0,0 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.BusinessLogicsContracts
{
public interface IComponentLogic
{
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
ComponentViewModel? ReadElement(ComponentSearchModel model);
bool Create(ComponentBindingModel model);
bool Update(ComponentBindingModel model);
bool Delete(ComponentBindingModel model);
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.SearchModels
{
public class ComponentSearchModel
{
public int? Id { get; set; }
public string? ComponentName { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.SearchModels
{
public class SecureSearchModel
{
public int? Id { get; set; }
public string? SecureName { get; set; }
}
}

View File

@ -1,22 +0,0 @@
using SecureShopContracts.BindingModels;
using SecureShopContracts.SearchModels;
using SecureShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.StorageContracts
{
public interface IComponentStorage
{
List<ComponentViewModel> GetFullList();
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
ComponentViewModel? GetElement(ComponentSearchModel model);
ComponentViewModel? Insert(ComponentBindingModel model);
ComponentViewModel? Update(ComponentBindingModel model);
ComponentViewModel? Delete(ComponentBindingModel model);
}
}

View File

@ -1,19 +0,0 @@
using SecureShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopContracts.ViewModels
{
public class ComponentViewModel : IComponentModel
{
public int Id { get; set; }
[DisplayName("Название компонента")]
public string ComponentName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Cost { get; set; }
}
}

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureShopDataModels", "SecureShopDataModels\SecureShopDataModels.csproj", "{11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E488F989-C9BB-4B7D-A085-2CA125E0D019}
EndGlobalSection
EndGlobal

View File

@ -1,7 +0,0 @@
namespace SecureShopDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopDataModels.Models
{
public interface IComponentModel:IId
{
string ComponentName { get;}
double Cost { get;}
}
}

View File

@ -1,16 +0,0 @@
using SecureShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopDataModels.Models
{
public interface ISecureModel:IId
{
string SecureName { get; }
double Price { get; }
Dictionary<int, (IComponentModel, int)> SecureComponents { get; }
}
}

View File

@ -1,9 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SecureShopListImplement.Models
{
public class Order
{
}
}