without front
This commit is contained in:
parent
513740d857
commit
91fb395e29
94
SecuritySystem/FormClients.Designer.cs
generated
Normal file
94
SecuritySystem/FormClients.Designer.cs
generated
Normal file
@ -0,0 +1,94 @@
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
partial class FormClients
|
||||
{
|
||||
/// <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.buttonDel = new System.Windows.Forms.Button();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dataGridView.Size = new System.Drawing.Size(350, 312);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
this.buttonDel.Location = new System.Drawing.Point(368, 12);
|
||||
this.buttonDel.Name = "buttonDel";
|
||||
this.buttonDel.Size = new System.Drawing.Size(75, 23);
|
||||
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(368, 53);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonRef.TabIndex = 4;
|
||||
this.buttonRef.Text = "Обновить";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// FormClients
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(464, 312);
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonDel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormClients";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Клиенты";
|
||||
this.Load += new System.EventHandler(this.FormClients_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.DataGridView dataGridView;
|
||||
private System.Windows.Forms.Button buttonDel;
|
||||
private System.Windows.Forms.Button buttonRef;
|
||||
}
|
||||
}
|
78
SecuritySystem/FormClients.cs
Normal file
78
SecuritySystem/FormClients.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
public partial class FormClients : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientLogic _logic;
|
||||
public FormClients(ILogger<FormClients> logger, IClientLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormClients_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["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки клиентов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
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);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ClientBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Удаление клиента");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления клиента");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
176
SecuritySystem/FormCreateOrder.Designer.cs
generated
176
SecuritySystem/FormCreateOrder.Designer.cs
generated
@ -28,107 +28,133 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.labelSecure = new System.Windows.Forms.Label();
|
||||
this.comboBoxSecure = new System.Windows.Forms.ComboBox();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.labelSum = new System.Windows.Forms.Label();
|
||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
labelSecure = new Label();
|
||||
comboBoxSecure = new ComboBox();
|
||||
labelCount = new Label();
|
||||
textBoxCount = new TextBox();
|
||||
labelSum = new Label();
|
||||
textBoxSum = new TextBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
labelClient = new Label();
|
||||
comboBoxClient = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelSecure
|
||||
//
|
||||
this.labelSecure.AutoSize = true;
|
||||
this.labelSecure.Location = new System.Drawing.Point(12, 15);
|
||||
this.labelSecure.Name = "labelSecure";
|
||||
this.labelSecure.Size = new System.Drawing.Size(75, 20);
|
||||
this.labelSecure.TabIndex = 0;
|
||||
this.labelSecure.Text = "Изделие: ";
|
||||
labelSecure.AutoSize = true;
|
||||
labelSecure.Location = new Point(10, 11);
|
||||
labelSecure.Name = "labelSecure";
|
||||
labelSecure.Size = new Size(59, 15);
|
||||
labelSecure.TabIndex = 0;
|
||||
labelSecure.Text = "Изделие: ";
|
||||
//
|
||||
// comboBoxSecure
|
||||
//
|
||||
this.comboBoxSecure.FormattingEnabled = true;
|
||||
this.comboBoxSecure.Location = new System.Drawing.Point(115, 12);
|
||||
this.comboBoxSecure.Name = "comboBoxSecure";
|
||||
this.comboBoxSecure.Size = new System.Drawing.Size(358, 28);
|
||||
this.comboBoxSecure.TabIndex = 1;
|
||||
this.comboBoxSecure.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSecure_SelectedIndexChanged);
|
||||
comboBoxSecure.FormattingEnabled = true;
|
||||
comboBoxSecure.Location = new Point(101, 9);
|
||||
comboBoxSecure.Margin = new Padding(3, 2, 3, 2);
|
||||
comboBoxSecure.Name = "comboBoxSecure";
|
||||
comboBoxSecure.Size = new Size(314, 23);
|
||||
comboBoxSecure.TabIndex = 1;
|
||||
comboBoxSecure.SelectedIndexChanged += ComboBoxSecure_SelectedIndexChanged;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(12, 49);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(97, 20);
|
||||
this.labelCount.TabIndex = 2;
|
||||
this.labelCount.Text = "Количество: ";
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(10, 37);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(78, 15);
|
||||
labelCount.TabIndex = 2;
|
||||
labelCount.Text = "Количество: ";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(115, 46);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(358, 27);
|
||||
this.textBoxCount.TabIndex = 3;
|
||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
||||
textBoxCount.Location = new Point(101, 34);
|
||||
textBoxCount.Margin = new Padding(3, 2, 3, 2);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(314, 23);
|
||||
textBoxCount.TabIndex = 3;
|
||||
textBoxCount.TextChanged += TextBoxCount_TextChanged;
|
||||
//
|
||||
// labelSum
|
||||
//
|
||||
this.labelSum.AutoSize = true;
|
||||
this.labelSum.Location = new System.Drawing.Point(12, 80);
|
||||
this.labelSum.Name = "labelSum";
|
||||
this.labelSum.Size = new System.Drawing.Size(62, 20);
|
||||
this.labelSum.TabIndex = 4;
|
||||
this.labelSum.Text = "Сумма: ";
|
||||
labelSum.AutoSize = true;
|
||||
labelSum.Location = new Point(10, 63);
|
||||
labelSum.Name = "labelSum";
|
||||
labelSum.Size = new Size(51, 15);
|
||||
labelSum.TabIndex = 4;
|
||||
labelSum.Text = "Сумма: ";
|
||||
//
|
||||
// textBoxSum
|
||||
//
|
||||
this.textBoxSum.Location = new System.Drawing.Point(115, 80);
|
||||
this.textBoxSum.Name = "textBoxSum";
|
||||
this.textBoxSum.ReadOnly = true;
|
||||
this.textBoxSum.Size = new System.Drawing.Size(358, 27);
|
||||
this.textBoxSum.TabIndex = 5;
|
||||
textBoxSum.Location = new Point(101, 60);
|
||||
textBoxSum.Margin = new Padding(3, 2, 3, 2);
|
||||
textBoxSum.Name = "textBoxSum";
|
||||
textBoxSum.ReadOnly = true;
|
||||
textBoxSum.Size = new Size(314, 23);
|
||||
textBoxSum.TabIndex = 5;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(337, 113);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(110, 32);
|
||||
this.buttonCancel.TabIndex = 6;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
buttonCancel.Location = new Point(294, 126);
|
||||
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(96, 24);
|
||||
buttonCancel.TabIndex = 6;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(221, 113);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(110, 32);
|
||||
this.buttonSave.TabIndex = 7;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
buttonSave.Location = new Point(192, 126);
|
||||
buttonSave.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(96, 24);
|
||||
buttonSave.TabIndex = 7;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// labelClient
|
||||
//
|
||||
labelClient.AutoSize = true;
|
||||
labelClient.Location = new Point(10, 91);
|
||||
labelClient.Name = "labelClient";
|
||||
labelClient.Size = new Size(49, 15);
|
||||
labelClient.TabIndex = 8;
|
||||
labelClient.Text = "Клиент:";
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
comboBoxClient.FormattingEnabled = true;
|
||||
comboBoxClient.Location = new Point(101, 88);
|
||||
comboBoxClient.Name = "comboBoxClient";
|
||||
comboBoxClient.Size = new Size(314, 23);
|
||||
comboBoxClient.TabIndex = 9;
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(485, 158);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.textBoxSum);
|
||||
this.Controls.Add(this.labelSum);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.comboBoxSecure);
|
||||
this.Controls.Add(this.labelSecure);
|
||||
this.Name = "FormCreateOrder";
|
||||
this.Text = "Заказ";
|
||||
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(424, 161);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(labelClient);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(textBoxSum);
|
||||
Controls.Add(labelSum);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(comboBoxSecure);
|
||||
Controls.Add(labelSecure);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormCreateOrder";
|
||||
Text = "Заказ";
|
||||
Load += FormCreateOrder_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -141,5 +167,7 @@
|
||||
private TextBox textBoxSum;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label labelClient;
|
||||
private ComboBox comboBoxClient;
|
||||
}
|
||||
}
|
@ -1,9 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@ -13,6 +9,14 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
public partial class FormCreateOrder : Form
|
||||
@ -20,24 +24,52 @@ namespace SecuritySystemView
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISecureLogic _logicM;
|
||||
private readonly IOrderLogic _logicO;
|
||||
private readonly IClientLogic _logicC;
|
||||
private List<SecureViewModel>? _list;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISecureLogic logicM, IOrderLogic logicO)
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISecureLogic logicM, IOrderLogic logicO, IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicM = logicM;
|
||||
_logicO = logicO;
|
||||
_logicC = logicC;
|
||||
}
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
_list = _logicM.ReadList(null);
|
||||
if (_list != null)
|
||||
_logger.LogInformation("Загрузка поездок для заказа");
|
||||
try
|
||||
{
|
||||
comboBoxSecure.DisplayMember = "SecureName";
|
||||
comboBoxSecure.ValueMember = "Id";
|
||||
comboBoxSecure.DataSource = _list;
|
||||
comboBoxSecure.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка изделий для заказа");
|
||||
var list = _logicM.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);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка списка клиентов");
|
||||
try
|
||||
{
|
||||
var list = _logicC.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxClient.DisplayMember = "ClientFIO";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxClient.DataSource = list;
|
||||
comboBoxClient.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка клиентов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CalcSum()
|
||||
@ -47,7 +79,7 @@ namespace SecuritySystemView
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxSecure.SelectedValue);
|
||||
var Secure = _logicM.ReadElement(new SecureSearchModel { Id = id });
|
||||
var Secure = _logicM.ReadElement(new SecuresearchModel { Id = id });
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
textBoxSum.Text = Math.Round(count * (Secure?.Price ?? 0), 2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
@ -79,6 +111,11 @@ namespace SecuritySystemView
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxClient.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
@ -86,6 +123,7 @@ namespace SecuritySystemView
|
||||
{
|
||||
SecureId = Convert.ToInt32(comboBoxSecure.SelectedValue),
|
||||
SecureName = comboBoxSecure.Text,
|
||||
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||
});
|
||||
|
47
SecuritySystem/FormMain.Designer.cs
generated
47
SecuritySystem/FormMain.Designer.cs
generated
@ -34,14 +34,15 @@
|
||||
goodsToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
componentListToolStripMenuItem = new ToolStripMenuItem();
|
||||
componentsSecureToolStripMenuItem = new ToolStripMenuItem();
|
||||
orderListToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonTakeOrderInWork = new Button();
|
||||
buttonOrderReady = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonRef = new Button();
|
||||
componentsSecureToolStripMenuItem = new ToolStripMenuItem();
|
||||
orderListToolStripMenuItem = new ToolStripMenuItem();
|
||||
clientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -59,7 +60,7 @@
|
||||
//
|
||||
// guideToolStripMenuItem
|
||||
//
|
||||
guideToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, goodsToolStripMenuItem });
|
||||
guideToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, goodsToolStripMenuItem, clientsToolStripMenuItem });
|
||||
guideToolStripMenuItem.Name = "guideToolStripMenuItem";
|
||||
guideToolStripMenuItem.Size = new Size(87, 20);
|
||||
guideToolStripMenuItem.Text = "Справочник";
|
||||
@ -67,14 +68,14 @@
|
||||
// componentsToolStripMenuItem
|
||||
//
|
||||
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
|
||||
componentsToolStripMenuItem.Size = new Size(145, 22);
|
||||
componentsToolStripMenuItem.Size = new Size(180, 22);
|
||||
componentsToolStripMenuItem.Text = "Компоненты";
|
||||
componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||
//
|
||||
// goodsToolStripMenuItem
|
||||
//
|
||||
goodsToolStripMenuItem.Name = "goodsToolStripMenuItem";
|
||||
goodsToolStripMenuItem.Size = new Size(145, 22);
|
||||
goodsToolStripMenuItem.Size = new Size(180, 22);
|
||||
goodsToolStripMenuItem.Text = "Изделия";
|
||||
goodsToolStripMenuItem.Click += GoodsToolStripMenuItem_Click;
|
||||
//
|
||||
@ -89,9 +90,23 @@
|
||||
//
|
||||
componentListToolStripMenuItem.Name = "componentListToolStripMenuItem";
|
||||
componentListToolStripMenuItem.Size = new Size(218, 22);
|
||||
componentListToolStripMenuItem.Text = "Список компонентов";
|
||||
componentListToolStripMenuItem.Text = "Список коспонентов";
|
||||
componentListToolStripMenuItem.Click += ComponentListToolStripMenuItem_Click;
|
||||
//
|
||||
// componentsSecureToolStripMenuItem
|
||||
//
|
||||
componentsSecureToolStripMenuItem.Name = "componentsSecureToolStripMenuItem";
|
||||
componentsSecureToolStripMenuItem.Size = new Size(218, 22);
|
||||
componentsSecureToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||
componentsSecureToolStripMenuItem.Click += ComponentSecuresToolStripMenuItem_Click;
|
||||
//
|
||||
// orderListToolStripMenuItem
|
||||
//
|
||||
orderListToolStripMenuItem.Name = "orderListToolStripMenuItem";
|
||||
orderListToolStripMenuItem.Size = new Size(218, 22);
|
||||
orderListToolStripMenuItem.Text = "Список заказов";
|
||||
orderListToolStripMenuItem.Click += OrderListToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
@ -161,19 +176,12 @@
|
||||
buttonRef.UseVisualStyleBackColor = true;
|
||||
buttonRef.Click += ButtonRef_Click;
|
||||
//
|
||||
// componentsSecureToolStripMenuItem
|
||||
// clientsToolStripMenuItem
|
||||
//
|
||||
componentsSecureToolStripMenuItem.Name = "componentsSecureToolStripMenuItem";
|
||||
componentsSecureToolStripMenuItem.Size = new Size(218, 22);
|
||||
componentsSecureToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||
componentsSecureToolStripMenuItem.Click += ComponentSecuresToolStripMenuItem_Click;
|
||||
//
|
||||
// orderListToolStripMenuItem
|
||||
//
|
||||
orderListToolStripMenuItem.Name = "orderListToolStripMenuItem";
|
||||
orderListToolStripMenuItem.Size = new Size(218, 22);
|
||||
orderListToolStripMenuItem.Text = "Список заказов";
|
||||
orderListToolStripMenuItem.Click += OrderListToolStripMenuItem_Click;
|
||||
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
|
||||
clientsToolStripMenuItem.Size = new Size(180, 22);
|
||||
clientsToolStripMenuItem.Text = "Клиенты";
|
||||
clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
@ -190,7 +198,7 @@
|
||||
MainMenuStrip = menuStrip1;
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormMain";
|
||||
Text = "Система охраны";
|
||||
Text = "Кузнечная мастерская";
|
||||
Load += FormMain_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
@ -215,5 +223,6 @@
|
||||
private ToolStripMenuItem componentListToolStripMenuItem;
|
||||
private ToolStripMenuItem componentsSecureToolStripMenuItem;
|
||||
private ToolStripMenuItem orderListToolStripMenuItem;
|
||||
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -11,8 +11,9 @@ using System.Windows.Forms;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||
using SecuritySystemDataModels.Models;
|
||||
using SecuritySystemDataModels.Enums;
|
||||
|
||||
|
||||
using SecuritySystemView;
|
||||
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
@ -41,7 +42,8 @@ namespace SecuritySystemView
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["SecureId"].Visible = false;
|
||||
dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["DateImplement"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
@ -61,8 +63,16 @@ namespace SecuritySystemView
|
||||
}
|
||||
private void GoodsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecuries));
|
||||
if (service is FormSecuries form)
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecures));
|
||||
if (service is FormSecures form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
@ -86,13 +96,7 @@ namespace SecuritySystemView
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value),
|
||||
SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
@ -117,15 +121,8 @@ namespace SecuritySystemView
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value),
|
||||
SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc)
|
||||
});
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
@ -149,14 +146,7 @@ namespace SecuritySystemView
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value),
|
||||
SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
DateImplement = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateImplement"].Value.ToString()),
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
@ -201,10 +191,5 @@ namespace SecuritySystemView
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void списокToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace SecuritySystemView
|
||||
_logger.LogInformation("Загрузка изделия");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new SecureSearchModel { Id = _id.Value });
|
||||
var view = _logic.ReadElement(new SecuresearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.SecureName;
|
||||
@ -79,8 +79,8 @@ namespace SecuritySystemView
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent));
|
||||
if (service is FormSecuriesComponent form)
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecureComponent));
|
||||
if (service is FormSecureComponent form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -105,8 +105,8 @@ namespace SecuritySystemView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent));
|
||||
if (service is FormSecuriesComponent form)
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecureComponent));
|
||||
if (service is FormSecureComponent form)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
partial class FormSecuriesComponent
|
||||
partial class FormSecureComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
@ -13,7 +13,7 @@ using System.Windows.Forms;
|
||||
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
public partial class FormSecuriesComponent : Form
|
||||
public partial class FormSecureComponent : Form
|
||||
{
|
||||
private readonly List<ComponentViewModel>? _list;
|
||||
public int Id
|
||||
@ -50,7 +50,7 @@ namespace SecuritySystemView
|
||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||
set { textBoxCount.Text = value.ToString(); }
|
||||
}
|
||||
public FormSecuriesComponent(IComponentLogic logic)
|
||||
public FormSecureComponent(IComponentLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_list = logic.ReadList(null);
|
@ -1,6 +1,6 @@
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
partial class FormSecuries
|
||||
partial class FormSecures
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -109,9 +109,9 @@
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.ToolsPanel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormSecuries";
|
||||
this.Name = "FormSecures";
|
||||
this.Text = "Изделия";
|
||||
this.Load += new System.EventHandler(this.FormSecuries_Load);
|
||||
this.Load += new System.EventHandler(this.FormSecures_Load);
|
||||
this.ToolsPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
@ -14,17 +14,17 @@ using System.Windows.Forms;
|
||||
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
public partial class FormSecuries : Form
|
||||
public partial class FormSecures : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISecureLogic _logic;
|
||||
public FormSecuries(ILogger<FormSecuries> logger, ISecureLogic logic)
|
||||
public FormSecures(ILogger<FormSecures> logger, ISecureLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormSecuries_Load(object sender, EventArgs e)
|
||||
private void FormSecures_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
120
SecuritySystem/FormSecures.resx
Normal file
120
SecuritySystem/FormSecures.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
@ -9,6 +9,10 @@ using SecuritySystemDatabaseImplement.Implements;
|
||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||
using SecuritySystemContracts.StoragesContracts;
|
||||
using SecureCompanyBusinessLogic.BusinessLogics;
|
||||
using SecuritySystemBusinessLogic.BusinessLogics;
|
||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||
using SecuritySystemContracts.StorageContracts;
|
||||
using SecuritySystemView;
|
||||
|
||||
namespace SecuritySystemView
|
||||
{
|
||||
@ -40,10 +44,12 @@ namespace SecuritySystemView
|
||||
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ISecureStorage, SecureStorage>();
|
||||
services.AddTransient<ISecurestorage, Securestorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<ISecureLogic, SecureLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
@ -54,10 +60,11 @@ namespace SecuritySystemView
|
||||
services.AddTransient<FormComponents>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormSecure>();
|
||||
services.AddTransient<FormSecuriesComponent>();
|
||||
services.AddTransient<FormSecuries>();
|
||||
services.AddTransient<FormSecureComponent>();
|
||||
services.AddTransient<FormSecures>();
|
||||
services.AddTransient<FormReportSecureComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormClients>();
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,6 @@
|
||||
Renaming the file extension or editing the content of this file may
|
||||
cause the file to be unrecognizable by the program.
|
||||
-->
|
||||
<GenericObjectDataSource DisplayName="ISecureStorage" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
|
||||
<TypeInfo>SecuritySystemContracts.StoragesContracts.ISecureStorage, SecuritySystemContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
|
||||
<GenericObjectDataSource DisplayName="ISecurestorage" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
|
||||
<TypeInfo>SecuritySystemContracts.StoragesContracts.ISecurestorage, SecuritySystemContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
|
||||
</GenericObjectDataSource>
|
117
SecuritySystemBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
117
SecuritySystemBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.StorageContracts;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using SecuritySystemDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ClientLogic : IClientLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientStorage _clientStorage;
|
||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_clientStorage = clientStorage;
|
||||
}
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ClientFIO:{ClientFIO}. Id:{Id}", model?.ClientFIO, model?.Id);
|
||||
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ClientFIO:{ClientFIO}. Id:{Id}", model.ClientFIO, model.Id);
|
||||
var element = _clientStorage.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(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_clientStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ClientFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет имени клиента", nameof(model.ClientFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Нет логина клиента", nameof(model.ClientFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля учетной записи клиента", nameof(model.ClientFIO));
|
||||
}
|
||||
_logger.LogInformation("Client. ClientFIO:{ClientFIO}. Email:{Email}. Password:{Password}. Id:{Id}", model.ClientFIO, model.Email, model.Password, model.Id);
|
||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
Email = model.Email
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,15 +11,15 @@ namespace SecureCompanyBusinessLogic.BusinessLogics
|
||||
public class ReportLogic : IReportLogic
|
||||
{
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
private readonly ISecureStorage _SecureStorage;
|
||||
private readonly ISecurestorage _Securestorage;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
public ReportLogic(ISecureStorage SecureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
||||
public ReportLogic(ISecurestorage Securestorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||
{
|
||||
_SecureStorage = SecureStorage;
|
||||
_Securestorage = Securestorage;
|
||||
_componentStorage = componentStorage;
|
||||
_orderStorage = orderStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
@ -34,7 +34,7 @@ namespace SecureCompanyBusinessLogic.BusinessLogics
|
||||
public List<ReportSecureComponentViewModel> GetSecureComponent()
|
||||
{
|
||||
var components = _componentStorage.GetFullList();
|
||||
var Secures = _SecureStorage.GetFullList();
|
||||
var Secures = _Securestorage.GetFullList();
|
||||
var list = new List<ReportSecureComponentViewModel>();
|
||||
|
||||
foreach (var Secure in Secures)
|
||||
@ -88,7 +88,7 @@ namespace SecureCompanyBusinessLogic.BusinessLogics
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список компонент",
|
||||
Secures = _SecureStorage.GetFullList()
|
||||
Secures = _Securestorage.GetFullList()
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -11,18 +11,18 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
||||
public class SecureLogic : ISecureLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISecureStorage _SecureStorage;
|
||||
private readonly ISecurestorage _Securestorage;
|
||||
|
||||
public SecureLogic(ILogger<SecureLogic> logger, ISecureStorage SecureStorage)
|
||||
public SecureLogic(ILogger<SecureLogic> logger, ISecurestorage Securestorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_SecureStorage = SecureStorage;
|
||||
_Securestorage = Securestorage;
|
||||
}
|
||||
|
||||
public List<SecureViewModel>? ReadList(SecureSearchModel? model)
|
||||
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);
|
||||
var list = model == null ? _Securestorage.GetFullList() : _Securestorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
@ -32,14 +32,14 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
public SecureViewModel? ReadElement(SecureSearchModel model)
|
||||
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);
|
||||
var element = _Securestorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
@ -52,7 +52,7 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
||||
public bool Create(SecureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_SecureStorage.Insert(model) == null)
|
||||
if (_Securestorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
@ -63,7 +63,7 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
||||
public bool Update(SecureBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_SecureStorage.Update(model) == null)
|
||||
if (_Securestorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
@ -75,7 +75,7 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_SecureStorage.Delete(model) == null)
|
||||
if (_Securestorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
@ -102,7 +102,7 @@ namespace SecuritySystemBusinessLogic.BusinessLogics
|
||||
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
|
||||
var element = _Securestorage.GetElement(new SecuresearchModel
|
||||
{
|
||||
SecureName = model.SecureName
|
||||
});
|
||||
|
17
SecuritySystemContracts/BindingModels/ClientBindingModel.cs
Normal file
17
SecuritySystemContracts/BindingModels/ClientBindingModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using SecuritySystemDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemContracts.BindingModels
|
||||
{
|
||||
public class ClientBindingModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ namespace SecuritySystemContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int SecureId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public string SecureName { get; set; } = string.Empty;
|
||||
|
@ -0,0 +1,21 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IClientLogic
|
||||
{
|
||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||
bool Create(ClientBindingModel model);
|
||||
bool Update(ClientBindingModel model);
|
||||
bool Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@ namespace SecuritySystemContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface ISecureLogic
|
||||
{
|
||||
List<SecureViewModel>? ReadList(SecureSearchModel? model);
|
||||
SecureViewModel? ReadElement(SecureSearchModel model);
|
||||
List<SecureViewModel>? ReadList(SecuresearchModel? model);
|
||||
SecureViewModel? ReadElement(SecuresearchModel model);
|
||||
bool Create(SecureBindingModel model);
|
||||
bool Update(SecureBindingModel model);
|
||||
bool Delete(SecureBindingModel model);
|
||||
|
16
SecuritySystemContracts/SearchModels/ClientSearchModel.cs
Normal file
16
SecuritySystemContracts/SearchModels/ClientSearchModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemContracts.SearchModels
|
||||
{
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ClientFIO { get; set; }
|
||||
public string? Email { get; set;}
|
||||
public string? Password { get; set;}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace SecuritySystemContracts.SearchModels
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemContracts.SearchModels
|
||||
{
|
||||
public class SecureSearchModel
|
||||
public class SecuresearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? SecureName { get; set; }
|
||||
|
23
SecuritySystemContracts/StorageContracts/IClientStorage.cs
Normal file
23
SecuritySystemContracts/StorageContracts/IClientStorage.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using SecuritySystemDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemContracts.StorageContracts
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
@ -9,11 +9,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemContracts.StoragesContracts
|
||||
{
|
||||
public interface ISecureStorage
|
||||
public interface ISecurestorage
|
||||
{
|
||||
List<SecureViewModel> GetFullList();
|
||||
List<SecureViewModel> GetFilteredList(SecureSearchModel model);
|
||||
SecureViewModel? GetElement(SecureSearchModel model);
|
||||
List<SecureViewModel> GetFilteredList(SecuresearchModel model);
|
||||
SecureViewModel? GetElement(SecuresearchModel model);
|
||||
SecureViewModel? Insert(SecureBindingModel model);
|
||||
SecureViewModel? Update(SecureBindingModel model);
|
||||
SecureViewModel? Delete(SecureBindingModel model);
|
||||
|
21
SecuritySystemContracts/ViewModels/ClientViewModel.cs
Normal file
21
SecuritySystemContracts/ViewModels/ClientViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using SecuritySystemDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Логин (эл. почта)")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -17,6 +17,9 @@ namespace SecuritySystemContracts.ViewModels
|
||||
[DisplayName("Изделие")]
|
||||
public string SecureName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
|
15
SecuritySystemDataModels/Models/IClientModel.cs
Normal file
15
SecuritySystemDataModels/Models/IClientModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
string ClientFIO { get; }
|
||||
string Email { get; }
|
||||
string Password { get; }
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ namespace SecuritySystemDataModels.Models
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int SecureId { get; }
|
||||
int ClientId { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
||||
|
96
SecuritySystemDatabaseImplement/Implements/ClientStorage.cs
Normal file
96
SecuritySystemDatabaseImplement/Implements/ClientStorage.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.StorageContracts;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using SecuritySystemDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemDatabaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new SecuritySystemDatabase();
|
||||
return context.Clients
|
||||
.Include(x => x.Orders)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
using var context = new SecuritySystemDatabase();
|
||||
return context.Clients
|
||||
.Include(x => x.Orders)
|
||||
.Where(x => x.Email.Contains(model.Email))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
using var context = new SecuritySystemDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Clients
|
||||
.FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return context.Clients
|
||||
.FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))?.GetViewModel;
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
var newClient = Client.Create(model);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new SecuritySystemDatabase();
|
||||
context.Clients.Add(newClient);
|
||||
context.SaveChanges();
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
using var context = new SecuritySystemDatabase();
|
||||
var client = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new SecuritySystemDatabase();
|
||||
var element = context.Clients
|
||||
.Include(x => x.Orders)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Clients.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SecuritySystemDatabaseImplement.Models;
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.StoragesContracts;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SecuritySystemDatabaseImplement.Models;
|
||||
|
||||
namespace SecuritySystemDatabaseImplement.Implements
|
||||
{
|
||||
@ -15,7 +16,11 @@ namespace SecuritySystemDatabaseImplement.Implements
|
||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Orders.Include(x => x.Secure).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
var deletedElement = context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Include(x => x.Client)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
@ -29,29 +34,55 @@ namespace SecuritySystemDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new SecuritySystemDatabase();
|
||||
return context.Orders.Include(x => x.Secure).FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Include(x => x.Client)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (model is null)
|
||||
return new();
|
||||
|
||||
using var context = new SecuritySystemDatabase();
|
||||
if (!model.Id.HasValue)
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
else if (model.ClientId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new SecuritySystemDatabase();
|
||||
return context.Orders.Include(x => x.Secure).Select(x => x.GetViewModel).ToList();
|
||||
return context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Include(x => x.Client)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -63,7 +94,11 @@ namespace SecuritySystemDatabaseImplement.Implements
|
||||
using var context = new SecuritySystemDatabase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Secure).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Include(x => x.Client)
|
||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
@ -75,7 +110,11 @@ namespace SecuritySystemDatabaseImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Secure).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Include(x => x.Client)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ using SecuritySystemDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
namespace SecuritySystemDatabaseImplement.Implements
|
||||
{
|
||||
public class SecureStorage : ISecureStorage
|
||||
public class Securestorage : ISecurestorage
|
||||
{
|
||||
public List<SecureViewModel> GetFullList()
|
||||
{
|
||||
using var context = new SecuritySystemDatabase();
|
||||
return context.Secures.Include(x => x.Components).ThenInclude(x => x.Component).ToList().Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<SecureViewModel> GetFilteredList(SecureSearchModel model)
|
||||
public List<SecureViewModel> GetFilteredList(SecuresearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SecureName))
|
||||
{
|
||||
@ -23,7 +23,7 @@ namespace SecuritySystemDatabaseImplement.Implements
|
||||
return context.Secures.Include(x => x.Components).ThenInclude(x => x.Component).Where(x => x.SecureName.Contains(model.SecureName)).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public SecureViewModel? GetElement(SecureSearchModel model)
|
||||
public SecureViewModel? GetElement(SecuresearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SecureName) &&
|
||||
!model.Id.HasValue)
|
||||
|
@ -1,171 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using SecuritySystemDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SecuritySystemDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(SecuritySystemDatabase))]
|
||||
[Migration("20230404083020_InitialCreate4")]
|
||||
partial class InitialCreate4
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("SecureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SecureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Secure", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("SecureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Secures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.SecureComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("SecureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("SecureId");
|
||||
|
||||
b.ToTable("SecureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("SecuritySystemDatabaseImplement.Models.Secure", "Secure")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SecureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Secure");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.SecureComponent", b =>
|
||||
{
|
||||
b.HasOne("SecuritySystemDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("SecureComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SecuritySystemDatabaseImplement.Models.Secure", "Secure")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("SecureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Secure");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("SecureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Secure", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SecuritySystemDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate4 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@ using SecuritySystemDatabaseImplement;
|
||||
namespace SecuritySystemDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(SecuritySystemDatabase))]
|
||||
[Migration("20230404083007_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
[Migration("20230423054524_with client")]
|
||||
partial class withclient
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -25,6 +25,31 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -53,6 +78,9 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -73,6 +101,8 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("SecureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
@ -126,12 +156,20 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("SecuritySystemDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SecuritySystemDatabaseImplement.Models.Secure", "Secure")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SecureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Secure");
|
||||
});
|
||||
|
||||
@ -154,6 +192,11 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
b.Navigation("Secure");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("SecureComponents");
|
@ -7,11 +7,26 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace SecuritySystemDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class withclient : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ClientFIO = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
@ -47,6 +62,7 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
SecureId = table.Column<int>(type: "integer", nullable: false),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
@ -56,6 +72,12 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Secures_SecureId",
|
||||
column: x => x.SecureId,
|
||||
@ -91,6 +113,11 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_SecureId",
|
||||
table: "Orders",
|
||||
@ -116,6 +143,9 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "SecureComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
@ -22,6 +22,31 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -50,6 +75,9 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -70,6 +98,8 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("SecureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
@ -123,12 +153,20 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("SecuritySystemDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SecuritySystemDatabaseImplement.Models.Secure", "Secure")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SecureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Secure");
|
||||
});
|
||||
|
||||
@ -151,6 +189,11 @@ namespace SecuritySystemDatabaseImplement.Migrations
|
||||
b.Navigation("Secure");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SecuritySystemDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("SecureComponents");
|
||||
|
57
SecuritySystemDatabaseImplement/Models/Client.cs
Normal file
57
SecuritySystemDatabaseImplement/Models/Client.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using SecuritySystemDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemDatabaseImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientFIO = model.ClientFIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientFIO = model.ClientFIO;
|
||||
Email = model.Email;
|
||||
Password = model.Password;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientFIO = ClientFIO,
|
||||
Email = Email,
|
||||
Password = Password
|
||||
};
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ namespace SecuritySystemDatabaseImplement.Models
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int SecureId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
[Required]
|
||||
@ -27,6 +28,7 @@ namespace SecuritySystemDatabaseImplement.Models
|
||||
public DateTime DateCreate { get; set; }
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public virtual Secure Secure { get; set; }
|
||||
public virtual Client Client { get; set; }
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -37,6 +39,7 @@ namespace SecuritySystemDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
SecureId = model.SecureId,
|
||||
ClientId = model.ClientId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -59,6 +62,8 @@ namespace SecuritySystemDatabaseImplement.Models
|
||||
Id = Id,
|
||||
SecureId = SecureId,
|
||||
SecureName = Secure.SecureName,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = Client.ClientFIO,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
|
@ -17,5 +17,7 @@ namespace SecuritySystemDatabaseImplement
|
||||
public virtual DbSet<Secure> Secures { set; get; }
|
||||
public virtual DbSet<SecureComponent> SecureComponents { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,11 @@ namespace SecuritySystemFileImplement
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string SecureFileName = "Secure.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Secure> Secures { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -29,11 +31,13 @@ namespace SecuritySystemFileImplement
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||
public void SaveSecures() => SaveData(Secures, SecureFileName, "Secures", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Secures = LoadData(SecureFileName, "Secure", x => Secure.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
{
|
||||
|
87
SecuritySystemFileImplement/Implements/ClientStorage.cs
Normal file
87
SecuritySystemFileImplement/Implements/ClientStorage.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.StorageContracts;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using SecuritySystemFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemFileImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public ClientStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
return source.Clients
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return source.Clients
|
||||
.Where(x => x.Email.Contains(model.Email))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return source.Clients
|
||||
.FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return source.Clients
|
||||
.FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))?.GetViewModel;
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
model.Id = source.Clients.Count > 0 ? source.Clients.Max(x => x.Id) + 1 : 1;
|
||||
var newClient = Client.Create(model);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Clients.Add(newClient);
|
||||
source.SaveClients();
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
source.SaveClients();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client != null)
|
||||
{
|
||||
source.Clients.Remove(client);
|
||||
source.SaveClients();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -22,10 +22,6 @@ namespace SecuritySystemFileImplement.Implements
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && (model.DateFrom == null || model.DateTo == null))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return source.Orders
|
||||
@ -33,13 +29,21 @@ namespace SecuritySystemFileImplement.Implements
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return source.Orders
|
||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
else if (model.ClientId.HasValue)
|
||||
{
|
||||
return source.Orders
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => GetViewModel(x))
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
|
@ -15,14 +15,14 @@ using SecuritySystemFileImplement;
|
||||
|
||||
namespace SecuritySystemFileImplement.Implements
|
||||
{
|
||||
public class SecureStorage : ISecureStorage
|
||||
public class Securestorage : ISecurestorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public SecureStorage()
|
||||
public Securestorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public SecureViewModel? GetElement(SecureSearchModel model)
|
||||
public SecureViewModel? GetElement(SecuresearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SecureName) && !model.Id.HasValue)
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace SecuritySystemFileImplement.Implements
|
||||
}
|
||||
return source.Secures.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SecureName) && x.SecureName == model.SecureName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
public List<SecureViewModel> GetFilteredList(SecureSearchModel model)
|
||||
public List<SecureViewModel> GetFilteredList(SecuresearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SecureName))
|
||||
{
|
||||
|
70
SecuritySystemFileImplement/Models/Client.cs
Normal file
70
SecuritySystemFileImplement/Models/Client.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using SecuritySystemDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SecuritySystemFileImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientFIO = model.ClientFIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password,
|
||||
};
|
||||
}
|
||||
public static Client? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Client()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ClientFIO = element.Element("ClientFIO")!.Value,
|
||||
Email = element.Element("Email")!.Value,
|
||||
Password = element.Element("Password")!.Value
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientFIO = model.ClientFIO;
|
||||
Email = model.Email;
|
||||
Password = model.Password;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientFIO = ClientFIO,
|
||||
Email = Email,
|
||||
Password = Password
|
||||
};
|
||||
public XElement GetXElement => new("Client",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ClientFIO", ClientFIO),
|
||||
new XElement("Email", Email),
|
||||
new XElement("Password", Password));
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ namespace SecuritySystemFileImplement.Models
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int SecureId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
public string SecureName { get; private set; } = string.Empty;
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
|
@ -13,12 +13,14 @@ namespace SecuritySystemListImplement
|
||||
private static DataListSingleton? _instance;
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Secure> Securies { get; set; }
|
||||
public List<Secure> Secures { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Securies = new List<Secure>();
|
||||
Secures = new List<Secure>();
|
||||
Clients = new List<Client>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
109
SecuritySystemListImplement/Implements/ClientStorage.cs
Normal file
109
SecuritySystemListImplement/Implements/ClientStorage.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.SearchModels;
|
||||
using SecuritySystemContracts.StorageContracts;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using SecuritySystemListImplement.Models;
|
||||
|
||||
namespace SecuritySystemListImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ClientStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ClientViewModel>();
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
result.Add(client.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
var result = new List<ClientViewModel>();
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Email.Contains(model.Email))
|
||||
{
|
||||
result.Add(client.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Id == model.Id)
|
||||
{
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Email == model.Email && client.Password == model.Password)
|
||||
{
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (model.Id <= client.Id)
|
||||
{
|
||||
model.Id = client.Id + 1;
|
||||
}
|
||||
}
|
||||
var newClient = Client.Create(model);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Clients.Add(newClient);
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Id == model.Id)
|
||||
{
|
||||
client.Update(model);
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Clients.Count; ++i)
|
||||
{
|
||||
if (_source.Clients[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Clients[i];
|
||||
_source.Clients.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,30 +7,30 @@ using SecuritySystemContracts.ViewModels;
|
||||
|
||||
namespace SecuritySystemListImplement.Implements
|
||||
{
|
||||
public class SecureStorage : ISecureStorage
|
||||
public class Securestorage : ISecurestorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public SecureStorage()
|
||||
public Securestorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<SecureViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<SecureViewModel>();
|
||||
foreach (var Secure in _source.Securies)
|
||||
foreach (var Secure in _source.Secures)
|
||||
{
|
||||
result.Add(Secure.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<SecureViewModel> GetFilteredList(SecureSearchModel model)
|
||||
public List<SecureViewModel> GetFilteredList(SecuresearchModel model)
|
||||
{
|
||||
var result = new List<SecureViewModel>();
|
||||
if (string.IsNullOrEmpty(model.SecureName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var Secure in _source.Securies)
|
||||
foreach (var Secure in _source.Secures)
|
||||
{
|
||||
if (Secure.SecureName.Contains(model.SecureName))
|
||||
{
|
||||
@ -39,13 +39,13 @@ namespace SecuritySystemListImplement.Implements
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public SecureViewModel? GetElement(SecureSearchModel model)
|
||||
public SecureViewModel? GetElement(SecuresearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SecureName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var Secure in _source.Securies)
|
||||
foreach (var Secure in _source.Secures)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.SecureName) && Secure.SecureName == model.SecureName) ||
|
||||
(model.Id.HasValue && Secure.Id == model.Id))
|
||||
@ -58,7 +58,7 @@ namespace SecuritySystemListImplement.Implements
|
||||
public SecureViewModel? Insert(SecureBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var Secure in _source.Securies)
|
||||
foreach (var Secure in _source.Secures)
|
||||
{
|
||||
if (model.Id <= Secure.Id)
|
||||
{
|
||||
@ -70,12 +70,12 @@ namespace SecuritySystemListImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Securies.Add(newSecure);
|
||||
_source.Secures.Add(newSecure);
|
||||
return newSecure.GetViewModel;
|
||||
}
|
||||
public SecureViewModel? Update(SecureBindingModel model)
|
||||
{
|
||||
foreach (var Secure in _source.Securies)
|
||||
foreach (var Secure in _source.Secures)
|
||||
{
|
||||
if (Secure.Id == model.Id)
|
||||
{
|
||||
@ -87,12 +87,12 @@ namespace SecuritySystemListImplement.Implements
|
||||
}
|
||||
public SecureViewModel? Delete(SecureBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Securies.Count; ++i)
|
||||
for (int i = 0; i < _source.Secures.Count; ++i)
|
||||
{
|
||||
if (_source.Securies[i].Id == model.Id)
|
||||
if (_source.Secures[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Securies[i];
|
||||
_source.Securies.RemoveAt(i);
|
||||
var element = _source.Secures[i];
|
||||
_source.Secures.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
50
SecuritySystemListImplement/Models/Client.cs
Normal file
50
SecuritySystemListImplement/Models/Client.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using SecuritySystemContracts.BindingModels;
|
||||
using SecuritySystemContracts.ViewModels;
|
||||
using SecuritySystemDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecuritySystemListImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientFIO = model.ClientFIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password,
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientFIO = model.ClientFIO;
|
||||
Email = model.Email;
|
||||
Password = model.Password;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientFIO = ClientFIO,
|
||||
Email = Email,
|
||||
Password = Password
|
||||
};
|
||||
}
|
||||
}
|
@ -16,16 +16,13 @@ namespace SecuritySystemListImplement.Models
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int SecureId { get; private set; }
|
||||
|
||||
public string SecureName { get; private set; } = string.Empty;
|
||||
public int ClientId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
|
Loading…
x
Reference in New Issue
Block a user