17 Commits

Author SHA1 Message Date
48e1851c03 to the end 2023-04-25 08:37:56 +04:00
84f68369cc add client 2023-04-23 16:15:29 +04:00
5f93519637 + 2023-04-23 15:19:18 +04:00
bd23625014 add logic sender 2023-04-23 15:18:46 +04:00
55aa15cc8c forms 2023-04-23 15:08:54 +04:00
408f284b77 add work with messages 2023-04-23 14:58:36 +04:00
68cb138c9e add Message Logic 2023-04-23 14:47:01 +04:00
f3b7639740 fix 2023-04-22 14:38:51 +04:00
9fc183089a little fix 2023-04-11 00:32:34 +04:00
294ba56f69 add forms 2023-04-11 00:21:54 +04:00
d1869ab2a7 add controller 2023-04-11 00:07:59 +04:00
849aa4fe85 work of implementers 2023-04-11 00:06:19 +04:00
15d464055a filter orders 2023-04-10 23:57:32 +04:00
8e7fd0f1d4 add migration 2023-04-10 23:44:02 +04:00
f4058aa48a add logic 2023-04-10 23:32:47 +04:00
892685058e add ImplementerId 2023-04-10 23:31:33 +04:00
1c0ed7b35a add models 2023-04-10 23:21:20 +04:00
226 changed files with 5532 additions and 79510 deletions

View File

@@ -0,0 +1,17 @@
using AbstractFurnitureAssemblyDataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyDataModels.Models
{
public interface IImplementerModel : IId
{
string ImplementerFIO { get; }
string Password { get; }
int WorkExperience { get; }
int Qualification { get; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyDataModels.Models
{
public interface IMessageInfoModel
{
string MessageId { get; }
int? ClientId { get; }
string SenderName { get; }
DateTime DateDelivery { get; }
string Subject { get; }
string Body { get; }
}
}

View File

@@ -16,5 +16,6 @@ namespace AbstractFurnitureAssemblyDataModels.Models
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
int ClientId { get; }
int? ImplementerId { get; }
}
}

View File

@@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractFurnitureAssemblyDataModels.Models
{
public interface IShopModel : IId
{
string ShopName { get; }
string Address { get; }
DateTime DateOpening { get; }
int MaxCount { get; }
Dictionary<int, (IFurnitureModel, int)> Furnitures { get; }
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SmtpClientHost" value="smtp.gmail.com" />
<add key="SmtpClientPort" value="587" />
<add key="PopHost" value="pop.gmail.com" />
<add key="PopPort" value="995" />
<add key="MailLogin" value="MailNoNameLab@gmail.com" />
<add key="MailPassword" value="cpdj ykey loip jxwj" />
</appSettings>
</configuration>

View File

@@ -1,177 +0,0 @@
namespace FurnitureAssemblyView
{
partial class CreateOrderForm
{
/// <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.comboBoxClientEmail = new System.Windows.Forms.ComboBox();
this.labelClient = new System.Windows.Forms.Label();
this.ButtonCancel = new System.Windows.Forms.Button();
this.ButtonSave = new System.Windows.Forms.Button();
this.textBoxSum = new System.Windows.Forms.TextBox();
this.comboBoxProduct = new System.Windows.Forms.ComboBox();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.labelSum = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.labelFurniture = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// comboBoxClientEmail
//
this.comboBoxClientEmail.FormattingEnabled = true;
this.comboBoxClientEmail.Location = new System.Drawing.Point(199, 49);
this.comboBoxClientEmail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.comboBoxClientEmail.Name = "comboBoxClientEmail";
this.comboBoxClientEmail.Size = new System.Drawing.Size(423, 33);
this.comboBoxClientEmail.TabIndex = 19;
//
// labelClient
//
this.labelClient.AutoSize = true;
this.labelClient.Location = new System.Drawing.Point(62, 54);
this.labelClient.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelClient.Name = "labelClient";
this.labelClient.Size = new System.Drawing.Size(71, 25);
this.labelClient.TabIndex = 18;
this.labelClient.Text = "Клиент:";
//
// ButtonCancel
//
this.ButtonCancel.Location = new System.Drawing.Point(473, 279);
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(150, 48);
this.ButtonCancel.TabIndex = 17;
this.ButtonCancel.Text = "Отмена";
this.ButtonCancel.UseVisualStyleBackColor = true;
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// ButtonSave
//
this.ButtonSave.Location = new System.Drawing.Point(288, 279);
this.ButtonSave.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonSave.Name = "ButtonSave";
this.ButtonSave.Size = new System.Drawing.Size(150, 48);
this.ButtonSave.TabIndex = 16;
this.ButtonSave.Text = "Сохранить";
this.ButtonSave.UseVisualStyleBackColor = true;
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// textBoxSum
//
this.textBoxSum.Location = new System.Drawing.Point(199, 231);
this.textBoxSum.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.Size = new System.Drawing.Size(423, 31);
this.textBoxSum.TabIndex = 15;
//
// comboBoxProduct
//
this.comboBoxProduct.FormattingEnabled = true;
this.comboBoxProduct.Location = new System.Drawing.Point(199, 112);
this.comboBoxProduct.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.comboBoxProduct.Name = "comboBoxProduct";
this.comboBoxProduct.Size = new System.Drawing.Size(423, 33);
this.comboBoxProduct.TabIndex = 14;
this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.comboBoxProduct_SelectedIndexChanged);
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(199, 171);
this.textBoxCount.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(423, 31);
this.textBoxCount.TabIndex = 13;
this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCount_TextChanged);
//
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(62, 236);
this.labelSum.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(67, 25);
this.labelSum.TabIndex = 12;
this.labelSum.Text = "Сумма";
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(62, 176);
this.labelCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(111, 25);
this.labelCount.TabIndex = 11;
this.labelCount.Text = "Количество:";
//
// labelFurniture
//
this.labelFurniture.AutoSize = true;
this.labelFurniture.Location = new System.Drawing.Point(62, 117);
this.labelFurniture.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelFurniture.Name = "labelFurniture";
this.labelFurniture.Size = new System.Drawing.Size(84, 25);
this.labelFurniture.TabIndex = 10;
this.labelFurniture.Text = "Изделие:";
//
// CreateOrderForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(733, 387);
this.Controls.Add(this.comboBoxClientEmail);
this.Controls.Add(this.labelClient);
this.Controls.Add(this.ButtonCancel);
this.Controls.Add(this.ButtonSave);
this.Controls.Add(this.textBoxSum);
this.Controls.Add(this.comboBoxProduct);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.labelSum);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelFurniture);
this.Name = "CreateOrderForm";
this.Text = "Создание заказа";
this.Load += new System.EventHandler(this.CreateOrderForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ComboBox comboBoxClientEmail;
private Label labelClient;
private Button ButtonCancel;
private Button ButtonSave;
private TextBox textBoxSum;
private ComboBox comboBoxProduct;
private TextBox textBoxCount;
private Label labelSum;
private Label labelCount;
private Label labelFurniture;
}
}

View File

@@ -1,146 +0,0 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using FurnitureAssemblyContracts.SearchModels;
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 FurnitureAssemblyView
{
public partial class CreateOrderForm : Form
{
private readonly ILogger _logger;
private readonly IfurnitureLogic _logicF;
private readonly IOrderLogic _logicO;
private readonly IClientLogic _logicC;
public CreateOrderForm(ILogger<CreateOrderForm> logger, IfurnitureLogic logicF, IOrderLogic logicO, IClientLogic logicC)
{
InitializeComponent();
_logger = logger;
_logicF = logicF;
_logicO = logicO;
_logicC = logicC;
}
private void CreateOrderForm_Load(object sender, EventArgs e)
{
_logger.LogInformation("Загрузка изделий и клиентов для заказа");
LoadData();
}
private void LoadData()
{
var _list = _logicF.ReadList(null);
if (_list != null)
{
comboBoxProduct.DisplayMember = "FurnitureName";
comboBoxProduct.ValueMember = "Id";
comboBoxProduct.DataSource = _list;
comboBoxProduct.SelectedItem = null;
}
var _listCli = _logicC.ReadList(null);
if (_listCli != null)
{
comboBoxClientEmail.DisplayMember = "Email"; // по нему однозначно можно определить клиента
comboBoxClientEmail.ValueMember = "Id";
comboBoxClientEmail.DataSource = _listCli;
comboBoxClientEmail.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxProduct.SelectedValue == null)
{
MessageBox.Show("Выберите изделие", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxClientEmail.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание заказа");
try
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
FurnitureId = Convert.ToInt32(comboBoxProduct.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text),
ClientId = Convert.ToInt32(comboBoxClientEmail.SelectedValue)
});
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void comboBoxProduct_SelectedIndexChanged(object sender, EventArgs e)
{
CalcSum();
}
private void textBoxCount_TextChanged(object sender, EventArgs e)
{
CalcSum();
}
private void CalcSum()
{
if (comboBoxProduct.SelectedValue != null &&
!string.IsNullOrEmpty(textBoxCount.Text))
{
try
{
int id = Convert.ToInt32(comboBoxProduct.SelectedValue);
var product = _logicF.ReadElement(new FurnitureSearchModel
{
Id
= id
});
int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0),
2).ToString();
_logger.LogInformation("Расчет суммы заказа");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка расчета суммы заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}
}

View File

@@ -1,142 +0,0 @@
namespace FurnitureAssembly
{
partial class FormAddToShop
{
/// <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.comboBoxShop = new System.Windows.Forms.ComboBox();
this.labelShop = new System.Windows.Forms.Label();
this.comboBoxFurniture = new System.Windows.Forms.ComboBox();
this.labelFurniture = new System.Windows.Forms.Label();
this.labelNum = new System.Windows.Forms.Label();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// comboBoxShop
//
this.comboBoxShop.FormattingEnabled = true;
this.comboBoxShop.Location = new System.Drawing.Point(133, 18);
this.comboBoxShop.Name = "comboBoxShop";
this.comboBoxShop.Size = new System.Drawing.Size(296, 23);
this.comboBoxShop.TabIndex = 0;
//
// labelShop
//
this.labelShop.AutoSize = true;
this.labelShop.Location = new System.Drawing.Point(46, 21);
this.labelShop.Name = "labelShop";
this.labelShop.Size = new System.Drawing.Size(54, 15);
this.labelShop.TabIndex = 1;
this.labelShop.Text = "Магазин";
//
// comboBoxFurniture
//
this.comboBoxFurniture.FormattingEnabled = true;
this.comboBoxFurniture.Location = new System.Drawing.Point(133, 62);
this.comboBoxFurniture.Name = "comboBoxFurniture";
this.comboBoxFurniture.Size = new System.Drawing.Size(296, 23);
this.comboBoxFurniture.TabIndex = 2;
//
// labelFurniture
//
this.labelFurniture.AutoSize = true;
this.labelFurniture.Location = new System.Drawing.Point(46, 65);
this.labelFurniture.Name = "labelFurniture";
this.labelFurniture.Size = new System.Drawing.Size(53, 15);
this.labelFurniture.TabIndex = 4;
this.labelFurniture.Text = "Изделие";
//
// labelNum
//
this.labelNum.AutoSize = true;
this.labelNum.Location = new System.Drawing.Point(46, 106);
this.labelNum.Name = "labelNum";
this.labelNum.Size = new System.Drawing.Size(72, 15);
this.labelNum.TabIndex = 5;
this.labelNum.Text = "Количество";
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(194, 161);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(99, 29);
this.buttonAdd.TabIndex = 6;
this.buttonAdd.Text = "Пополнить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(330, 161);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(99, 29);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(133, 103);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(160, 23);
this.textBoxCount.TabIndex = 8;
//
// FormReplenishmentShop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(479, 214);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.labelNum);
this.Controls.Add(this.labelFurniture);
this.Controls.Add(this.comboBoxFurniture);
this.Controls.Add(this.labelShop);
this.Controls.Add(this.comboBoxShop);
this.Name = "FormReplenishmentShop";
this.Text = "Пополнение магазина";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ComboBox comboBoxShop;
private Label labelShop;
private ComboBox comboBoxFurniture;
private Label labelFurniture;
private Label labelNum;
private Button buttonAdd;
private Button buttonCancel;
private TextBox textBoxCount;
}
}

View File

@@ -1,129 +0,0 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.ViewModels;
using AbstractFurnitureAssemblyDataModels.Models;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using System;
using System.Collections;
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;
using Microsoft.Extensions.Logging;
namespace FurnitureAssembly
{
public partial class FormAddToShop : Form
{
private readonly List<ShopViewModel>? _listShops;
private readonly List<FurnitureViewModel>? _listFurnitures;
private IShopLogic _shopLogic;
private ILogger _logger;
public int Id
{
get
{
return Convert.ToInt32(comboBoxShop.SelectedValue);
}
set
{
comboBoxShop.SelectedValue = value;
}
}
public int FurnitureId
{
get
{
return Convert.ToInt32(comboBoxFurniture.SelectedValue);
}
set
{
comboBoxFurniture.SelectedValue = value;
}
}
public int Count
{
get { return Convert.ToInt32(textBoxCount.Text); }
set
{ textBoxCount.Text = value.ToString(); }
}
public FormAddToShop(IShopLogic shopLogic, IfurnitureLogic furnitureLogic, ILogger<FormShop> logger)
{
InitializeComponent();
_logger = logger;
_shopLogic = shopLogic;
_listShops = shopLogic.ReadList(null);
_listFurnitures = furnitureLogic.ReadList(null);
if (_listShops != null)
{
comboBoxShop.DisplayMember = "ShopName";
comboBoxShop.ValueMember = "Id";
comboBoxShop.DataSource = _listShops;
comboBoxShop.SelectedItem = null;
}
if (_listFurnitures != null)
{
comboBoxFurniture.DisplayMember = "FurnitureName";
comboBoxFurniture.ValueMember = "Id";
comboBoxFurniture.DataSource = _listFurnitures;
comboBoxFurniture.SelectedItem = null;
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (comboBoxShop.SelectedValue == null)
{
MessageBox.Show("Выберите магазин", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxFurniture.SelectedValue == null)
{
MessageBox.Show("Выберите изделие", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Укажите количество поступившего изделия", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
_logger.LogInformation("Добавление в магазин с id = {ShopName} изделия: id = { FurnitureName} - { Count}", Id, FurnitureId, Count);
var operationResult = _shopLogic.AddFurniture(new ShopBindingModel { Id = Id }, new FurnitureBindingModel { Id = FurnitureId }, Count);
if (!operationResult)
{
throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах.");
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при пополнении магазина c id = " + Id);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
}
}

View File

@@ -1,119 +0,0 @@
namespace FurnitureAssemblyView
{
partial class FormSell
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelFurniture = new System.Windows.Forms.Label();
this.comboBoxToSell = new System.Windows.Forms.ComboBox();
this.labelCount = new System.Windows.Forms.Label();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.buttonSell = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelFurniture
//
this.labelFurniture.AutoSize = true;
this.labelFurniture.Location = new System.Drawing.Point(38, 53);
this.labelFurniture.Name = "labelFurniture";
this.labelFurniture.Size = new System.Drawing.Size(80, 25);
this.labelFurniture.TabIndex = 0;
this.labelFurniture.Text = "Изделие";
//
// comboBoxToSell
//
this.comboBoxToSell.FormattingEnabled = true;
this.comboBoxToSell.Location = new System.Drawing.Point(174, 50);
this.comboBoxToSell.Name = "comboBoxToSell";
this.comboBoxToSell.Size = new System.Drawing.Size(182, 33);
this.comboBoxToSell.TabIndex = 1;
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(43, 133);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(107, 25);
this.labelCount.TabIndex = 2;
this.labelCount.Text = "Количество";
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(178, 131);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(150, 31);
this.textBoxCount.TabIndex = 3;
//
// buttonSell
//
this.buttonSell.Location = new System.Drawing.Point(38, 225);
this.buttonSell.Name = "buttonSell";
this.buttonSell.Size = new System.Drawing.Size(112, 34);
this.buttonSell.TabIndex = 4;
this.buttonSell.Text = "Продать";
this.buttonSell.UseVisualStyleBackColor = true;
this.buttonSell.Click += new System.EventHandler(this.buttonSell_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(216, 225);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(112, 34);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// FormSell
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(463, 313);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSell);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.comboBoxToSell);
this.Controls.Add(this.labelFurniture);
this.Name = "FormSell";
this.Text = "Продажа мебели";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelFurniture;
private ComboBox comboBoxToSell;
private Label labelCount;
private TextBox textBoxCount;
private Button buttonSell;
private Button buttonCancel;
}
}

View File

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

View File

@@ -1,220 +0,0 @@
namespace FurnitureAssembly
{
partial class FormShop
{
/// <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.labelShopName = new System.Windows.Forms.Label();
this.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxAddress = new System.Windows.Forms.TextBox();
this.labelAddress = new System.Windows.Forms.Label();
this.labelDate = new System.Windows.Forms.Label();
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.ButtonSave = new System.Windows.Forms.Button();
this.ButtonCancel = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.FurnitureId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.FurnitureName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.labelMaxCount = new System.Windows.Forms.Label();
this.textBoxMaxCount = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// labelShopName
//
this.labelShopName.AutoSize = true;
this.labelShopName.Location = new System.Drawing.Point(53, 75);
this.labelShopName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelShopName.Name = "labelShopName";
this.labelShopName.Size = new System.Drawing.Size(170, 25);
this.labelShopName.TabIndex = 0;
this.labelShopName.Text = "Название магазина";
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(240, 70);
this.textBoxName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(401, 31);
this.textBoxName.TabIndex = 1;
//
// textBoxAddress
//
this.textBoxAddress.Location = new System.Drawing.Point(240, 138);
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxAddress.Name = "textBoxAddress";
this.textBoxAddress.Size = new System.Drawing.Size(401, 31);
this.textBoxAddress.TabIndex = 3;
//
// labelAddress
//
this.labelAddress.AutoSize = true;
this.labelAddress.Location = new System.Drawing.Point(53, 143);
this.labelAddress.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelAddress.Name = "labelAddress";
this.labelAddress.Size = new System.Drawing.Size(62, 25);
this.labelAddress.TabIndex = 2;
this.labelAddress.Text = "Адрес";
//
// labelDate
//
this.labelDate.AutoSize = true;
this.labelDate.Location = new System.Drawing.Point(53, 213);
this.labelDate.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelDate.Name = "labelDate";
this.labelDate.Size = new System.Drawing.Size(131, 25);
this.labelDate.TabIndex = 4;
this.labelDate.Text = "Дата открытия";
//
// dateTimePicker
//
this.dateTimePicker.Location = new System.Drawing.Point(240, 203);
this.dateTimePicker.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(401, 31);
this.dateTimePicker.TabIndex = 6;
//
// ButtonSave
//
this.ButtonSave.Location = new System.Drawing.Point(546, 817);
this.ButtonSave.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonSave.Name = "ButtonSave";
this.ButtonSave.Size = new System.Drawing.Size(141, 47);
this.ButtonSave.TabIndex = 7;
this.ButtonSave.Text = "Сохранить";
this.ButtonSave.UseVisualStyleBackColor = true;
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// ButtonCancel
//
this.ButtonCancel.Location = new System.Drawing.Point(727, 817);
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(141, 47);
this.ButtonCancel.TabIndex = 8;
this.ButtonCancel.Text = "Отмена";
this.ButtonCancel.UseVisualStyleBackColor = true;
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.FurnitureId,
this.FurnitureName,
this.Count});
this.dataGridView1.Location = new System.Drawing.Point(53, 371);
this.dataGridView1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersWidth = 62;
this.dataGridView1.RowTemplate.Height = 25;
this.dataGridView1.Size = new System.Drawing.Size(816, 406);
this.dataGridView1.TabIndex = 9;
//
// FurnitureId
//
this.FurnitureId.HeaderText = "Id";
this.FurnitureId.MinimumWidth = 8;
this.FurnitureId.Name = "FurnitureId";
this.FurnitureId.Visible = false;
this.FurnitureId.Width = 150;
//
// FurnitureName
//
this.FurnitureName.HeaderText = "Название";
this.FurnitureName.MinimumWidth = 8;
this.FurnitureName.Name = "FurnitureName";
this.FurnitureName.Width = 150;
//
// Count
//
this.Count.HeaderText = "Количество";
this.Count.MinimumWidth = 8;
this.Count.Name = "Count";
this.Count.Width = 150;
//
// labelMaxCount
//
this.labelMaxCount.AutoSize = true;
this.labelMaxCount.Location = new System.Drawing.Point(58, 275);
this.labelMaxCount.Name = "labelMaxCount";
this.labelMaxCount.Size = new System.Drawing.Size(117, 25);
this.labelMaxCount.TabIndex = 10;
this.labelMaxCount.Text = "Вместимость";
//
// textBoxMaxCount
//
this.textBoxMaxCount.Location = new System.Drawing.Point(242, 267);
this.textBoxMaxCount.Name = "textBoxMaxCount";
this.textBoxMaxCount.Size = new System.Drawing.Size(399, 31);
this.textBoxMaxCount.TabIndex = 11;
//
// FormShop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(901, 883);
this.Controls.Add(this.textBoxMaxCount);
this.Controls.Add(this.labelMaxCount);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.ButtonCancel);
this.Controls.Add(this.ButtonSave);
this.Controls.Add(this.dateTimePicker);
this.Controls.Add(this.labelDate);
this.Controls.Add(this.textBoxAddress);
this.Controls.Add(this.labelAddress);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelShopName);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "FormShop";
this.Text = "Магазин";
this.Load += new System.EventHandler(this.FormShop_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelShopName;
private TextBox textBoxName;
private TextBox textBoxAddress;
private Label labelAddress;
private Label labelDate;
private DateTimePicker dateTimePicker;
private Button ButtonSave;
private Button ButtonCancel;
private DataGridView dataGridView1;
private DataGridViewTextBoxColumn FurnitureId;
private DataGridViewTextBoxColumn FurnitureName;
private DataGridViewTextBoxColumn Count;
private Label labelMaxCount;
private TextBox textBoxMaxCount;
}
}

View File

@@ -1,144 +0,0 @@
using AbstractFurnitureAssemblyDataModels.Models;
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using AbstractFurnitureAssemblyDataModels.Models;
using Microsoft.Extensions.Logging;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
namespace FurnitureAssembly
{
public partial class FormShop : Form
{
private readonly ILogger _logger;
private readonly IShopLogic _logic;
private Dictionary<int, (IFurnitureModel, int)> _shopFurnitures;
private int? _id;
public int Id { set { _id = value; } }
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
_shopFurnitures = new Dictionary<int, (IFurnitureModel, int)>();
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните название", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxAddress.Text))
{
MessageBox.Show("Заполните адрес", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(dateTimePicker.Text))
{
MessageBox.Show("Заполните дату открытия", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (Convert.ToInt32(textBoxMaxCount.Text) <= 0)
{
MessageBox.Show("Некорректная вместимость", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение магазина");
try
{
var model = new ShopBindingModel
{
Id = _id ?? 0,
ShopName = textBoxName.Text,
Address = textBoxAddress.Text,
DateOpening = dateTimePicker.Value,
MaxCount = Convert.ToInt32(textBoxMaxCount.Text)
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void FormShop_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение магазина");
var view = _logic.ReadElement(new ShopSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.ShopName;
textBoxAddress.Text = view.Address.ToString();
dateTimePicker.Value = view.DateOpening;
textBoxMaxCount.Text = view.MaxCount.ToString();
_shopFurnitures = view.Furnitures ?? new
Dictionary<int, (IFurnitureModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void LoadData()
{
_logger.LogInformation("Загрузка компонент изделия");
try
{
if (_shopFurnitures != null)
{
dataGridView1.Rows.Clear();
foreach (var pc in _shopFurnitures)
{
dataGridView1.Rows.Add(new object[] { pc.Key, pc.Value.Item1.FurnitureName, pc.Value.Item2 });
}
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}

View File

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

View File

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

View File

@@ -20,11 +20,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyFileImplem
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyDatabaseImplement", "..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj", "{36ED9141-7BD9-40C6-808F-93C7CA6E6391}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyRestApi", "..\FurnitureAssemblyRestApi\FurnitureAssemblyRestApi.csproj", "{4EEFC2A5-829A-4C0D-BBE0-76E765995FDB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyRestApi", "..\FurnitureAssemblyRestApi\FurnitureAssemblyRestApi.csproj", "{4EEFC2A5-829A-4C0D-BBE0-76E765995FDB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyClientApp", "..\FurnitureAssemblyClientApp\FurnitureAssemblyClientApp.csproj", "{34C0C84A-FEAF-478A-8794-768FB9FD4692}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyShopWorkApp", "..\FurnitureAssemblyShopWorkApp\FurnitureAssemblyShopWorkApp.csproj", "{31F20108-5750-4B26-B5BA-440441CEE692}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyClientApp", "..\FurnitureAssemblyClientApp\FurnitureAssemblyClientApp.csproj", "{34C0C84A-FEAF-478A-8794-768FB9FD4692}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -68,10 +66,6 @@ Global
{34C0C84A-FEAF-478A-8794-768FB9FD4692}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34C0C84A-FEAF-478A-8794-768FB9FD4692}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34C0C84A-FEAF-478A-8794-768FB9FD4692}.Release|Any CPU.Build.0 = Release|Any CPU
{31F20108-5750-4B26-B5BA-440441CEE692}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31F20108-5750-4B26-B5BA-440441CEE692}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31F20108-5750-4B26-B5BA-440441CEE692}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31F20108-5750-4B26-B5BA-440441CEE692}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,177 @@
namespace FurnitureAssemblyView
{
partial class ImplementerForm
{
/// <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.numericUpDownQual = new System.Windows.Forms.NumericUpDown();
this.numericUpDownWE = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.labelName = new System.Windows.Forms.Label();
this.textBoxPassword = new System.Windows.Forms.TextBox();
this.textBoxFIO = new System.Windows.Forms.TextBox();
this.ButtonCancel = new System.Windows.Forms.Button();
this.ButtonSave = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQual)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWE)).BeginInit();
this.SuspendLayout();
//
// numericUpDownQual
//
this.numericUpDownQual.Location = new System.Drawing.Point(269, 258);
this.numericUpDownQual.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.numericUpDownQual.Name = "numericUpDownQual";
this.numericUpDownQual.Size = new System.Drawing.Size(171, 31);
this.numericUpDownQual.TabIndex = 27;
//
// numericUpDownWE
//
this.numericUpDownWE.Location = new System.Drawing.Point(269, 187);
this.numericUpDownWE.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.numericUpDownWE.Name = "numericUpDownWE";
this.numericUpDownWE.Size = new System.Drawing.Size(171, 31);
this.numericUpDownWE.TabIndex = 26;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(129, 262);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(130, 25);
this.label3.TabIndex = 25;
this.label3.Text = "Квалификация";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(129, 190);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(118, 25);
this.label2.TabIndex = 24;
this.label2.Text = "Стаж работы";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(129, 123);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(74, 25);
this.label1.TabIndex = 23;
this.label1.Text = "Пароль";
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(129, 55);
this.labelName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(52, 25);
this.labelName.TabIndex = 22;
this.labelName.Text = "ФИО";
//
// textBoxPassword
//
this.textBoxPassword.Location = new System.Drawing.Point(269, 118);
this.textBoxPassword.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxPassword.Name = "textBoxPassword";
this.textBoxPassword.Size = new System.Drawing.Size(400, 31);
this.textBoxPassword.TabIndex = 21;
//
// textBoxFIO
//
this.textBoxFIO.Location = new System.Drawing.Point(269, 50);
this.textBoxFIO.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.textBoxFIO.Name = "textBoxFIO";
this.textBoxFIO.Size = new System.Drawing.Size(400, 31);
this.textBoxFIO.TabIndex = 20;
//
// ButtonCancel
//
this.ButtonCancel.Location = new System.Drawing.Point(564, 363);
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(107, 38);
this.ButtonCancel.TabIndex = 19;
this.ButtonCancel.Text = "Отмена";
this.ButtonCancel.UseVisualStyleBackColor = true;
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// ButtonSave
//
this.ButtonSave.Location = new System.Drawing.Point(415, 363);
this.ButtonSave.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonSave.Name = "ButtonSave";
this.ButtonSave.Size = new System.Drawing.Size(107, 38);
this.ButtonSave.TabIndex = 18;
this.ButtonSave.Text = "Сохранить";
this.ButtonSave.UseVisualStyleBackColor = true;
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// ImplementerForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.numericUpDownQual);
this.Controls.Add(this.numericUpDownWE);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.labelName);
this.Controls.Add(this.textBoxPassword);
this.Controls.Add(this.textBoxFIO);
this.Controls.Add(this.ButtonCancel);
this.Controls.Add(this.ButtonSave);
this.Name = "ImplementerForm";
this.Text = "Исполнитель";
this.Load += new System.EventHandler(this.ImplementerForm_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQual)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWE)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private NumericUpDown numericUpDownQual;
private NumericUpDown numericUpDownWE;
private Label label3;
private Label label2;
private Label label1;
private Label labelName;
private TextBox textBoxPassword;
private TextBox textBoxFIO;
private Button ButtonCancel;
private Button ButtonSave;
}
}

View File

@@ -0,0 +1,109 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using FurnitureAssemblyContracts.SearchModels;
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 FurnitureAssemblyView
{
public partial class ImplementerForm : Form
{
private readonly ILogger _logger;
private readonly IImplementerLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public ImplementerForm(ILogger<ImplementerForm> logger, IImplementerLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void ImplementerForm_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
_logger.LogInformation("Получение исполнителя");
var view = _logic.ReadElement(new ImplementerSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxFIO.Text = view.ImplementerFIO;
textBoxPassword.Text = view.Password;
numericUpDownWE.Value = view.WorkExperience;
numericUpDownQual.Value = view.Qualification;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFIO.Text))
{
MessageBox.Show("Заполните ФИО", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxPassword.Text))
{
MessageBox.Show("Заполните пароль", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение исполнителя");
try
{
var model = new ImplementerBindingModel
{
Id = _id ?? 0,
ImplementerFIO = textBoxFIO.Text,
Password = textBoxPassword.Text,
WorkExperience = Convert.ToInt32(numericUpDownWE.Value),
Qualification = Convert.ToInt32(numericUpDownQual.Value),
};
var operationResult = _id.HasValue ? _logic.Update(model) :
_logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@@ -1,6 +1,6 @@
namespace FurnitureAssembly
namespace FurnitureAssemblyView
{
partial class FormShops
partial class ImplementersForm
{
/// <summary>
/// Required designer variable.
@@ -28,76 +28,82 @@
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ButtonRef = new System.Windows.Forms.Button();
this.ButtonUpd = new System.Windows.Forms.Button();
this.ButtonDel = new System.Windows.Forms.Button();
this.ButtonUpd = new System.Windows.Forms.Button();
this.ButtonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(-1, -1);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(559, 453);
this.dataGridView.TabIndex = 6;
//
// ButtonRef
//
this.ButtonRef.Location = new System.Drawing.Point(601, 223);
this.ButtonRef.Location = new System.Drawing.Point(749, 309);
this.ButtonRef.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonRef.Name = "ButtonRef";
this.ButtonRef.Size = new System.Drawing.Size(105, 29);
this.ButtonRef.TabIndex = 13;
this.ButtonRef.Size = new System.Drawing.Size(150, 48);
this.ButtonRef.TabIndex = 16;
this.ButtonRef.Text = "Обновить";
this.ButtonRef.UseVisualStyleBackColor = true;
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// ButtonUpd
//
this.ButtonUpd.Location = new System.Drawing.Point(601, 168);
this.ButtonUpd.Name = "ButtonUpd";
this.ButtonUpd.Size = new System.Drawing.Size(105, 29);
this.ButtonUpd.TabIndex = 12;
this.ButtonUpd.Text = "Изменить";
this.ButtonUpd.UseVisualStyleBackColor = true;
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// ButtonDel
//
this.ButtonDel.Location = new System.Drawing.Point(601, 113);
this.ButtonDel.Location = new System.Drawing.Point(749, 212);
this.ButtonDel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonDel.Name = "ButtonDel";
this.ButtonDel.Size = new System.Drawing.Size(105, 29);
this.ButtonDel.TabIndex = 11;
this.ButtonDel.Size = new System.Drawing.Size(150, 48);
this.ButtonDel.TabIndex = 15;
this.ButtonDel.Text = "Удалить";
this.ButtonDel.UseVisualStyleBackColor = true;
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// ButtonUpd
//
this.ButtonUpd.Location = new System.Drawing.Point(749, 117);
this.ButtonUpd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonUpd.Name = "ButtonUpd";
this.ButtonUpd.Size = new System.Drawing.Size(150, 48);
this.ButtonUpd.TabIndex = 14;
this.ButtonUpd.Text = "Изменить";
this.ButtonUpd.UseVisualStyleBackColor = true;
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// ButtonAdd
//
this.ButtonAdd.Location = new System.Drawing.Point(601, 59);
this.ButtonAdd.Location = new System.Drawing.Point(749, 24);
this.ButtonAdd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonAdd.Name = "ButtonAdd";
this.ButtonAdd.Size = new System.Drawing.Size(105, 29);
this.ButtonAdd.TabIndex = 10;
this.ButtonAdd.Size = new System.Drawing.Size(150, 48);
this.ButtonAdd.TabIndex = 13;
this.ButtonAdd.Text = "Добавить";
this.ButtonAdd.UseVisualStyleBackColor = true;
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// FormShops
// dataGridView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(13, 14);
this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(707, 540);
this.dataGridView.TabIndex = 12;
//
// ImplementersForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(743, 451);
this.ClientSize = new System.Drawing.Size(992, 568);
this.Controls.Add(this.ButtonRef);
this.Controls.Add(this.ButtonUpd);
this.Controls.Add(this.ButtonDel);
this.Controls.Add(this.ButtonUpd);
this.Controls.Add(this.ButtonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormShops";
this.Text = "Магазины";
this.Load += new System.EventHandler(this.FormShops_Load);
this.Name = "ImplementersForm";
this.Text = "Исполнители";
this.Load += new System.EventHandler(this.ImplementersForm_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
@@ -105,10 +111,10 @@
#endregion
private DataGridView dataGridView;
private Button ButtonRef;
private Button ButtonUpd;
private Button ButtonDel;
private Button ButtonUpd;
private Button ButtonAdd;
private DataGridView dataGridView;
}
}

View File

@@ -1,39 +1,34 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssembly;
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.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 FurnitureAssembly
namespace FurnitureAssemblyView
{
public partial class FormShops : Form
public partial class ImplementersForm : Form
{
private readonly ILogger _logger;
private readonly IShopLogic _logic;
public FormShops(ILogger<FormShop> logger, IShopLogic logic)
private readonly IImplementerLogic _logic;
public ImplementersForm(ILogger<ImplementersForm> logger, IImplementerLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
if (service is FormShop form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void FormShops_Load(object sender, EventArgs e)
private void ImplementersForm_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
@@ -43,27 +38,41 @@ namespace FurnitureAssembly
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ImplementerFIO"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка магазинов");
_logger.LogInformation("Загрузка исполнителей");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки магазинов");
_logger.LogError(ex, "Ошибка загрузки исполнителей");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(ImplementerForm));
if (service is ImplementerForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormShop));
if (service is FormShop form)
Program.ServiceProvider?.GetService(typeof(ImplementerForm));
if (service is ImplementerForm form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
form.Id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
@@ -81,10 +90,13 @@ namespace FurnitureAssembly
{
int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление магазина");
_logger.LogInformation("Удаление исполнителя");
try
{
if (!_logic.Delete(new ShopBindingModel{ Id = id}))
if (!_logic.Delete(new ImplementerBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
@@ -92,7 +104,7 @@ namespace FurnitureAssembly
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления магазина");
_logger.LogError(ex, "Ошибка удаления исполнителя");
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}

64
FurnitureAssembly/MailForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,64 @@
namespace FurnitureAssemblyView
{
partial class MailForm
{
/// <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.dataGridViewMail = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewMail)).BeginInit();
this.SuspendLayout();
//
// dataGridViewMail
//
this.dataGridViewMail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridViewMail.Location = new System.Drawing.Point(0, 2);
this.dataGridViewMail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dataGridViewMail.Name = "dataGridViewMail";
this.dataGridViewMail.RowHeadersWidth = 62;
this.dataGridViewMail.RowTemplate.Height = 25;
this.dataGridViewMail.Size = new System.Drawing.Size(965, 592);
this.dataGridViewMail.TabIndex = 1;
//
// MailForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(965, 593);
this.Controls.Add(this.dataGridViewMail);
this.Name = "MailForm";
this.Text = "Письма";
this.Load += new System.EventHandler(this.MailForm_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridViewMail)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewMail;
}
}

View File

@@ -0,0 +1,48 @@
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
{
public partial class MailForm : Form
{
private readonly ILogger _logger;
private readonly IMessageInfoLogic _logic;
public MailForm(ILogger<MailForm> logger, IMessageInfoLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void MailForm_Load(object sender, EventArgs e)
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridViewMail.DataSource = list;
dataGridViewMail.Columns["ClientId"].Visible = false;
dataGridViewMail.Columns["MessageId"].Visible = false;
dataGridViewMail.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка писем");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки писем");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}

View File

@@ -39,16 +39,13 @@
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FurnituresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FurnituresComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.изделияВМагазинахToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовПоДатамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonSell = new System.Windows.Forms.Button();
this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
buttonReady = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip.SuspendLayout();
@@ -71,7 +68,7 @@
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.RowTemplate.Height = 33;
this.dataGridView.Size = new System.Drawing.Size(1227, 441);
this.dataGridView.Size = new System.Drawing.Size(1227, 386);
this.dataGridView.TabIndex = 0;
//
// buttonCreate
@@ -119,8 +116,14 @@
this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem,
this.пополнениеМагазинаToolStripMenuItem,
this.отчетыToolStripMenuItem});
this.отчетыToolStripMenuItem,
this.запускРаботToolStripMenuItem,
this.письмаToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1530, 33);
this.menuStrip.TabIndex = 6;
this.menuStrip.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
@@ -128,7 +131,7 @@
this.компонентыToolStripMenuItem,
this.изделияToolStripMenuItem,
this.клиентыToolStripMenuItem,
this.магазиныToolStripMenuItem});
this.исполнителиToolStripMenuItem});
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(139, 29);
this.справочникиToolStripMenuItem.Text = "Справочники";
@@ -136,47 +139,37 @@
// компонентыToolStripMenuItem
//
this.компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.компонентыToolStripMenuItem.Text = "Компоненты";
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
//
// изделияToolStripMenuItem
//
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.изделияToolStripMenuItem.Text = "Изделия";
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.изделияToolStripMenuItem_Click);
//
// клиентыToolStripMenuItem
//
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.клиентыToolStripMenuItem.Text = "Клиенты";
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
//
// магазиныToolStripMenuItem
// исполнителиToolStripMenuItem
//
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
this.магазиныToolStripMenuItem.Text = "Магазины";
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click);
//
// пополнениеМагазинаToolStripMenuItem
//
this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(210, 29);
this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.AddToShopToolStripMenuItem_Click);
this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.исполнителиToolStripMenuItem.Text = "Исполнители";
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.ImplementersToolStripMenuItem_Click);
//
// отчетыToolStripMenuItem
//
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FurnituresToolStripMenuItem,
this.FurnituresComponentsToolStripMenuItem,
this.списокЗаказовToolStripMenuItem,
this.списокМагазиновToolStripMenuItem,
this.изделияВМагазинахToolStripMenuItem,
this.списокЗаказовПоДатамToolStripMenuItem});
this.списокЗаказовToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(88, 29);
this.отчетыToolStripMenuItem.Text = "Отчеты";
@@ -202,43 +195,25 @@
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
//
// списокМагазиновToolStripMenuItem
// запускРаботToolStripMenuItem
//
this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(325, 34);
this.списокМагазиновToolStripMenuItem.Text = "Список магазинов";
this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(141, 29);
this.запускРаботToolStripMenuItem.Text = " Запуск работ";
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.doWorkToolStripMenuItem_Click);
//
// изделияВМагазинахToolStripMenuItem
// письмаToolStripMenuItem
//
this.изделияВМагазинахToolStripMenuItem.Name = "изделияВМагазинахToolStripMenuItem";
this.изделияВМагазинахToolStripMenuItem.Size = new System.Drawing.Size(325, 34);
this.изделияВМагазинахToolStripMenuItem.Text = "Изделия в магазинах";
this.изделияВМагазинахToolStripMenuItem.Click += new System.EventHandler(this.ShopsFurnituresToolStripMenuItem_Click);
//
// списокЗаказовПоДатамToolStripMenuItem
//
this.списокЗаказовПоДатамToolStripMenuItem.Name = "списокЗаказовПоДатамToolStripMenuItem";
this.списокЗаказовПоДатамToolStripMenuItem.Size = new System.Drawing.Size(325, 34);
this.списокЗаказовПоДатамToolStripMenuItem.Text = "Список заказов по датам";
this.списокЗаказовПоДатамToolStripMenuItem.Click += new System.EventHandler(this.OrderDateToolStripMenuItem_Click);
//
// buttonSell
//
this.buttonSell.Location = new System.Drawing.Point(1280, 450);
this.buttonSell.Name = "buttonSell";
this.buttonSell.Size = new System.Drawing.Size(208, 34);
this.buttonSell.TabIndex = 7;
this.buttonSell.Text = "Продать";
this.buttonSell.UseVisualStyleBackColor = true;
this.buttonSell.Click += new System.EventHandler(this.buttonSell_Click);
this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
this.письмаToolStripMenuItem.Size = new System.Drawing.Size(90, 29);
this.письмаToolStripMenuItem.Text = "Письма";
this.письмаToolStripMenuItem.Click += new System.EventHandler(this.mailToolStripMenuItem_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1530, 505);
this.Controls.Add(this.buttonSell);
this.ClientSize = new System.Drawing.Size(1530, 450);
this.Controls.Add(this.buttonRefresh);
this.Controls.Add(this.buttonPut);
this.Controls.Add(buttonReady);
@@ -269,17 +244,13 @@
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem компонентыToolStripMenuItem;
private ToolStripMenuItem изделияToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem;
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
private Button buttonSell;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem FurnituresToolStripMenuItem;
private ToolStripMenuItem FurnituresComponentsToolStripMenuItem;
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
private ToolStripMenuItem списокМагазиновToolStripMenuItem;
private ToolStripMenuItem изделияВМагазинахToolStripMenuItem;
private ToolStripMenuItem списокЗаказовПоДатамToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem;
private ToolStripMenuItem исполнителиToolStripMenuItem;
private ToolStripMenuItem запускРаботToolStripMenuItem;
private ToolStripMenuItem письмаToolStripMenuItem;
}
}

View File

@@ -19,17 +19,16 @@ namespace FurnitureAssemblyView
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IShopLogic _shopLogic;
private readonly IReportLogic _reportLogic;
private readonly IReportLogic _reportLogic;
private readonly IWorkProcess _workModeling;
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IShopLogic shopLogic)
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workModeling)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_shopLogic = shopLogic;
_reportLogic = reportLogic;
_workModeling = workModeling;
}
private void MainForm_Load(object sender, EventArgs e)
@@ -48,6 +47,7 @@ namespace FurnitureAssemblyView
dataGridView.DataSource = list;
dataGridView.Columns["FurnitureId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ImplementerId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов");
@@ -133,7 +133,8 @@ namespace FurnitureAssemblyView
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try {
try
{
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{
Id = id,
@@ -143,8 +144,10 @@ namespace FurnitureAssemblyView
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
@@ -196,26 +199,7 @@ namespace FurnitureAssemblyView
LoadData();
}
private void ShopToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
{
form.ShowDialog();
}
}
private void AddToShopToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAddToShop));
if (service is FormAddToShop form)
{
form.ShowDialog();
}
}
private void FurnituresToolStripMenuItem_Click(object sender, EventArgs e)
private void FurnituresToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
@@ -235,57 +219,16 @@ namespace FurnitureAssemblyView
var service =
Program.ServiceProvider?.GetService(typeof(FormReportFurnitureComponents));
if (service is FormReportFurnitureComponents form)
{
{
form.ShowDialog();
}
}
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
}
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormReportOrders));
if (service is FormReportOrders form)
{
form.ShowDialog();
}
}
private void buttonSell_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSell));
if (service is FormSell form)
{
form.ShowDialog();
}
}
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveShopsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
private void ShopsFurnituresToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(ReportShopFurnituresForm));
if (service is ReportShopFurnituresForm form)
{
form.ShowDialog();
}
}
private void OrderDateToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(ReportCountOrdersByPeriodForm));
if (service is ReportCountOrdersByPeriodForm form)
{
form.ShowDialog();
}
@@ -300,5 +243,29 @@ namespace FurnitureAssemblyView
}
}
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(ImplementersForm));
if (service is ImplementersForm form)
{
form.ShowDialog();
}
}
private void doWorkToolStripMenuItem_Click(object sender, EventArgs e)
{
_workModeling.DoWork((
Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!,
_orderLogic);
}
private void mailToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(MailForm));
if (service is MailForm form)
{
form.ShowDialog();
}
}
}
}

View File

@@ -36,12 +36,14 @@
this.textBoxSum = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.comboBoxClientEmail = new System.Windows.Forms.ComboBox();
this.labelClient = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// comboBoxFurniture
//
this.comboBoxFurniture.FormattingEnabled = true;
this.comboBoxFurniture.Location = new System.Drawing.Point(115, 14);
this.comboBoxFurniture.Location = new System.Drawing.Point(115, 70);
this.comboBoxFurniture.Name = "comboBoxFurniture";
this.comboBoxFurniture.Size = new System.Drawing.Size(250, 33);
this.comboBoxFurniture.TabIndex = 0;
@@ -49,7 +51,7 @@
// labelFurniture
//
this.labelFurniture.AutoSize = true;
this.labelFurniture.Location = new System.Drawing.Point(12, 22);
this.labelFurniture.Location = new System.Drawing.Point(12, 78);
this.labelFurniture.Name = "labelFurniture";
this.labelFurniture.Size = new System.Drawing.Size(80, 25);
this.labelFurniture.TabIndex = 1;
@@ -58,7 +60,7 @@
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(12, 67);
this.labelCount.Location = new System.Drawing.Point(12, 123);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(107, 25);
this.labelCount.TabIndex = 2;
@@ -67,7 +69,7 @@
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(12, 118);
this.labelSum.Location = new System.Drawing.Point(12, 174);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(67, 25);
this.labelSum.TabIndex = 3;
@@ -75,7 +77,7 @@
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(115, 64);
this.textBoxCount.Location = new System.Drawing.Point(115, 120);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(250, 31);
this.textBoxCount.TabIndex = 4;
@@ -83,7 +85,7 @@
//
// textBoxSum
//
this.textBoxSum.Location = new System.Drawing.Point(115, 115);
this.textBoxSum.Location = new System.Drawing.Point(115, 171);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.ReadOnly = true;
this.textBoxSum.Size = new System.Drawing.Size(250, 31);
@@ -91,7 +93,7 @@
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(31, 161);
this.buttonSave.Location = new System.Drawing.Point(31, 217);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(112, 34);
this.buttonSave.TabIndex = 6;
@@ -101,7 +103,7 @@
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(253, 161);
this.buttonCancel.Location = new System.Drawing.Point(253, 217);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(112, 34);
this.buttonCancel.TabIndex = 7;
@@ -109,11 +111,32 @@
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// comboBoxClientEmail
//
this.comboBoxClientEmail.FormattingEnabled = true;
this.comboBoxClientEmail.Location = new System.Drawing.Point(115, 14);
this.comboBoxClientEmail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.comboBoxClientEmail.Name = "comboBoxClientEmail";
this.comboBoxClientEmail.Size = new System.Drawing.Size(270, 33);
this.comboBoxClientEmail.TabIndex = 11;
//
// labelClient
//
this.labelClient.AutoSize = true;
this.labelClient.Location = new System.Drawing.Point(21, 17);
this.labelClient.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelClient.Name = "labelClient";
this.labelClient.Size = new System.Drawing.Size(71, 25);
this.labelClient.TabIndex = 10;
this.labelClient.Text = "Клиент:";
//
// OrderForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(401, 207);
this.ClientSize = new System.Drawing.Size(389, 277);
this.Controls.Add(this.comboBoxClientEmail);
this.Controls.Add(this.labelClient);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxSum);
@@ -140,5 +163,7 @@
private TextBox textBoxSum;
private Button buttonSave;
private Button buttonCancel;
private ComboBox comboBoxClientEmail;
private Label labelClient;
}
}

View File

@@ -19,12 +19,14 @@ namespace FurnitureAssemblyView
private readonly ILogger _logger;
private readonly IfurnitureLogic _logicP;
private readonly IOrderLogic _logicO;
public OrderForm(ILogger<OrderForm> logger, IfurnitureLogic logicP, IOrderLogic logicO)
private readonly IClientLogic _logicC;
public OrderForm(ILogger<OrderForm> logger, IfurnitureLogic logicF, IOrderLogic logicO, IClientLogic logicC)
{
InitializeComponent();
_logger = logger;
_logicP = logicP;
_logicP = logicF;
_logicO = logicO;
_logicC = logicC;
}
private void OrderForm_Load(object sender, EventArgs e)
@@ -35,12 +37,23 @@ namespace FurnitureAssemblyView
var list = _logicP.ReadList(null);
if (list != null)
{
comboBoxFurniture.DisplayMember = "Furniture";
comboBoxFurniture.DisplayMember = "FurnitureName";
comboBoxFurniture.ValueMember = "Id";
comboBoxFurniture.DataSource = list.Select(c => c.FurnitureName).ToList();
comboBoxFurniture.DataSource = list;
comboBoxFurniture.SelectedItem = null;
//comboBoxProduct.ValueMember = "Id";
//comboBoxProduct.DataSource = _list;
//comboBoxProduct.SelectedItem = null;
}
var _listCli = _logicC.ReadList(null);
if (_listCli != null)
{
comboBoxClientEmail.DisplayMember = "Email"; // по нему однозначно можно определить клиента
comboBoxClientEmail.ValueMember = "Id";
comboBoxClientEmail.DataSource = _listCli;
comboBoxClientEmail.SelectedItem = null;
}
}
catch (Exception ex)
{
@@ -50,17 +63,20 @@ namespace FurnitureAssemblyView
}
private void CalcSum()
{
if (comboBoxFurniture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
if (comboBoxFurniture.SelectedValue != null &&
!string.IsNullOrEmpty(textBoxCount.Text))
{
try
{
int id = Convert.ToInt32(comboBoxFurniture.SelectedIndex)+1;
var furniture = _logicP.ReadElement(new FurnitureSearchModel
int id = Convert.ToInt32(comboBoxFurniture.SelectedValue);
var product = _logicP.ReadElement(new FurnitureSearchModel
{
Id = id
Id
= id
});
int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (furniture?.Price ?? 0), 2).ToString();
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0),
2).ToString();
_logger.LogInformation("Расчет суммы заказа");
}
catch (Exception ex)
@@ -96,15 +112,17 @@ namespace FurnitureAssemblyView
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
FurnitureId = Convert.ToInt32(comboBoxFurniture.SelectedIndex)+1,
FurnitureId = Convert.ToInt32(comboBoxFurniture.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text)
Sum = Convert.ToDouble(textBoxSum.Text),
ClientId = Convert.ToInt32(comboBoxClientEmail.SelectedValue)
});
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}

View File

@@ -9,6 +9,7 @@ using FurnitureAssemblyView;
using Microsoft.Extensions.Logging;
using FurnitureAssemblyBusinessLogic.OfficePackage;
using FurnitureAssemblyBusinessLogic.OfficePackage.Implements;
using FurnitureAssemblyContracts.BindingModels;
namespace FurnitureAssembly
{
@@ -26,6 +27,34 @@ namespace FurnitureAssembly
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
try
{
var mailSender =
_serviceProvider.GetService<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin =
System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ??
string.Empty,
MailPassword =
System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ??
string.Empty,
SmtpClientHost =
System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ??
string.Empty,
SmtpClientPort =
Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
});
var timer = new System.Threading.Timer(new
TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
var logger = _serviceProvider.GetService<ILogger>();
logger?.LogError(ex, "Error");
}
Application.Run(_serviceProvider.GetRequiredService<MainForm>());
}
private static void ConfigureServices(ServiceCollection services)
@@ -38,14 +67,18 @@ namespace FurnitureAssembly
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IFurnitureStorage, FurnitureStorage>();
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IfurnitureLogic, FurnitureLogic>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IWorkProcess, WorkModeling>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
services.AddTransient<MainForm>();
services.AddTransient<ComponentForm>();
services.AddTransient<ComponentsForm>();
@@ -53,13 +86,8 @@ namespace FurnitureAssembly
services.AddTransient<FurnitureForm>();
services.AddTransient<FurnituresForm>();
services.AddTransient<FurnitureComponentForm>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormAddToShop>();
services.AddTransient<FormSell>();
services.AddTransient<ReportShopFurnituresForm>();
services.AddTransient<ReportCountOrdersByPeriodForm>();
services.AddTransient<ClientsForm>();
services.AddTransient<MailForm>();
services.AddTransient<FormReportFurnitureComponents>();
services.AddTransient<FormReportOrders>();
@@ -67,8 +95,11 @@ namespace FurnitureAssembly
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
}
services.AddTransient<ImplementersForm>();
services.AddTransient<ImplementerForm>();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
}
}

View File

@@ -1,133 +0,0 @@
namespace FurnitureAssemblyView
{
partial class ReportCountOrdersByPeriodForm
{
/// <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.panel = new System.Windows.Forms.Panel();
this.buttonMake_Pdf = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.buttonToPdf = new System.Windows.Forms.Button();
this.buttonMake = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.panel.SuspendLayout();
this.SuspendLayout();
//
// panel
//
this.panel.Controls.Add(this.button2);
this.panel.Controls.Add(this.buttonMake_Pdf);
this.panel.Controls.Add(this.button1);
this.panel.Controls.Add(this.buttonToPdf);
this.panel.Controls.Add(this.buttonMake);
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
this.panel.Location = new System.Drawing.Point(0, 0);
this.panel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(986, 67);
this.panel.TabIndex = 3;
//
// buttonMake_Pdf
//
this.buttonMake_Pdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonMake_Pdf.Location = new System.Drawing.Point(1966, 13);
this.buttonMake_Pdf.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonMake_Pdf.Name = "buttonMake_Pdf";
this.buttonMake_Pdf.Size = new System.Drawing.Size(199, 45);
this.buttonMake_Pdf.TabIndex = 7;
this.buttonMake_Pdf.Text = "В Pdf";
this.buttonMake_Pdf.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(3020, 13);
this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(199, 45);
this.button1.TabIndex = 6;
this.button1.Text = "В Pdf";
this.button1.UseVisualStyleBackColor = true;
//
// buttonToPdf
//
this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonToPdf.Location = new System.Drawing.Point(4289, 13);
this.buttonToPdf.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonToPdf.Name = "buttonToPdf";
this.buttonToPdf.Size = new System.Drawing.Size(199, 45);
this.buttonToPdf.TabIndex = 5;
this.buttonToPdf.Text = "В Pdf";
this.buttonToPdf.UseVisualStyleBackColor = true;
//
// buttonMake
//
this.buttonMake.Location = new System.Drawing.Point(126, 14);
this.buttonMake.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonMake.Name = "buttonMake";
this.buttonMake.Size = new System.Drawing.Size(199, 45);
this.buttonMake.TabIndex = 4;
this.buttonMake.Text = "Сформировать";
this.buttonMake.UseVisualStyleBackColor = true;
this.buttonMake.Click += new System.EventHandler(this.buttonMake_Click);
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Location = new System.Drawing.Point(584, 14);
this.button2.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(199, 45);
this.button2.TabIndex = 8;
this.button2.Text = "В Pdf";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// ReportCountOrdersByPeriodForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(986, 491);
this.Controls.Add(this.panel);
this.Name = "ReportCountOrdersByPeriodForm";
this.Text = "Заказы по датам";
this.Load += new System.EventHandler(this.ReportCountOrdersByPeriodForm_Load);
this.panel.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Panel panel;
private Button button2;
private Button buttonMake_Pdf;
private Button button1;
private Button buttonToPdf;
private Button buttonMake;
}
}

View File

@@ -1,87 +0,0 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FurnitureAssemblyView
{
public partial class ReportCountOrdersByPeriodForm : Form
{
private readonly ReportViewer reportViewer;
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public ReportCountOrdersByPeriodForm(ILogger<ReportCountOrdersByPeriodForm> logger, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_logic = reportLogic;
reportViewer = new ReportViewer
{
Dock = DockStyle.Fill
};
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrdersCount.rdlc", FileMode.Open)); // другой файл
Controls.Clear();
Controls.Add(reportViewer);
Controls.Add(panel);
}
private void ReportCountOrdersByPeriodForm_Load(object sender, EventArgs e)
{
}
private void buttonMake_Click(object sender, EventArgs e)
{
try
{
var dataSource = _logic.GetCountOrders();
var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source);
reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов, объединенных по дате");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button2_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveCountOrdersToPdfFile(new ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка заказов");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

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

View File

@@ -1,459 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="FurnitureAssemblyContractsViewModels">
<ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties>
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSetOrders">
<Query>
<DataSourceName>FurnitureAssemblyContractsViewModels</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<Fields>
<Field Name="DateCreate">
<DataField>DateCreate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="CountOrders">
<DataField>CountOrders</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="TotalSumOrders">
<DataField>TotalSumOrders</DataField>
<rd:TypeName>System.Double</rd:TypeName>
</Field>
</Fields>
<rd:DataSetInfo>
<rd:DataSetName>FurnitureAssemblyContracts.ViewModels</rd:DataSetName>
<rd:TableName>ReportCountOrdersViewModel</rd:TableName>
<rd:ObjectDataSourceType>FurnitureAssemblyContracts.ViewModels.ReportCountOrdersViewModel, FurnitureAssemblyContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="ReportParameterPeriod">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Parameters!ReportParameterPeriod.Value</Value>
<Style>
<FontSize>14pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
<Top>1cm</Top>
<Height>1cm</Height>
<Width>21cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="TextboxTitle">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Заказы</Value>
<Style>
<FontSize>16pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Height>1cm</Height>
<Width>21cm</Width>
<ZIndex>1</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Tablix Name="Tablix1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>3cm</Width>
</TablixColumn>
<TablixColumn>
<Width>3cm</Width>
</TablixColumn>
<TablixColumn>
<Width>7cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Дата создания</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox3">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Количество заказов</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox3</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Сумма</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox2</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="DateCreate">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!DateCreate.Value</Value>
<Style>
<Format>d</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>DateCreate</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="CountOrders">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!CountOrders.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>CountOrders</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="TotalSumOrders">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!TotalSumOrders.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>TotalSumOrders</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Подробности" />
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSetOrders</DataSetName>
<Top>2.48391cm</Top>
<Left>0.55245cm</Left>
<Height>1.2cm</Height>
<Width>19.84713cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>
<Style>Double</Style>
</Border>
</Style>
</Tablix>
<Textbox Name="TextboxTotalSum">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Итого:</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>15.39958cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>3</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="SumTotal">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Fields!TotalSumOrders.Value, "DataSetOrders")</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>17.89958cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>4</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</ReportItems>
<Height>5.72875cm</Height>
<Style />
</Body>
<Width>21cm</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
<LeftMargin>2cm</LeftMargin>
<RightMargin>2cm</RightMargin>
<TopMargin>2cm</TopMargin>
<BottomMargin>2cm</BottomMargin>
<ColumnSpacing>0.13cm</ColumnSpacing>
<Style />
</Page>
</ReportSection>
</ReportSections>
<ReportParameters>
<ReportParameter Name="ReportParameterPeriod">
<DataType>String</DataType>
<Nullable>true</Nullable>
<Prompt>ReportParameter1</Prompt>
</ReportParameter>
</ReportParameters>
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>4</NumberOfColumns>
<NumberOfRows>2</NumberOfRows>
<CellDefinitions>
<CellDefinition>
<ColumnIndex>0</ColumnIndex>
<RowIndex>0</RowIndex>
<ParameterName>ReportParameterPeriod</ParameterName>
</CellDefinition>
</CellDefinitions>
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
</Report>

View File

@@ -1,110 +0,0 @@
namespace FurnitureAssemblyView
{
partial class ReportShopFurnituresForm
{
/// <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.Shop = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Furniture = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ButtonSaveToExcel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Shop,
this.Furniture,
this.Count});
this.dataGridView.Location = new System.Drawing.Point(10, 76);
this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(777, 384);
this.dataGridView.TabIndex = 4;
//
// Shop
//
this.Shop.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Shop.HeaderText = "Магазин";
this.Shop.MinimumWidth = 8;
this.Shop.Name = "Shop";
//
// Furniture
//
this.Furniture.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Furniture.HeaderText = "Изделие";
this.Furniture.MinimumWidth = 8;
this.Furniture.Name = "Furniture";
//
// Count
//
this.Count.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
this.Count.HeaderText = "Количество";
this.Count.MinimumWidth = 8;
this.Count.Name = "Count";
this.Count.Width = 143;
//
// ButtonSaveToExcel
//
this.ButtonSaveToExcel.Location = new System.Drawing.Point(10, 17);
this.ButtonSaveToExcel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonSaveToExcel.Name = "ButtonSaveToExcel";
this.ButtonSaveToExcel.Size = new System.Drawing.Size(181, 49);
this.ButtonSaveToExcel.TabIndex = 3;
this.ButtonSaveToExcel.Text = "Сохранить в Excel";
this.ButtonSaveToExcel.UseVisualStyleBackColor = true;
this.ButtonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
//
// ReportShopFurnituresForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 476);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.ButtonSaveToExcel);
this.Name = "ReportShopFurnituresForm";
this.Text = "Магазины и изделия";
this.Load += new System.EventHandler(this.ReportShopFurnituresForm_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn Shop;
private DataGridViewTextBoxColumn Furniture;
private DataGridViewTextBoxColumn Count;
private Button ButtonSaveToExcel;
}
}

View File

@@ -1,87 +0,0 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
{
public partial class ReportShopFurnituresForm : Form
{
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public ReportShopFurnituresForm(ILogger<ReportShopFurnituresForm> logger, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_logic = reportLogic;
}
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog
{
Filter = "xlsx|*.xlsx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveShopFurnituresToExcelFile(new
ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка магазинов с изделиями в них");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка магазинов с изделиями в них");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ReportShopFurnituresForm_Load(object sender, EventArgs e)
{
try
{
var dict = _logic.GetShopFurnitures();
if (dict != null)
{
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
foreach (var listElem in elem.Furnitures)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
dataGridView.Rows.Add(Array.Empty<object>());
}
}
_logger.LogInformation("Загрузка списка магазинов с изделиями в них");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка магазинов с изделиями в них");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}

View File

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

View File

@@ -0,0 +1,87 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
{
public abstract class AbstractMailWorker
{
protected string _mailLogin = string.Empty;
protected string _mailPassword = string.Empty;
protected string _smtpClientHost = string.Empty;
protected int _smtpClientPort;
protected string _popHost = string.Empty;
protected int _popPort;
private readonly IMessageInfoLogic _messageInfoLogic;
private readonly ILogger _logger;
private readonly IClientLogic _clientLogic;
public AbstractMailWorker(ILogger<AbstractMailWorker> logger,
IMessageInfoLogic messageInfoLogic,
IClientLogic clientLogic)
{
_logger = logger;
_messageInfoLogic = messageInfoLogic;
_clientLogic = clientLogic;
}
public void MailConfig(MailConfigBindingModel config)
{
_mailLogin = config.MailLogin;
_mailPassword = config.MailPassword;
_smtpClientHost = config.SmtpClientHost;
_smtpClientPort = config.SmtpClientPort;
_popHost = config.PopHost;
_popPort = config.PopPort;
_logger.LogDebug("Config: {login}, {password}, {clientHost},{ clientPOrt}, { popHost}, { popPort}", _mailLogin, _mailPassword, _smtpClientHost,
_smtpClientPort, _popHost, _popPort);
}
public async void MailSendAsync(MailSendInfoBindingModel info)
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
{
return;
}
if (string.IsNullOrEmpty(info.MailAddress) ||
string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
{
return;
}
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress,
info.Subject);
await SendMailAsync(info);
}
public async void MailCheck()
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
{
return;
}
if (_messageInfoLogic == null)
{
return;
}
var list = await ReceiveMailAsync();
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
foreach (var mail in list)
{
mail.ClientId = _clientLogic.ReadElement(new() { Email = mail.SenderName })?.Id;
_messageInfoLogic.Create(mail);
}
}
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
}
}

View File

@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
@@ -112,6 +113,15 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
throw new ArgumentNullException("Нет пароля пользователя",
nameof(model.Password));
}
if (!Regex.IsMatch(model.Email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,})+)$"))
{
throw new ArgumentException("Некорректно введена почта клиента", nameof(model.Email));
}
if (!Regex.IsMatch(model.Password, @"^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$"))
{
throw new ArgumentException("Некорректно введен пароль клиента", nameof(model.Password));
}
_logger.LogInformation("Component. ClientFIO:{ClientFIO}. Email:{ Email}. Id: { Id}", model.ClientFIO, model.Email, model.Id);
var element = _clientStorage.GetElement(new ClientSearchModel { Email = model.Email });
if (element != null && element.Id != model.Id)

View File

@@ -0,0 +1,131 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
{
public class ImplementerLogic : IImplementerLogic
{
private readonly ILogger _logger;
private readonly IImplementerStorage _implementerStorage;
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
{
_logger = logger;
_implementerStorage = implementerStorage;
}
public bool Create(ImplementerBindingModel model)
{
CheckModel(model);
if (_implementerStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(ImplementerBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_implementerStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ImplementerFIO: {ImplementerFIO} Id:{ Id}", model.ImplementerFIO, model.Id);
var element = _implementerStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
{
_logger.LogInformation("ReadList. ImplementerFIO: {ImplementerFIO}. Id:{ Id}", model?.ImplementerFIO, model?.Id);
var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Update(ImplementerBindingModel model)
{
CheckModel(model);
if (_implementerStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ImplementerFIO))
{
throw new ArgumentNullException("Нет ФИО исполнителя",
nameof(model.ImplementerFIO));
}
if (string.IsNullOrEmpty(model.Password))
{
throw new ArgumentNullException("Нет пароля пользователя",
nameof(model.Password));
}
if (model.WorkExperience < 0)
{
throw new ArgumentException("Опыт работы не должен быть отрицательным", nameof(model.WorkExperience));
}
if (model.Qualification < 0)
{
throw new ArgumentException("Квалификация не должна быть отрицательной", nameof(model.Qualification));
}
_logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}. Id: { Id}", model.ImplementerFIO, model.Id);
var element = _implementerStorage.GetElement(new ImplementerSearchModel { ImplementerFIO = model.ImplementerFIO });
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Исполнитель с таким логином уже есть");
}
}
}
}

View File

@@ -0,0 +1,82 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using MailKit.Net.Pop3;
using MailKit.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Security.Authentication;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
{
public class MailKitWorker : AbstractMailWorker
{
public MailKitWorker(Microsoft.Extensions.Logging.ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic) : base(logger, messageInfoLogic, clientLogic) { }
protected override async Task SendMailAsync(MailSendInfoBindingModel
info)
{
using var objMailMessage = new MailMessage();
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
try
{
objMailMessage.From = new MailAddress(_mailLogin);
objMailMessage.To.Add(new MailAddress(info.MailAddress));
objMailMessage.Subject = info.Subject;
objMailMessage.Body = info.Text;
objMailMessage.SubjectEncoding = Encoding.UTF8;
objMailMessage.BodyEncoding = Encoding.UTF8;
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.EnableSsl = true;
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.Credentials = new NetworkCredential(_mailLogin,
_mailPassword);
await Task.Run(() => objSmtpClient.Send(objMailMessage));
}
catch (Exception)
{
throw;
}
}
protected override async Task<List<MessageInfoBindingModel>>
ReceiveMailAsync()
{
var list = new List<MessageInfoBindingModel>();
using var client = new Pop3Client();
await Task.Run(() =>
{
try
{
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
client.Authenticate(_mailLogin, _mailPassword);
for (int i = 0; i < client.Count; i++)
{
var message = client.GetMessage(i);
foreach (var mail in message.From.Mailboxes)
{
list.Add(new MessageInfoBindingModel
{
DateDelivery = message.Date.DateTime,
MessageId = message.MessageId,
SenderName = mail.Address,
Subject = message.Subject,
Body = message.TextBody
});
}
}
}
catch (System.Security.Authentication.AuthenticationException)
{ }
finally
{
client.Disconnect(true);
}
});
return list;
}
}
}

View File

@@ -0,0 +1,49 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
{
public class MessageInfoLogic : IMessageInfoLogic
{
private readonly ILogger _logger;
private readonly IMessageInfoStorage _messageInfoStorage;
public MessageInfoLogic(ILogger<MessageInfoLogic> logger, IMessageInfoStorage messageInfoStorage)
{
_logger = logger;
_messageInfoStorage = messageInfoStorage;
}
public bool Create(MessageInfoBindingModel model)
{
if (_messageInfoStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
{
_logger.LogInformation("ReadList. ClientId:{ClientId}. MessageId:{ MessageId}", model?.ClientId, model?.MessageId);
var list = model == null ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
}
}

View File

@@ -17,58 +17,79 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
private readonly IShopLogic _shopLogic;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic)
private readonly AbstractMailWorker _mailWorker;
private readonly IClientLogic _clientLogic;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IClientLogic clientLogic, AbstractMailWorker abstractMailWorker)
{
_logger = logger;
_orderStorage = orderStorage;
_shopLogic = shopLogic;
_clientLogic = clientLogic;
_mailWorker = abstractMailWorker;
}
private bool ChangeStatus(OrderBindingModel model, OrderStatus orderStatus)
{
if (model.Status + 1 != orderStatus)
{
return false;
}
model.Status = orderStatus;
SendMail(model.ClientId, $"Статус заказа {model.Id} изменен", $"Заказ {model.Id} переведен в статус {model.Status}");
return true;
}
public bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Неизвестен) return false;
model.Status = OrderStatus.Принят;
if (_orderStorage.Insert(model) == null)
{
var order = _orderStorage.Insert(model);
if (order == null) {
_logger.LogWarning("Insert operation failed");
return false;
}
SendMail(model.ClientId, $"Создание заказа {order.Id}", $"Заказ под номером {order.Id} создан {model.DateCreate}");
return true;
}
public bool DeliveryOrder(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Готов) return false;
if (!_shopLogic.AddFurnituresAtShops(new FurnitureBindingModel() { Id = model.FurnitureId }, model.Count))
var modelNew = ReadElement(new OrderSearchModel { Id = model.Id }); // в связи с обновлением контракта, предыдущий метод не нужен
if (modelNew == null)
{
_logger.LogWarning("There are not empty places at shops. Replenishment is impossible");
return false;
}
model.Status = OrderStatus.Выдан;
model.DateImplement = DateTime.Now;
if (_orderStorage.Update(model) == null)
model.Id = modelNew.Id;
model.Status = modelNew.Status;
model.ClientId = modelNew.ClientId;
model.ImplementerId = modelNew.ImplementerId;
model.DateImplement = modelNew.DateImplement;
if (!ChangeStatus(model, OrderStatus.Выдан))
{
_logger.LogWarning("Update operation failed");
_logger.LogWarning("Order's status is wrong");
return false;
}
_orderStorage.Update(model);
return true;
}
public bool FinishOrder(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Выполняется) return false;
model.Status = OrderStatus.Готов;
if (_orderStorage.Update(model) == null)
var modelNew = ReadElement(new OrderSearchModel { Id = model.Id });
if (modelNew == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
model.Id = modelNew.Id;
model.Status = modelNew.Status;
model.ClientId = modelNew.ClientId;
model.ImplementerId = modelNew.ImplementerId;
if (!ChangeStatus(model, OrderStatus.Готов))
{
_logger.LogWarning("Order's status is wrong");
return false;
}
model.DateImplement = DateTime.Now;
_orderStorage.Update(model);
return true;
}
@@ -87,14 +108,20 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
public bool TakeOrderInWork(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Принят) return false;
model.Status = OrderStatus.Выполняется;
if (_orderStorage.Update(model) == null)
var modelNew = ReadElement(new OrderSearchModel { Id = model.Id });
if (modelNew == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
model.Status = modelNew.Status;
model.ClientId = modelNew.ClientId;
model.Id = modelNew.Id;
if (!ChangeStatus(model, OrderStatus.Выполняется))
{
_logger.LogWarning("Order's status is wrong");
return false;
}
_orderStorage.Update(model);
return true;
}
@@ -127,6 +154,37 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. PackageId: { PackageId}", model.Id, model.Sum, model.FurnitureId);
}
public OrderViewModel? ReadElement(OrderSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Status: {Status}. ImplementerId: {ImplementerId} Id:{ Id}", model.Status, model.ImplementerId, model.Id);
var element = _orderStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
private bool SendMail(int clientId, string subject, string text)
{
var client = _clientLogic.ReadElement(new() { Id = clientId });
if (client == null)
{
_logger.LogWarning("Email sending failed. Client with id {Id} not found", clientId);
return false;
}
_mailWorker.MailSendAsync(new MailSendInfoBindingModel()
{
Subject = subject,
Text = text,
MailAddress = client.Email
});
return true;
}
}
}

View File

@@ -15,21 +15,21 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
{
public class ReportLogic : IReportLogic
{
private readonly IComponentStorage _componentStorage;
private readonly IFurnitureStorage _furnitureStorage;
private readonly IOrderStorage _orderStorage;
private readonly IShopStorage _shopStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(IFurnitureStorage furnitureStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf, IShopStorage shopStorage)
public ReportLogic(IFurnitureStorage furnitureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_furnitureStorage = furnitureStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
_shopStorage = shopStorage;
}
/// <summary>
/// Получение списка компонент с указанием, в каких изделиях используются
@@ -38,6 +38,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
public List<ReportFurnitureComponentViewModel> GetFurnitureComponent()
{
var furnitures = _furnitureStorage.GetFullList();
var components = _componentStorage.GetFullList();
var list = new List<ReportFurnitureComponentViewModel>();
foreach (var furniture in furnitures)
{
@@ -47,10 +48,13 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
Components = new List<Tuple<string, int>>(),
TotalCount = 0
};
foreach (var componentCount in furniture.FurnitureComponents.Values)
foreach (var component in components)
{
record.Components.Add(new Tuple<string, int>(componentCount.Item1.ComponentName, componentCount.Item2));
record.TotalCount += componentCount.Item2;
if (furniture.FurnitureComponents.ContainsKey(component.Id))
{
record.Components.Add(new Tuple<string, int>(component.ComponentName, furniture.FurnitureComponents[component.Id].Item2));
record.TotalCount += furniture.FurnitureComponents[component.Id].Item2;
}
}
list.Add(record);
}
@@ -84,7 +88,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
/// <param name="model"></param>
public void SaveFurnituresToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfoFurnitures
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список изделий",
@@ -97,7 +101,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
/// <param name="model"></param>
public void SaveFurnitureComponentToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoFurnitures
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список изделий",
@@ -110,7 +114,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
/// <param name="model"></param>
public void SaveOrdersToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateDoc(new PdfInfoOrders
_saveToPdf.CreateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Список заказов",
@@ -119,69 +123,5 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
Orders = GetOrders(model)
});
}
/// <summary>
/// Сохранение магазинов в файл-Word
/// </summary>
/// <param name="model"></param>
public void SaveShopsToWordFile(ReportBindingModel model)
{
_saveToWord.CreateTableDoc(new WordInfoShops
{
FileName = model.FileName,
Title = "Список магазинов",
Shops = _shopStorage.GetFullList()
});
}
public void SaveShopFurnituresToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoShops
{
FileName = model.FileName,
Title = "Список магазинов с изделиями",
ShopFurnitures = GetShopFurnitures()
});
}
public List<ReportShopFurnituresViewModel> GetShopFurnitures()
{
var shops = _shopStorage.GetFullList();
var list = new List<ReportShopFurnituresViewModel>();
foreach (var shop in shops)
{
var record = new ReportShopFurnituresViewModel
{
ShopName = shop.ShopName,
Furnitures = new List<Tuple<string, int>>(),
TotalCount = 0
};
foreach (var furnitureCount in shop.Furnitures.Values)
{
record.Furnitures.Add(new Tuple<string, int>(furnitureCount.Item1.FurnitureName, furnitureCount.Item2));
record.TotalCount += furnitureCount.Item2;
}
list.Add(record);
}
return list;
}
public List<ReportCountOrdersViewModel> GetCountOrders()
{
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportCountOrdersViewModel
{
DateCreate = x.Key,
CountOrders = x.Count(),
TotalSumOrders = x.Sum(y => y.Sum)
}).ToList();
}
public void SaveCountOrdersToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateDoc(new PdfInfoCountOrders
{
FileName = model.FileName,
Title = "Список объединенных по дате заказов",
CountOrders = GetCountOrders()
});
}
}
}

View File

@@ -1,208 +0,0 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
{
public class ShopLogic : IShopLogic
{
private readonly ILogger _logger;
private readonly IShopStorage _shopStorage;
private readonly IFurnitureStorage _furnitureStorage;
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage, IFurnitureStorage furnitureStorage)
{
_logger = logger;
_shopStorage = shopStorage;
_furnitureStorage = furnitureStorage;
}
public ShopViewModel? ReadElement(ShopSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ShopName:{ShopName}. Id:{ Id}", model.ShopName, model.Id);
var element = _shopStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
{
_logger.LogInformation("ReadList. ShopName:{ShopName}. Id:{ Id}", model?.ShopName, model?.Id);
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Create(ShopBindingModel model)
{
CheckModel(model);
if (_shopStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(ShopBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_shopStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Update(ShopBindingModel model)
{
CheckModel(model);
if (_shopStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(ShopBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ShopName))
{
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
}
if (string.IsNullOrEmpty(model.Address))
{
throw new ArgumentNullException("Нет адреса магазина", nameof(model.Address));
}
if (model.DateOpening.Equals(null))
{
throw new ArgumentNullException("Нет даты открытия магазина", nameof(model.DateOpening));
}
if (model.MaxCount <= 0)
{
throw new ArgumentNullException("Нет вместимости магазина", nameof(model.DateOpening));
}
_logger.LogInformation("Shop. ShopName:{ShopName}. Address:{ Address}. DateOpening:{ DateOpening}. Id: { Id}", model.ShopName, model.Address, model.DateOpening, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName });
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Магазин с таким названием уже есть");
}
}
public bool AddFurniture(ShopBindingModel model, FurnitureBindingModel furnitureModel, int count)
{
var shop = _shopStorage.GetElement(new ShopSearchModel { Id = model.Id });
var furniture = _furnitureStorage.GetElement(new FurnitureSearchModel { Id = furnitureModel.Id });
if (shop == null || furniture == null)
{
return false;
}
if (GetCountFreePlaces(model.Id) < count)
{
return false;
}
if (shop.Furnitures.ContainsKey(furniture.Id))
{
int prev_count = shop.Furnitures[furniture.Id].Item2;
shop.Furnitures[furniture.Id] = (furniture, prev_count + count);
}
else
{
shop.Furnitures[furniture.Id] = (furniture, count);
}
model.Furnitures = shop.Furnitures;
model.DateOpening = shop.DateOpening;
model.Address = shop.Address;
model.MaxCount = shop.MaxCount;
model.ShopName = shop.ShopName;
if (_shopStorage.Update(model) == null)
{
_logger.LogWarning("Replenishment operation failed");
return false;
}
return true;
}
private int GetCountFreePlaces(int ShopId)
{
var shop = ReadElement(new ShopSearchModel { Id = ShopId });
if (shop == null)
return 0;
int count = shop.MaxCount;
foreach (var f in shop.Furnitures)
{
count -= f.Value.Item2;
if (count <= 0)
{
return 0;
}
}
return count;
}
private int GetCountFreePlaces_All()
{
return _shopStorage.GetFullList().Select(x => GetCountFreePlaces(x.Id)).Sum();
}
public bool AddFurnituresAtShops(FurnitureBindingModel furnitureModel, int count)
{
if (GetCountFreePlaces_All() < count)
{
return false;
}
foreach (var shop in _shopStorage.GetFullList())
{
int countShop = GetCountFreePlaces(shop.Id);
if (countShop >= count)
{
AddFurniture(new() { Id = shop.Id }, furnitureModel, count);
break;
}
else
{
AddFurniture(new() { Id = shop.Id }, furnitureModel, countShop);
}
count -= countShop;
}
return true;
}
public bool Sell(FurnitureBindingModel furnitureBindingModel, int count)
{
return _shopStorage.Sell(furnitureBindingModel, count);
}
}
}

View File

@@ -0,0 +1,156 @@
using AbstractFurnitureAssemblyDataModels.Enums;
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
{
public class WorkModeling : IWorkProcess
{
private readonly ILogger _logger;
private readonly Random _rnd;
private IOrderLogic? _orderLogic;
public WorkModeling(ILogger<WorkModeling> logger)
{
_logger = logger;
_rnd = new Random(1000);
}
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic
orderLogic)
{
_orderLogic = orderLogic;
var implementers = implementerLogic.ReadList(null);
if (implementers == null)
{
_logger.LogWarning("DoWork. Implementers is null");
return;
}
var orders = _orderLogic.ReadList(new OrderSearchModel
{
Status = OrderStatus.Принят
});
if (orders == null || orders.Count == 0)
{
_logger.LogWarning("DoWork. Orders is null or empty");
return;
}
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
foreach (var implementer in implementers)
{
Task.Run(() => WorkerWorkAsync(implementer, orders));
}
}
/// <summary>
/// Иммитация работы исполнителя
/// </summary>
/// <param name="implementer"></param>
/// <param name="orders"></param>
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
{
if (_orderLogic == null || implementer == null)
{
return;
}
await Task.Run(() =>
{
foreach (var order in orders)
{
try
{
RunOrderInWork(implementer);
_logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id);
// пытаемся назначить заказ на исполнителя
_orderLogic.TakeOrderInWork(new OrderBindingModel
{
Id = order.Id,
ImplementerId = implementer.Id
});
// делаем работу
Thread.Sleep(implementer.WorkExperience * _rnd.Next(50,
1000) * order.Count);
_logger.LogDebug("DoWork. Worker {Id} finish order{ Order} ", implementer.Id, order.Id);
_orderLogic.FinishOrder(new OrderBindingModel
{
Id = order.Id,
ImplementerId = implementer.Id
});
// отдыхаем
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
// кто-то мог уже перехватить заказ, игнорируем ошибку
catch (InvalidOperationException ex)
{
_logger.LogWarning(ex, "Error try get work");
}
// заканчиваем выполнение имитации в случае иной ошибки
catch (Exception ex)
{
_logger.LogError(ex, "Error while do work");
throw;
}
}
});
}
/// <summary>
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
/// </summary>
/// <param name="implementer"></param>
/// <returns></returns>
private async Task RunOrderInWork(ImplementerViewModel implementer)
{
if (_orderLogic == null || implementer == null)
{
return;
}
try
{
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
{
ImplementerId = implementer.Id,
Status = OrderStatus.Выполняется
}));
if (runOrder == null)
{
return;
}
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}",
implementer.Id, runOrder.Id);
// доделываем работу
Thread.Sleep(implementer.WorkExperience * _rnd.Next(50, 300) *
runOrder.Count);
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}",
implementer.Id, runOrder.Id);
_orderLogic.FinishOrder(new OrderBindingModel
{
Id = runOrder.Id,
ImplementerId = implementer.Id
});
// отдыхаем
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
// заказа может не быть, просто игнорируем ошибку
catch (InvalidOperationException ex)
{
_logger.LogWarning(ex, "Error try get work");
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while do work");
throw;
}
}
}
}

View File

@@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
<PackageReference Include="MailKit" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
</ItemGroup>

View File

@@ -30,19 +30,6 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
CellToName = "C1"
});
uint rowIndex = 2;
if (info is ExcelInfoFurnitures infoFurnitures)
{
CreateExcelCellsFurnitures(infoFurnitures, rowIndex);
}
else if (info is ExcelInfoShops infoShops)
{
CreateExcelCellsShops(infoShops, rowIndex);
}
SaveExcel(info);
}
private void CreateExcelCellsFurnitures(ExcelInfoFurnitures info, uint rowIndex)
{
foreach (var pc in info.FurnitureComponents)
{
InsertCellInWorksheet(new ExcelCellParameters
@@ -89,58 +76,8 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
});
rowIndex++;
}
SaveExcel(info);
}
private void CreateExcelCellsShops(ExcelInfoShops info, uint rowIndex)
{
foreach (var sF in info.ShopFurnitures)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = sF.ShopName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var furniture in sF.Furnitures)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = furniture.Item1,
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = furniture.Item2.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Итого",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = sF.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
}
/// <summary>
/// Создание excel-файла
/// </summary>

View File

@@ -19,26 +19,11 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
if (info is PdfInfoOrders infoOrders)
CreateParagraph(new PdfParagraph
{
CreateParagraph(new PdfParagraph
{
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateDocOrders(infoOrders);
}
else if (info is PdfInfoCountOrders countOrders)
{
CreateDocCountOrders(countOrders);
}
SavePdf(info);
}
private void CreateDocOrders(PdfInfoOrders info)
{
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
@@ -62,33 +47,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
ParagraphAlignment =
PdfParagraphAlignmentType.Right
});
}
private void CreateDocCountOrders(PdfInfoCountOrders info)
{
CreateTable(new List<string> { "3cm", "3cm", "7cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Дата заказа", "Количество заказов", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var order in info.CountOrders)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.DateCreate.ToShortDateString(), order.CountOrders.ToString(), order.TotalSumOrders.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
CreateParagraph(new PdfParagraph
{
Text = $"Итого: {info.CountOrders.Sum(x => x.TotalSumOrders)}\t",
Style = "Normal",
ParagraphAlignment =
PdfParagraphAlignmentType.Right
});
SavePdf(info);
}
/// <summary>
/// Создание doc-файла

View File

@@ -6,49 +6,6 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToWord
{
public void CreateTableDoc(WordInfo wordInfo)
{
CreateWord(wordInfo);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (wordInfo.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
WordTable wordTable = new();
if (wordInfo is WordInfoShops infoShops)
{
wordTable = CreateTableDocShops(infoShops);
}
CreateTable(wordTable);
SaveWord(wordInfo);
}
private WordTable CreateTableDocShops(WordInfoShops wordInfo)
{
var list = new List<string>();
foreach (var shop in wordInfo.Shops)
{
list.Add(shop.ShopName);
list.Add(shop.Address);
list.Add(shop.DateOpening.ToString());
}
var wordTable = new WordTable
{
Headers = new List<string> {
"Название",
"Адрес",
"Дата открытия"},
Texts = list
};
return wordTable;
}
public void CreateDoc(WordInfo info)
{
CreateWord(info);
@@ -61,23 +18,20 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
JustificationType = WordJustificationType.Center
}
});
if (info is WordInfoFurnitures infoFurnitures)
foreach (var furniture in info.Furnitures)
{
foreach (var furniture in infoFurnitures.Furnitures)
CreateParagraph(new WordParagraph
{
CreateParagraph(new WordParagraph
Texts = new List<(string, WordTextProperties)> { (furniture.FurnitureName,
new WordTextProperties { Size = "24", Bold=true}),
(" - " + furniture.Price.ToString(), new WordTextProperties { Size = "24", }) },
TextProperties = new WordTextProperties
{
Texts = new List<(string, WordTextProperties)> { (furniture.FurnitureName,
new WordTextProperties { Size = "24", Bold=true}), (" - " + furniture.Price.ToString(),
new WordTextProperties { Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
SaveWord(info);
}
@@ -86,7 +40,6 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
/// </summary>
/// <param name="info"></param>
protected abstract void CreateWord(WordInfo info);
protected abstract void CreateTable(WordTable info);
/// <summary>
/// Создание абзаца с текстом
/// </summary>

View File

@@ -1,19 +0,0 @@
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfoFurnitures : ExcelInfo
{
public List<ReportFurnitureComponentViewModel> FurnitureComponents
{
get;
set;
} = new();
}
}

View File

@@ -1,19 +0,0 @@
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfoShops : ExcelInfo
{
public List<ReportShopFurnituresViewModel> ShopFurnitures
{
get;
set;
} = new();
}
}

View File

@@ -1,15 +0,0 @@
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
{
public class PdfInfoCountOrders : PdfInfo
{
public List<ReportCountOrdersViewModel> CountOrders { get; set; } = new();
}
}

View File

@@ -1,15 +0,0 @@
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
{
public class PdfInfoOrders : PdfInfo
{
public List<ReportOrdersViewModel> Orders { get; set; } = new();
}
}

View File

@@ -1,14 +0,0 @@
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
{
public class WordInfoFurnitures : WordInfo
{
public List<FurnitureViewModel> Furnitures { get; set; } = new();
}
}

View File

@@ -1,14 +0,0 @@
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
{
public class WordInfoShops : WordInfo
{
public List<ShopViewModel> Shops { get; set; } = new();
}
}

View File

@@ -1,12 +0,0 @@

using FurnitureAssemblyContracts.ViewModels;
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
{
public class WordTable
{
public List<string> Headers { get; set; } = new();
public List<string> Texts { get; set; } = new ();
}
}

View File

@@ -122,90 +122,5 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
_wordDocument.MainDocumentPart!.Document.Save();
_wordDocument.Close();
}
protected override void CreateTable(WordTable table)
{
if (_docBody == null || table == null)
{
return;
}
Table tab = new Table();
TableProperties props = new TableProperties(
new TableBorders(
new TopBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new BottomBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new LeftBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new RightBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideHorizontalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideVerticalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
}
)
);
tab.AppendChild<TableProperties>(props);
// разметка сетки таблицы
TableGrid tableGrid = new TableGrid();
for (int i = 0; i < table.Headers.Count; i++)
{
tableGrid.AppendChild(new GridColumn());
}
tab.AppendChild(tableGrid);
TableRow tableRow = new TableRow();
// заполнение заголовков
foreach (var text in table.Headers)
{
tableRow.AppendChild(CreateTableCell(text));
}
tab.AppendChild(tableRow);
// заполнение содержимым
int height = table.Texts.Count / table.Headers.Count;
int width = table.Headers.Count;
for (int i = 0; i < height; i++)
{
tableRow = new TableRow();
for (int j = 0; j < width; j++)
{
var element = table.Texts[i * table.Headers.Count + j];
tableRow.AppendChild(CreateTableCell(element));
}
tab.AppendChild(tableRow);
}
_docBody.AppendChild(tab);
}
private TableCell CreateTableCell(string element)
{
var tableParagraph = new Paragraph();
var run = new Run();
run.AppendChild(new Text { Text = element });
tableParagraph.AppendChild(run);
var tableCell = new TableCell();
tableCell.AppendChild(tableParagraph);
return tableCell;
}
}
}

View File

@@ -145,5 +145,15 @@ namespace FurnitureAssemblyClientApp.Controllers
);
return count * (prod?.Price ?? 1);
}
[HttpGet]
public IActionResult Mails()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={ APIClient.Client.Id}"));
}
}
}

View File

@@ -0,0 +1,43 @@
@using FurnitureAssemblyContracts.ViewModels
@model List<MessageInfoViewModel>
@{
ViewData["Title"] = "Mails";
}
<div class="text-center">
<h1 class="display-4">Заказы</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<table class="table">
<thead>
<tr>
<th>Дата письма</th>
<th>Заголовок</th>
<th>Текст</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem =>
item.DateDelivery)
</td>
<td>
@Html.DisplayFor(modelItem => item.Subject)
</td>
<td>
@Html.DisplayFor(modelItem =>item.Body)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@@ -26,6 +26,9 @@
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Mails">Письма</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>

View File

@@ -10,7 +10,7 @@ namespace FurnitureAssemblyContracts.BindingModels
public class FurnitureBindingModel : IFurnitureModel
{
public int Id { get; set; }
public string FurnitureName { get; set; } = string.Empty;
public string FurnitureName { get; set; } //= string.Empty;
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> FurnitureComponents {get; set;} = new();
}

View File

@@ -0,0 +1,21 @@
using FurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BindingModels
{
public class ImplementerBindingModel : IImplementerModel
{
public int Id { get; set; }
public string ImplementerFIO { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public int WorkExperience { get; set; }
public int Qualification { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BindingModels
{
public class MailConfigBindingModel
{
public string MailLogin { get; set; } = string.Empty;
public string MailPassword { get; set; } = string.Empty;
public string SmtpClientHost { get; set; } = string.Empty;
public int SmtpClientPort { get; set; }
public string PopHost { get; set; } = string.Empty;
public int PopPort { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BindingModels
{
public class MailSendInfoBindingModel
{
public string MailAddress { get; set; } = string.Empty;
public string Subject { get; set; } = string.Empty;
public string Text { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,24 @@
using FurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BindingModels
{
public class MessageInfoBindingModel : IMessageInfoModel
{
public string MessageId { get; set; } = string.Empty;
public int? ClientId { get; set; }
public string SenderName { get; set; } = string.Empty;
public DateTime DateDelivery { get; set; }
public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
}
}

View File

@@ -18,5 +18,6 @@ namespace FurnitureAssemblyContracts.BindingModels
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; } = null;
public int ClientId { get; set; }
public int? ImplementerId { get; set; }
}
}

View File

@@ -1,25 +0,0 @@
using AbstractFurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BindingModels
{
public class ShopBindingModel : IShopModel
{
public int Id { get; set; }
public string ShopName { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public DateTime DateOpening { get; set; }
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
public int MaxCount { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{
public interface IImplementerLogic
{
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
bool Create(ImplementerBindingModel model);
bool Update(ImplementerBindingModel model);
bool Delete(ImplementerBindingModel model);
}
}

View File

@@ -0,0 +1,17 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{
public interface IMessageInfoLogic
{
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
bool Create(MessageInfoBindingModel model);
}
}

View File

@@ -12,6 +12,7 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
public interface IOrderLogic
{
List<OrderViewModel>? ReadList(OrderSearchModel? model);
OrderViewModel? ReadElement(OrderSearchModel? model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);

View File

@@ -31,15 +31,5 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
/// </summary>
/// <param name="model"></param>
void SaveOrdersToPdfFile(ReportBindingModel model);
void SaveShopsToWordFile(ReportBindingModel model);
void SaveShopFurnituresToExcelFile(ReportBindingModel model);
List<ReportShopFurnituresViewModel> GetShopFurnitures();
/// <summary>
/// Получение объединенных по дате заказов за определенный период
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
List<ReportCountOrdersViewModel> GetCountOrders();
void SaveCountOrdersToPdfFile(ReportBindingModel model);
}
}

View File

@@ -1,23 +0,0 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{
public interface IShopLogic
{
List<ShopViewModel>? ReadList(ShopSearchModel? model);
ShopViewModel? ReadElement(ShopSearchModel model);
bool Create(ShopBindingModel model);
bool Update(ShopBindingModel model);
bool Delete(ShopBindingModel model);
bool AddFurniture(ShopBindingModel model, FurnitureBindingModel furnitureModel, int count);
bool AddFurnituresAtShops(FurnitureBindingModel furnitureModel, int count);
bool Sell(FurnitureBindingModel furnitureModel, int count);
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{
public interface IWorkProcess
{
/// <summary>
/// Запуск работ
/// </summary>
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
}
}

View File

@@ -6,9 +6,10 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.SearchModels
{
public class ShopSearchModel
public class ImplementerSearchModel
{
public int? Id { get; set; }
public string? ShopName { get; set; }
public string? ImplementerFIO { get; set; }
public string? Password { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.SearchModels
{
public class MessageInfoSearchModel
{
public int? ClientId { get; set; }
public string? MessageId { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using System;
using AbstractFurnitureAssemblyDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -12,5 +13,7 @@ namespace FurnitureAssemblyContracts.SearchModels
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public int? ClientId { get; set; }
public OrderStatus? Status { get; set; }
public int? ImplementerId { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.StoragesContracts
{
public interface IImplementerStorage
{
List<ImplementerViewModel> GetFullList();
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
ImplementerViewModel? GetElement(ImplementerSearchModel model);
ImplementerViewModel? Insert(ImplementerBindingModel model);
ImplementerViewModel? Update(ImplementerBindingModel model);
ImplementerViewModel? Delete(ImplementerBindingModel model);
}
}

View File

@@ -0,0 +1,19 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.StoragesContracts
{
public interface IMessageInfoStorage
{
List<MessageInfoViewModel> GetFullList();
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
}
}

View File

@@ -1,18 +0,0 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.ViewModels;
namespace FurnitureAssemblyContracts.StoragesContracts
{
public interface IShopStorage
{
List<ShopViewModel> GetFullList();
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
ShopViewModel? GetElement(ShopSearchModel model);
ShopViewModel? Insert(ShopBindingModel model);
ShopViewModel? Update(ShopBindingModel model);
ShopViewModel? Delete(ShopBindingModel model);
bool Sell(FurnitureBindingModel furnitureBindingModel, int count);
}
}

View File

@@ -1,15 +0,0 @@
using AbstractFurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels
{
public class FurnitureCountViewModel
{
public string furniture { get; set; }
public int Count { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using FurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels
{
public class ImplementerViewModel : IImplementerModel
{
public int Id { get; set; }
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
[DisplayName("Опыт работы")]
public int WorkExperience { get; set; }
[DisplayName("Квалификация")]
public int Qualification { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using FurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels
{
public class MessageInfoViewModel : IMessageInfoModel
{
public string MessageId { get; set; } = string.Empty;
public int? ClientId { get; set; }
[DisplayName("Отправитель")]
public string SenderName { get; set; } = string.Empty;
[DisplayName("Дата письма")]
public DateTime DateDelivery { get; set; }
[DisplayName("Заголовок")]
public string Subject { get; set; } = string.Empty;
[DisplayName("Текст")]
public string Body { get; set; } = string.Empty;
}
}

View File

@@ -30,5 +30,8 @@ namespace FurnitureAssemblyContracts.ViewModels
public int ClientId { get; set; }
[DisplayName("Клиент")]
public string ClientFIO { get; set; } = string.Empty;
public int? ImplementerId { get; set; }
[DisplayName("Исполнитель")]
public string? ImplementerFIO { get; set; } = string.Empty;
}
}

View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels
{
public class ReportCountOrdersViewModel
{
public DateTime DateCreate { get; set; }
public int CountOrders { get; set; }
public double TotalSumOrders { get; set; }
}
}

View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels
{
public class ReportShopFurnituresViewModel
{
public string ShopName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Furnitures { get; set; } = new();
}
}

View File

@@ -1,26 +0,0 @@
using AbstractFurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels
{
public class ShopViewModel : IShopModel
{
public int Id { get; set; }
[DisplayName("Название магазина")]
public string ShopName { get; set; } = string.Empty;
[DisplayName("Адрес магазина")]
public string Address { get; set; } = string.Empty;
[DisplayName("Дата открытия")]
public DateTime DateOpening { get; set; }
[DisplayName("Вместимость")]
public int MaxCount { get; set; }
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
public List<FurnitureCountViewModel>? FurnituresCount { get; set; } = new();
}
}

View File

@@ -14,7 +14,7 @@ namespace FurnitureAssemblyDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-T89D4FU;Encrypt=False;Integrated Security=True;User ID=DESKTOP-T89D4FU\Alena; Initial Catalog=FurnitureAssemblyHardDatabase;");
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-T89D4FU;Encrypt=False;Integrated Security=True;User ID=DESKTOP-T89D4FU\Alena; Initial Catalog=FurnitureAssemblyDatabase;");
}
base.OnConfiguring(optionsBuilder);
}
@@ -26,8 +26,9 @@ namespace FurnitureAssemblyDatabaseImplement
public virtual DbSet<FurnitureComponent> FurnitureComponents { set; get; }
public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Shop> Shops { set; get; }
public virtual DbSet<ShopFurniture> ShopFurniture { set; get; }
public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<Implementer> Implementers { set; get; }
public virtual DbSet<MessageInfo> Messages { set; get; }
}
}

View File

@@ -13,102 +13,99 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyDatabaseImplement.Implements
{
public class FurnitureStorage : IFurnitureStorage
{
public List<FurnitureViewModel> GetFullList()
{
using var context = new FurnitureAssemblyDatabase();
return context.Furnitures
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
{
public List<FurnitureViewModel> GetFullList()
{
using var context = new FurnitureAssemblyDatabase();
return context.Furnitures
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
{
if (string.IsNullOrEmpty(model.FurnitureName))
{
return new();
}
using var context = new FurnitureAssemblyDatabase();
return context.Furnitures
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.Where(x => x.FurnitureName.Contains(model.FurnitureName))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
{
if (string.IsNullOrEmpty(model.FurnitureName))
{
return new();
}
using var context = new FurnitureAssemblyDatabase();
return context.Furnitures
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.Where(x => x.FurnitureName.Contains(model.FurnitureName))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
{
if (string.IsNullOrEmpty(model.FurnitureName) &&
!model.Id.HasValue)
{
return null;
}
using var context = new FurnitureAssemblyDatabase();
return context.Furnitures
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FurnitureName) &&
x.FurnitureName == model.FurnitureName) ||
(model.Id.HasValue && x.Id ==
model.Id))
?.GetViewModel;
}
public FurnitureViewModel? Insert(FurnitureBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var newProduct = Furniture.Create(context, model);
if (newProduct == null)
{
return null;
}
context.Furnitures.Add(newProduct);
context.SaveChanges();
return newProduct.GetViewModel;
}
public FurnitureViewModel? Update(FurnitureBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var product = context.Furnitures.FirstOrDefault(rec =>
rec.Id == model.Id);
if (product == null)
{
return null;
}
product.Update(model);
context.SaveChanges();
product.UpdateComponents(context, model);
transaction.Commit();
return product.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public FurnitureViewModel? Delete(FurnitureBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var element = context.Furnitures.Include(x => x.Components)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Furnitures.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
{
if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue)
{
return null;
}
using var context = new FurnitureAssemblyDatabase();
return context.Furnitures
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FurnitureName) && x.FurnitureName == model.FurnitureName) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public FurnitureViewModel? Insert(FurnitureBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var newFurniture = Furniture.Create(context, model);
if (newFurniture == null)
{
return null;
}
context.Furnitures.Add(newFurniture);
context.SaveChanges();
return newFurniture.GetViewModel;
}
public FurnitureViewModel? Update(FurnitureBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var Furniture = context.Furnitures.FirstOrDefault(rec => rec.Id == model.Id);
if (Furniture == null)
{
return null;
}
Furniture.Update(model);
context.SaveChanges();
Furniture.UpdateComponents(context, model);
transaction.Commit();
return Furniture.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
public FurnitureViewModel? Delete(FurnitureBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var element = context.Furnitures
.Include(x => x.Components)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Furnitures.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@@ -0,0 +1,101 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyDatabaseImplement.Implements
{
public class ImplementerStorage : IImplementerStorage
{
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
{
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue && string.IsNullOrEmpty(model.Password))
{
return null;
}
using var context = new FurnitureAssemblyDatabase();
if (model.Id.HasValue)
{
return context.Implementers
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
}
if (model.ImplementerFIO != null && model.Password != null)
{
return context.Implementers
.FirstOrDefault(x =>
x.ImplementerFIO.Equals(model.ImplementerFIO) && x.Password.Equals(model.Password))
?.GetViewModel;
}
return context.Implementers
.FirstOrDefault(x =>
x.ImplementerFIO.Equals(model.ImplementerFIO))
?.GetViewModel;
}
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
{
if (string.IsNullOrEmpty(model.ImplementerFIO))
{
return new();
}
using var context = new FurnitureAssemblyDatabase();
return context.Implementers
.Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO))
.Select(x => x.GetViewModel)
.ToList();
}
public List<ImplementerViewModel> GetFullList()
{
using var context = new FurnitureAssemblyDatabase();
return context.Implementers
.Select(x => x.GetViewModel)
.ToList();
}
public ImplementerViewModel? Insert(ImplementerBindingModel model)
{
var newImplementer = Implementer.Create(model);
if (newImplementer == null)
{
return null;
}
using var context = new FurnitureAssemblyDatabase();
context.Implementers.Add(newImplementer);
context.SaveChanges();
return newImplementer.GetViewModel;
}
public ImplementerViewModel? Update(ImplementerBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var client = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
if (client == null)
{
return null;
}
client.Update(model);
context.SaveChanges();
return client.GetViewModel;
}
public ImplementerViewModel? Delete(ImplementerBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var element = context.Implementers.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Implementers.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@@ -0,0 +1,62 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyDatabaseImplement.Implements
{
public class MessageInfoStorage : IMessageInfoStorage
{
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
{
if (model.MessageId == null)
{
return null;
}
using var context = new FurnitureAssemblyDatabase();
return context.Messages.FirstOrDefault(x => x.MessageId.Equals(model.MessageId))?.GetViewModel;
}
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
{
if (!model.ClientId.HasValue)
{
return new();
}
using var context = new FurnitureAssemblyDatabase();
return context.Messages
.Where(x => x.ClientId == (model.ClientId))
.Select(x => x.GetViewModel)
.ToList();
}
public List<MessageInfoViewModel> GetFullList()
{
using var context = new FurnitureAssemblyDatabase();
return context.Messages
.Select(x => x.GetViewModel)
.ToList();
}
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
{
var newMessage = MessageInfo.Create(model);
if (newMessage == null)
{
return null;
}
using var context = new FurnitureAssemblyDatabase();
context.Messages.Add(newMessage);
context.SaveChanges();
return newMessage.GetViewModel;
}
}
}

View File

@@ -15,36 +15,30 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
public class OrderStorage : IOrderStorage
{
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
if (order != null)
{
context.Orders.Remove(order);
context.SaveChanges();
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
}
return null;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
{
return new();
}
using var context = new FurnitureAssemblyDatabase();
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
if (model.Id.HasValue)
{
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
return context.Orders
.Include(x => x.Furniture)
.Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x => x.ImplementerId.Equals(model.ImplementerId) && x.Status.Equals(model.Status))
?.GetViewModel;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue && !model.Status.HasValue)
{
return new();
}
@@ -52,7 +46,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
if (model.Id.HasValue)
{
return context.Orders
.Include(x => x.Furniture)
.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
@@ -61,7 +55,12 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
return context.Orders
.Include(x => x.Furniture)
.Include(x => x.Client)
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || model.ClientId == x.ClientId)
.Include(x => x.Implementer)
.Where(x => !(
(((model.DateFrom.HasValue) && (model.DateTo.HasValue)) && !(model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|| (model.ClientId.HasValue && !x.ClientId.Equals(model.ClientId))
|| (model.Status.HasValue && !x.Status.Equals(model.Status))))
)
.Select(x => x.GetViewModel)
.ToList();
}
@@ -72,6 +71,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
return context.Orders
.Include(x => x.Furniture)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Select(x => x.GetViewModel)
.ToList();
}
@@ -86,9 +86,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
}
context.Orders.Add(newOrder);
context.SaveChanges();
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
@@ -101,8 +99,20 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
}
order.Update(model);
context.SaveChanges();
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
}
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
if (order != null)
{
context.Orders.Remove(order);
context.SaveChanges();
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
}
return null;
}
}
}

View File

@@ -1,178 +0,0 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.SearchModels;
using FurnitureAssemblyContracts.StoragesContracts;
using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyDatabaseImplement.Implements
{
public class ShopStorage : IShopStorage
{
public ShopViewModel? GetElement(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName) &&
!model.Id.HasValue)
{
return null;
}
using var context = new FurnitureAssemblyDatabase();
return context.Shops
.Include(x => x.ShopFurnitures)
.ThenInclude(x => x.Furniture)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) &&
x.ShopName == model.ShopName) ||
(model.Id.HasValue && x.Id ==
model.Id))
?.GetViewModel;
}
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName))
{
return new();
}
using var context = new FurnitureAssemblyDatabase();
return context.Shops
.Include(x => x.ShopFurnitures)
.ThenInclude(x => x.Furniture)
.Where(x => x.ShopName.Contains(model.ShopName))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<ShopViewModel> GetFullList()
{
using var context = new FurnitureAssemblyDatabase();
return context.Shops
.Include(x => x.ShopFurnitures)
.ThenInclude(x => x.Furniture)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public ShopViewModel? Delete(ShopBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
var element = context.Shops.Include(x => x.ShopFurnitures).FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Shops.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public ShopViewModel? Insert(ShopBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var newShop = Shop.Create(context, model);
if (newShop == null)
{
return null;
}
if (GetElement(new ShopSearchModel { ShopName = newShop.ShopName }) != null)
{
throw new Exception("Магазин с таким названием уже есть");
}
context.Shops.Add(newShop);
context.SaveChanges();
transaction.Commit();
return newShop.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public bool Sell(FurnitureBindingModel furniture, int count)
{
using var context = new FurnitureAssemblyDatabase();
using var transaction = context.Database.BeginTransaction();
foreach (var shop in context.Shops.Include(x => x.ShopFurnitures).ThenInclude(x => x.Furniture).ToList())
{
if (shop.Furnitures.ContainsKey(furniture.Id))
{
if (shop.Furnitures[furniture.Id].Item2 >= count)
{
shop.Furnitures[furniture.Id] = (shop.Furnitures[furniture.Id].Item1, shop.Furnitures[furniture.Id].Item2 - count);
count = 0;
}
else
{
count -= shop.Furnitures[furniture.Id].Item2;
shop.Furnitures[furniture.Id] = (shop.Furnitures[furniture.Id].Item1, 0);
}
var model = new ShopBindingModel
{
Id = shop.Id,
ShopName = shop.ShopName,
MaxCount = shop.MaxCount,
Furnitures = shop.Furnitures,
Address = shop.Address,
DateOpening = shop.DateOpening
};
shop.Update(model);
shop.UpdateFurnitures(context, model);
if (count == 0)
break;
}
}
if (count == 0)
{
context.SaveChanges();
transaction.Commit();
return true;
}
else
{
transaction.Rollback();
return false;
}
}
public ShopViewModel? Update(ShopBindingModel model)
{
using var context = new FurnitureAssemblyDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var shop = context.Shops.FirstOrDefault(rec =>
rec.Id == model.Id);
if (shop == null)
{
return null;
}
shop.Update(model);
if (model.Furnitures.Count > 0)
{
shop.UpdateFurnitures(context, model);
}
context.SaveChanges();
transaction.Commit();
return shop.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@@ -0,0 +1,156 @@
// <auto-generated />
using System;
using FurnitureAssemblyDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FurnitureAssemblyDatabaseImplement.Migrations
{
[DbContext(typeof(FurnitureAssemblyDatabase))]
[Migration("20230226121415_InitMigration")]
partial class InitMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FurnitureName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Furnitures");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Counts")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("ProductId");
b.ToTable("FurnitureComponents");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Orders");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
{
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Component", "Component")
.WithMany("FurnitureComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
.WithMany("Components")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Furniture");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
{
b.Navigation("FurnitureComponents");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
{
b.Navigation("Components");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,114 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FurnitureAssemblyDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Components",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cost = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Components", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Furnitures",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FurnitureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Furnitures", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
});
migrationBuilder.CreateTable(
name: "FurnitureComponents",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductId = table.Column<int>(type: "int", nullable: false),
ComponentId = table.Column<int>(type: "int", nullable: false),
Counts = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FurnitureComponents", x => x.Id);
table.ForeignKey(
name: "FK_FurnitureComponents_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_FurnitureComponents_Furnitures_ProductId",
column: x => x.ProductId,
principalTable: "Furnitures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_FurnitureComponents_ComponentId",
table: "FurnitureComponents",
column: "ComponentId");
migrationBuilder.CreateIndex(
name: "IX_FurnitureComponents_ProductId",
table: "FurnitureComponents",
column: "ProductId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "FurnitureComponents");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Components");
migrationBuilder.DropTable(
name: "Furnitures");
}
}
}

View File

@@ -0,0 +1,157 @@
// <auto-generated />
using System;
using FurnitureAssemblyDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FurnitureAssemblyDatabaseImplement.Migrations
{
[DbContext(typeof(FurnitureAssemblyDatabase))]
[Migration("20230226124904_OrderAddMigration")]
partial class OrderAddMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FurnitureName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Furnitures");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Counts")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("ProductId");
b.ToTable("FurnitureComponents");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.IsRequired()
.HasColumnType("datetime2");
b.Property<int>("FurnitureId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Orders");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
{
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Component", "Component")
.WithMany("FurnitureComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
.WithMany("Components")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Furniture");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
{
b.Navigation("FurnitureComponents");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
{
b.Navigation("Components");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FurnitureAssemblyDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class OrderAddMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "ProductId",
table: "Orders",
newName: "FurnitureId");
migrationBuilder.AlterColumn<DateTime>(
name: "DateImplement",
table: "Orders",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "FurnitureId",
table: "Orders",
newName: "ProductId");
migrationBuilder.AlterColumn<DateTime>(
name: "DateImplement",
table: "Orders",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
}
}
}

View File

@@ -0,0 +1,157 @@
// <auto-generated />
using System;
using FurnitureAssemblyDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FurnitureAssemblyDatabaseImplement.Migrations
{
[DbContext(typeof(FurnitureAssemblyDatabase))]
[Migration("20230226125233_OrderFKAddMigration")]
partial class OrderFKAddMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FurnitureName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Furnitures");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Counts")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("ProductId");
b.ToTable("FurnitureComponents");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.IsRequired()
.HasColumnType("datetime2");
b.Property<int>("FurnitureId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Orders");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
{
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Component", "Component")
.WithMany("FurnitureComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
.WithMany("Components")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Furniture");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
{
b.Navigation("FurnitureComponents");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
{
b.Navigation("Components");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FurnitureAssemblyDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class OrderFKAddMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FurnitureId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Order_Furniture_FurnitureId",
column: x => x.FurnitureId,
principalTable: "Furnitures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Orders");
}
}
}

View File

@@ -0,0 +1,160 @@
// <auto-generated />
using System;
using FurnitureAssemblyDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FurnitureAssemblyDatabaseImplement.Migrations
{
[DbContext(typeof(FurnitureAssemblyDatabase))]
[Migration("20230226140340_OrderNameFurnitureAddMigration")]
partial class OrderNameFurnitureAddMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FurnitureName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Furnitures");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Counts")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("ProductId");
b.ToTable("FurnitureComponents");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("FurnitureId")
.HasColumnType("int");
b.Property<string>("FurnitureName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Orders");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
{
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Component", "Component")
.WithMany("FurnitureComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
.WithMany("Components")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Furniture");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
{
b.Navigation("FurnitureComponents");
});
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
{
b.Navigation("Components");
});
#pragma warning restore 612, 618
}
}
}

Some files were not shown because too many files have changed in this diff Show More