Я устал босс
This commit is contained in:
parent
43c34e351b
commit
dfe49b519d
BIN
SushiBar/ImplementationExtensions/SushiBarContracts.dll
Normal file
BIN
SushiBar/ImplementationExtensions/SushiBarContracts.dll
Normal file
Binary file not shown.
BIN
SushiBar/ImplementationExtensions/SushiBarDataModels.dll
Normal file
BIN
SushiBar/ImplementationExtensions/SushiBarDataModels.dll
Normal file
Binary file not shown.
BIN
SushiBar/ImplementationExtensions/SushiBarDatabaseImplement.dll
Normal file
BIN
SushiBar/ImplementationExtensions/SushiBarDatabaseImplement.dll
Normal file
Binary file not shown.
BIN
SushiBar/ImplementationExtensions/SushiBarFileImplement.dll
Normal file
BIN
SushiBar/ImplementationExtensions/SushiBarFileImplement.dll
Normal file
Binary file not shown.
BIN
SushiBar/ImplementationExtensions/SushiBarListImplement.dll
Normal file
BIN
SushiBar/ImplementationExtensions/SushiBarListImplement.dll
Normal file
Binary file not shown.
46
SushiBar/SushiBar/DataGridViewExtension.cs
Normal file
46
SushiBar/SushiBar/DataGridViewExtension.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using SushiBarContracts.Attributes;
|
||||||
|
|
||||||
|
namespace SushiBarView
|
||||||
|
{
|
||||||
|
internal static class DataGridViewExtension
|
||||||
|
{
|
||||||
|
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data)
|
||||||
|
{
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
grid.DataSource = data;
|
||||||
|
|
||||||
|
var type = typeof(T);
|
||||||
|
var properties = type.GetProperties();
|
||||||
|
foreach (DataGridViewColumn column in grid.Columns)
|
||||||
|
{
|
||||||
|
var property = properties.FirstOrDefault(x => x.Name == column.Name);
|
||||||
|
if (property == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}");
|
||||||
|
}
|
||||||
|
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
|
||||||
|
if (attribute == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}");
|
||||||
|
}
|
||||||
|
// ищем нужный нам атрибут
|
||||||
|
if (attribute is ColumnAttribute columnAttr)
|
||||||
|
{
|
||||||
|
column.HeaderText = columnAttr.Title;
|
||||||
|
column.Visible = columnAttr.Visible;
|
||||||
|
if (columnAttr.IsUseAutoSize)
|
||||||
|
{
|
||||||
|
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
column.Width = columnAttr.Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,13 +27,7 @@ namespace SushiBarView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
|
||||||
namespace SushiBarView
|
namespace SushiBarView
|
||||||
{
|
{
|
||||||
@ -20,14 +21,7 @@ namespace SushiBarView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка исполнителей");
|
_logger.LogInformation("Загрузка исполнителей");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -45,13 +39,10 @@ namespace SushiBarView
|
|||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var form = DependencyManager.Instance.Resolve<FormIngredient>();
|
||||||
if (service is FormImplementer form)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
LoadData();
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,14 +50,11 @@ namespace SushiBarView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var form = DependencyManager.Instance.Resolve<FormIngredient>();
|
||||||
if (service is FormImplementer form)
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
LoadData();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
|
||||||
namespace SushiBarView
|
namespace SushiBarView
|
||||||
{
|
{
|
||||||
@ -40,27 +41,21 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredient));
|
var form = DependencyManager.Instance.Resolve<FormIngredient>();
|
||||||
if (service is FormIngredient form)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
LoadData();
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredient));
|
var form = DependencyManager.Instance.Resolve<FormIngredient>();
|
||||||
if (service is FormIngredient form)
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
LoadData();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
|
||||||
namespace SushiBarView
|
namespace SushiBarView
|
||||||
{
|
{
|
||||||
@ -42,13 +43,10 @@ namespace SushiBarView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
|
var form = DependencyManager.Instance.Resolve<FormSushi>();
|
||||||
if (service is FormSushi form)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
LoadData();
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,14 +54,11 @@ namespace SushiBarView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
|
var form = DependencyManager.Instance.Resolve<FormSushi>();
|
||||||
if (service is FormSushi form)
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
LoadData();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
SushiBar/SushiBar/FormMain.Designer.cs
generated
33
SushiBar/SushiBar/FormMain.Designer.cs
generated
@ -39,20 +39,21 @@
|
|||||||
списокСушиToolStripMenuItem = new ToolStripMenuItem();
|
списокСушиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
сушиСИнгредиентамиToolStripMenuItem = new ToolStripMenuItem();
|
сушиСИнгредиентамиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
письмаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
buttonUpdate = new Button();
|
buttonUpdate = new Button();
|
||||||
buttonSetToFinish = new Button();
|
buttonSetToFinish = new Button();
|
||||||
buttonSetToDone = new Button();
|
buttonSetToDone = new Button();
|
||||||
buttonSetToWork = new Button();
|
buttonSetToWork = new Button();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
письмаToolStripMenuItem = new ToolStripMenuItem();
|
создатьБекапToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, создатьБекапToolStripMenuItem });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(1112, 24);
|
menuStrip.Size = new Size(1112, 24);
|
||||||
@ -69,35 +70,35 @@
|
|||||||
// ингредиентыToolStripMenuItem
|
// ингредиентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
ингредиентыToolStripMenuItem.Name = "ингредиентыToolStripMenuItem";
|
ингредиентыToolStripMenuItem.Name = "ингредиентыToolStripMenuItem";
|
||||||
ингредиентыToolStripMenuItem.Size = new Size(154, 22);
|
ингредиентыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
ингредиентыToolStripMenuItem.Text = "Ингредиенты";
|
ингредиентыToolStripMenuItem.Text = "Ингредиенты";
|
||||||
ингредиентыToolStripMenuItem.Click += IngredientsToolStripMenuItem_Click;
|
ингредиентыToolStripMenuItem.Click += IngredientsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// сушиToolStripMenuItem
|
// сушиToolStripMenuItem
|
||||||
//
|
//
|
||||||
сушиToolStripMenuItem.Name = "сушиToolStripMenuItem";
|
сушиToolStripMenuItem.Name = "сушиToolStripMenuItem";
|
||||||
сушиToolStripMenuItem.Size = new Size(154, 22);
|
сушиToolStripMenuItem.Size = new Size(180, 22);
|
||||||
сушиToolStripMenuItem.Text = "Суши";
|
сушиToolStripMenuItem.Text = "Суши";
|
||||||
сушиToolStripMenuItem.Click += SushiToolStripMenuItem_Click;
|
сушиToolStripMenuItem.Click += SushiToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// клиентыToolStripMenuItem
|
// клиентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||||
клиентыToolStripMenuItem.Size = new Size(154, 22);
|
клиентыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// исполнителиToolStripMenuItem
|
// исполнителиToolStripMenuItem
|
||||||
//
|
//
|
||||||
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||||
исполнителиToolStripMenuItem.Size = new Size(154, 22);
|
исполнителиToolStripMenuItem.Size = new Size(180, 22);
|
||||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||||
исполнителиToolStripMenuItem.Click += employersToolStripMenuItem_Click;
|
исполнителиToolStripMenuItem.Click += employersToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// начатьРаботуToolStripMenuItem
|
// начатьРаботуToolStripMenuItem
|
||||||
//
|
//
|
||||||
начатьРаботуToolStripMenuItem.Name = "начатьРаботуToolStripMenuItem";
|
начатьРаботуToolStripMenuItem.Name = "начатьРаботуToolStripMenuItem";
|
||||||
начатьРаботуToolStripMenuItem.Size = new Size(154, 22);
|
начатьРаботуToolStripMenuItem.Size = new Size(180, 22);
|
||||||
начатьРаботуToolStripMenuItem.Text = "Начать работу";
|
начатьРаботуToolStripMenuItem.Text = "Начать работу";
|
||||||
начатьРаботуToolStripMenuItem.Click += startWorkToolStripMenuItem_Click;
|
начатьРаботуToolStripMenuItem.Click += startWorkToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -129,6 +130,13 @@
|
|||||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||||
списокЗаказовToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
списокЗаказовToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// письмаToolStripMenuItem
|
||||||
|
//
|
||||||
|
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
||||||
|
письмаToolStripMenuItem.Size = new Size(203, 22);
|
||||||
|
письмаToolStripMenuItem.Text = "Письма";
|
||||||
|
письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
@ -201,12 +209,12 @@
|
|||||||
dataGridView.Size = new Size(919, 426);
|
dataGridView.Size = new Size(919, 426);
|
||||||
dataGridView.TabIndex = 7;
|
dataGridView.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// письмаToolStripMenuItem
|
// создатьБекапToolStripMenuItem
|
||||||
//
|
//
|
||||||
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
создатьБекапToolStripMenuItem.Name = "создатьБекапToolStripMenuItem";
|
||||||
письмаToolStripMenuItem.Size = new Size(203, 22);
|
создатьБекапToolStripMenuItem.Size = new Size(97, 20);
|
||||||
письмаToolStripMenuItem.Text = "Письма";
|
создатьБекапToolStripMenuItem.Text = "Создать бекап";
|
||||||
письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click;
|
создатьБекапToolStripMenuItem.Click += создатьБекапToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -251,5 +259,6 @@
|
|||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem начатьРаботуToolStripMenuItem;
|
private ToolStripMenuItem начатьРаботуToolStripMenuItem;
|
||||||
private ToolStripMenuItem письмаToolStripMenuItem;
|
private ToolStripMenuItem письмаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem создатьБекапToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
|
||||||
namespace SushiBarView
|
namespace SushiBarView
|
||||||
{
|
{
|
||||||
@ -10,8 +11,8 @@ namespace SushiBarView
|
|||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@ -19,6 +20,8 @@ namespace SushiBarView
|
|||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
|
LoadData();
|
||||||
}
|
}
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -29,14 +32,7 @@ namespace SushiBarView
|
|||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["SushiId"].Visible = false;
|
|
||||||
dataGridView.Columns["Implementerid"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientEmail"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -47,28 +43,19 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
private void IngredientsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void IngredientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredients));
|
var form = DependencyManager.Instance.Resolve<FormIngredients>();
|
||||||
if (service is FormIngredients form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void SushiToolStripMenuItem_Click(object sender, EventArgs e)
|
private void SushiToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormListSushi));
|
var form = DependencyManager.Instance.Resolve<FormSushi>();
|
||||||
if (service is FormListSushi form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
if (service is FormCreateOrder form)
|
form.ShowDialog();
|
||||||
{
|
LoadData();
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -152,61 +139,67 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
private void SushiListToolStripMenuItem_Click(object sender, EventArgs e)
|
private void SushiListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
var form = DependencyManager.Instance.Resolve<FormListSushi>();
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
_reportLogic.SaveListSushiToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
|
||||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SushiIngredientToolStripMenuItem_Click(object sender, EventArgs e)
|
private void SushiIngredientToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportSushiIngredients));
|
var form = DependencyManager.Instance.Resolve<FormSushiIngredients>();
|
||||||
if (service is FormReportSushiIngredients form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
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));
|
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||||
if (service is FormReportOrders form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||||
if (service is FormClients form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void employersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void employersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||||
if (service is FormImplementers form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
private void startWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
|
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormViewMail));
|
var form = DependencyManager.Instance.Resolve<FormViewMail>();
|
||||||
if (service is FormViewMail form)
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
private void создатьБекапToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
if (_backUpLogic != null)
|
||||||
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
FolderName = fbd.SelectedPath
|
||||||
|
});
|
||||||
|
MessageBox.Show("Бекап создан", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
@ -70,23 +71,25 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiIngredients));
|
var form = DependencyManager.Instance.Resolve<FormSushiIngredients>();
|
||||||
if (service is FormSushiIngredients form)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.IngredientModel == null)
|
||||||
{
|
{
|
||||||
if (form.IngredientModel == null)
|
if (form.IngredientModel == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Добавление нового ингредиента: { IngredientName} - { Count}", form.IngredientModel.IngredientName, form.Count);
|
_logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.IngredientModel.IngredientName, form.Count);
|
||||||
if (_sushiIngredients.ContainsKey(form.Id))
|
if (_sushiIngredients.ContainsKey(form.Id))
|
||||||
{
|
{
|
||||||
_sushiIngredients[form.Id] = (form.IngredientModel, form.Count);
|
_sushiIngredients[form.Id] = (form.IngredientModel,
|
||||||
|
form.Count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_sushiIngredients.Add(form.Id, (form.IngredientModel, form.Count));
|
_sushiIngredients.Add(form.Id, (form.IngredientModel,
|
||||||
|
form.Count));
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
@ -96,22 +99,19 @@ namespace SushiBarView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiIngredients));
|
var form = DependencyManager.Instance.Resolve<FormSushiIngredients>();
|
||||||
if (service is FormSushiIngredients form)
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
form.Count = _sushiIngredients[id].Item2;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
if (form.IngredientModel == null)
|
||||||
form.Id = id;
|
|
||||||
form.Count = _sushiIngredients[id].Item2;
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
if (form.IngredientModel == null)
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Изменение ингредиента: { IngredientName} - { Count} ", form.IngredientModel.IngredientName, form.Count);
|
|
||||||
_sushiIngredients[form.Id] = (form.IngredientModel, form.Count);
|
|
||||||
LoadData();
|
|
||||||
}
|
}
|
||||||
|
_logger.LogInformation("Изменение компонента:{ ComponentName}-{ Count}", form.IngredientModel.IngredientName, form.Count);
|
||||||
|
_sushiIngredients[form.Id] = (form.IngredientModel, form.Count);
|
||||||
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@ using SushiBarDatabaseImplement.Implements;
|
|||||||
using SushiBarBusinessLogic;
|
using SushiBarBusinessLogic;
|
||||||
using SushiBarBusinessLogic.MailWorker;
|
using SushiBarBusinessLogic.MailWorker;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
|
||||||
namespace SushiBarView
|
namespace SushiBarView
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static ServiceProvider? _serviceProvider;
|
|
||||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -26,76 +26,69 @@ namespace SushiBarView
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
var services = new ServiceCollection();
|
InitDependency();
|
||||||
ConfigureServices(services);
|
try
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
{
|
||||||
try
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>(); mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
{
|
{
|
||||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||||
mailSender?.MailConfig(new MailConfigBindingModel
|
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
||||||
{
|
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
||||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
||||||
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
||||||
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
||||||
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);
|
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void InitDependency()
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
DependencyManager.InitDependency();
|
||||||
|
|
||||||
|
DependencyManager.Instance.AddLogging(option =>
|
||||||
{
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
services.AddTransient<IIngredientStorage, IngredientStorage>();
|
DependencyManager.Instance.RegisterType<IIngredientLogic, IngredientLogic>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ISushiStorage, SushiStorage>();
|
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
|
||||||
services.AddTransient<IIngredientLogic, IngredientLogic>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
||||||
services.AddTransient<ISushiLogic, SushiLogic>();
|
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<FormIngredient>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<FormIngredients>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
|
||||||
services.AddTransient<FormSushi>();
|
|
||||||
services.AddTransient<FormSushiIngredients>();
|
|
||||||
services.AddTransient<FormListSushi>();
|
|
||||||
services.AddTransient<FormClients>();
|
|
||||||
services.AddTransient<FormReportSushiIngredients>();
|
|
||||||
services.AddTransient<FormReportOrders>();
|
|
||||||
services.AddTransient<FormImplementers>();
|
|
||||||
services.AddTransient<FormImplementer>();
|
|
||||||
services.AddTransient<FormViewMail>();
|
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<FormIngredient>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<FormIngredients>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
DependencyManager.Instance.RegisterType<FormListSushi>();
|
||||||
}
|
DependencyManager.Instance.RegisterType<FormSushiIngredients>();
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
DependencyManager.Instance.RegisterType<FormSushi>();
|
||||||
}
|
DependencyManager.Instance.RegisterType<FormReportSushiIngredients>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormViewMail>();
|
||||||
|
}
|
||||||
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
103
SushiBar/SushiBarBusinessLogic/BusinessLogics/BackUpLogic.cs
Normal file
103
SushiBar/SushiBarBusinessLogic/BusinessLogics/BackUpLogic.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class BackUpLogic : IBackUpLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IBackUpInfo _backUpInfo;
|
||||||
|
|
||||||
|
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_backUpInfo = backUpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateBackUp(BackUpSaveBindingModel model)
|
||||||
|
{
|
||||||
|
if (_backUpInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Clear folder");
|
||||||
|
// зачистка папки и удаление старого архива
|
||||||
|
var dirInfo = new DirectoryInfo(model.FolderName);
|
||||||
|
if (dirInfo.Exists)
|
||||||
|
{
|
||||||
|
foreach (var file in dirInfo.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Delete archive");
|
||||||
|
string fileName = $"{model.FolderName}.zip";
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
|
// берем метод для сохранения
|
||||||
|
_logger.LogDebug("Get assembly");
|
||||||
|
var typeIId = typeof(IId);
|
||||||
|
var assembly = typeIId.Assembly;
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
||||||
|
}
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
_logger.LogDebug("Find {count} types", types.Length);
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||||
|
{
|
||||||
|
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
|
// вызываем метод на выполнение
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
// архивируем
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
// удаляем папку
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToFile<T>(string folderName) where T : class, new()
|
||||||
|
{
|
||||||
|
var records = _backUpInfo.GetList<T>();
|
||||||
|
if (records == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
|
jsonFormatter.WriteObject(fs, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
31
SushiBar/SushiBarContracts/Attributes/ColumnAttribute.cs
Normal file
31
SushiBar/SushiBarContracts/Attributes/ColumnAttribute.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.Attributes
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ColumnAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Title { get; private set; }
|
||||||
|
|
||||||
|
public bool Visible { get; private set; }
|
||||||
|
|
||||||
|
public int Width { get; private set; }
|
||||||
|
|
||||||
|
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
Visible = visible;
|
||||||
|
Width = width;
|
||||||
|
GridViewAutoSize = gridViewAutoSize;
|
||||||
|
IsUseAutoSize = isUseAutoSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
SushiBar/SushiBarContracts/Attributes/GridViewAutoSize.cs
Normal file
27
SushiBar/SushiBarContracts/Attributes/GridViewAutoSize.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.Attributes
|
||||||
|
{
|
||||||
|
public enum GridViewAutoSize
|
||||||
|
{
|
||||||
|
NotSet = 0,
|
||||||
|
|
||||||
|
None = 1,
|
||||||
|
|
||||||
|
ColumnHeader = 2,
|
||||||
|
|
||||||
|
AllCellsExceptHeader = 4,
|
||||||
|
|
||||||
|
AllCells = 6,
|
||||||
|
|
||||||
|
DisplayedCellsExceptHeader = 8,
|
||||||
|
|
||||||
|
DisplayedCells = 10,
|
||||||
|
|
||||||
|
Fill = 16
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using PrecastConcretePlantDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -16,5 +16,6 @@ namespace SushiBarContracts.BindingModels
|
|||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
}
|
public int Id => throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
void CreateBackUp(BackUpSaveBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
41
SushiBar/SushiBarContracts/DI/DependencyManager.cs
Normal file
41
SushiBar/SushiBarContracts/DI/DependencyManager.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public class DependencyManager
|
||||||
|
{
|
||||||
|
private readonly IDependencyContainer _dependencyManager;
|
||||||
|
|
||||||
|
private static DependencyManager? _manager;
|
||||||
|
|
||||||
|
private static readonly object _locjObject = new();
|
||||||
|
|
||||||
|
private DependencyManager()
|
||||||
|
{
|
||||||
|
_dependencyManager = new ServiceDependencyContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
|
||||||
|
|
||||||
|
public static void InitDependency()
|
||||||
|
{
|
||||||
|
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||||
|
if (ext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
||||||
|
}
|
||||||
|
// регистрируем зависимости
|
||||||
|
ext.RegisterServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
|
||||||
|
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
|
||||||
|
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
|
||||||
|
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
20
SushiBar/SushiBarContracts/DI/IDependencyContainer.cs
Normal file
20
SushiBar/SushiBarContracts/DI/IDependencyContainer.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public interface IDependencyContainer
|
||||||
|
{
|
||||||
|
void AddLogging(Action<ILoggingBuilder> configure);
|
||||||
|
|
||||||
|
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
|
||||||
|
|
||||||
|
void RegisterType<T>(bool isSingle) where T : class;
|
||||||
|
|
||||||
|
T Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
14
SushiBar/SushiBarContracts/DI/IImplementationExtension.cs
Normal file
14
SushiBar/SushiBarContracts/DI/IImplementationExtension.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
62
SushiBar/SushiBarContracts/DI/ServiceDependencyContainer.cs
Normal file
62
SushiBar/SushiBarContracts/DI/ServiceDependencyContainer.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public class ServiceDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private ServiceProvider? _serviceProvider;
|
||||||
|
|
||||||
|
private readonly ServiceCollection _serviceCollection;
|
||||||
|
|
||||||
|
public ServiceDependencyContainer()
|
||||||
|
{
|
||||||
|
_serviceCollection = new ServiceCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddLogging(configure);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T, U>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
if (_serviceProvider == null)
|
||||||
|
{
|
||||||
|
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
return _serviceProvider.GetService<T>()!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
SushiBar/SushiBarContracts/DI/ServiceProviderLoader.cs
Normal file
51
SushiBar/SushiBarContracts/DI/ServiceProviderLoader.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public class ServiceProviderLoader
|
||||||
|
{
|
||||||
|
public static IImplementationExtension? GetImplementationExtensions()
|
||||||
|
{
|
||||||
|
IImplementationExtension? source = null;
|
||||||
|
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
|
||||||
|
foreach (var file in files.Distinct())
|
||||||
|
{
|
||||||
|
Assembly asm = Assembly.LoadFrom(file);
|
||||||
|
foreach (var t in asm.GetExportedTypes())
|
||||||
|
{
|
||||||
|
if (t.IsClass && typeof(IImplementationExtension).IsAssignableFrom(t))
|
||||||
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
source = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||||
|
if (newSource.Priority > source.Priority)
|
||||||
|
{
|
||||||
|
source = newSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string TryGetImplementationExtensionsFolder()
|
||||||
|
{
|
||||||
|
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
|
while (directory != null && !directory.GetDirectories("ImplementationExtensions", SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
|
||||||
|
{
|
||||||
|
directory = directory.Parent;
|
||||||
|
}
|
||||||
|
return $"{directory?.FullName}\\ImplementationExtensions";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
43
SushiBar/SushiBarContracts/DI/UnityDependencyContainer.cs
Normal file
43
SushiBar/SushiBarContracts/DI/UnityDependencyContainer.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Unity;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public class UnityDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public UnityDependencyContainer()
|
||||||
|
{
|
||||||
|
_container = new UnityContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
var factory = LoggerFactory.Create(configure);
|
||||||
|
_container.AddExtension(new LoggingExtension(factory));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
_container.RegisterType<T>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDependencyContainer.RegisterType<T, U>(bool isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
SushiBar/SushiBarContracts/StoragesContracts/IBackUpInfo.cs
Normal file
14
SushiBar/SushiBarContracts/StoragesContracts/IBackUpInfo.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,12 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SushiBarDataModels;
|
using SushiBarContracts.Attributes;
|
||||||
|
using SushiBarDataModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,17 +11,14 @@ namespace SushiBarContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("ФИО Клиента")]
|
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
[Column("Логин (эл. почта)", width: 150)]
|
||||||
[DisplayName("Логин (эл. почтаы)")]
|
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[Column("Пароль", width: 150)]
|
||||||
[DisplayName("Пароль")]
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarContracts.Attributes;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,18 +11,19 @@ namespace SushiBarContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[Column("Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Стаж работы")]
|
[Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[DisplayName("Квалификация")]
|
[Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarContracts.Attributes;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class IngredientViewModel : IIngredientModel
|
public class IngredientViewModel : IIngredientModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название ингредиента")]
|
[Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string IngredientName { get; set; } = string.Empty;
|
public string IngredientName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column("Цена", width: 80)]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using PrecastConcretePlantDataModels.Models;
|
using SushiBarContracts.Attributes;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -11,20 +12,23 @@ namespace SushiBarContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
public string MessageId { get; set; } = string.Empty;
|
[Column(visible: false)]
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
[Column(visible: false)]
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
public int? ClientId { get; set; }
|
[Column("Отправитель", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
|
||||||
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Отправитель")]
|
[Column("Дата письма", width: 100)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
[DisplayName("Дата письма")]
|
[Column("Заголовок", width: 150)]
|
||||||
public DateTime DateDelivery { get; set; }
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Заголовок")]
|
[Column("Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
[Column(visible: false)]
|
||||||
[DisplayName("Текст")]
|
public int Id => throw new NotImplementedException();
|
||||||
public string Body { get; set; } = string.Empty;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SushiBarDataModels.Enums;
|
using SushiBarContracts.Attributes;
|
||||||
|
using SushiBarDataModels.Enums;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
@ -6,34 +7,38 @@ namespace SushiBarContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
[DisplayName("Исполнитель")]
|
[Column("Фамилия исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string? ImplementerFIO { get; set; } = null;
|
public string? ImplementerFIO { get; set; } = null;
|
||||||
|
[Column(visible: false)]
|
||||||
public int SushiId { get; set; }
|
public int SushiId { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public string ClientEmail { get; set; } = string.Empty;
|
public string ClientEmail { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("ФИО клиента")]
|
[Column("Фамилия клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Изделие")]
|
[Column("Изделие", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public string SushiName { get; set; } = string.Empty;
|
public string SushiName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
[Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
[DisplayName("Сумма")]
|
[Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
[DisplayName("Статус")]
|
[Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
[DisplayName("Дата создания")]
|
[Column("Дата создания", width: 100)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
[DisplayName("Дата выполнения")]
|
[Column("Дата выполнения", width: 100)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,18 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarContracts.Attributes;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class SushiViewModel : ISushiModel
|
public class SushiViewModel : ISushiModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название изделия")]
|
[Column("Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string SushiName { get; set; } = string.Empty;
|
public string SushiName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column("Цена", width: 100)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (IIngredientModel, int)> SushiIngredients{ get; set; } = new();
|
public Dictionary<int, (IIngredientModel, int)> SushiIngredients{ get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,13 @@
|
|||||||
using System;
|
using SushiBarDataModels;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace PrecastConcretePlantDataModels.Models
|
namespace SushiBarDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
|
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
using SushiBarContracts.DI;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarDatabaseImplement.Models;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarDatabaseImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarDatabaseImplement
|
||||||
|
{
|
||||||
|
internal class DataBaseImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 2;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IIngredientStorage, IngredientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
31
SushiBar/SushiBarDatabaseImplement/Models/BackUpInfo.cs
Normal file
31
SushiBar/SushiBarDatabaseImplement/Models/BackUpInfo.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new SushiBarDatabase();
|
||||||
|
return context.Set<T>().ToList();
|
||||||
|
}
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,24 +3,32 @@ using SushiBarContracts.ViewModels;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using SushiBarDataModels;
|
using SushiBarDataModels;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace SushiBarDatabaseImplement.Models
|
namespace SushiBarDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; private set; } = string.Empty;
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Email { get; private set; } = string.Empty;
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[ForeignKey("ClientId")]
|
[ForeignKey("ClientId")]
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<MessageInfo> Messages { get; set; } = new();
|
||||||
|
|
||||||
public static Client? Create(ClientBindingModel? model)
|
public static Client? Create(ClientBindingModel? model)
|
||||||
{
|
{
|
||||||
|
@ -8,23 +8,30 @@ using System.Threading.Tasks;
|
|||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarDatabaseImplement.Models;
|
using SushiBarDatabaseImplement.Models;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace SushiBarDataModels.Models
|
namespace SushiBarDataModels.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ImplementerId")]
|
[ForeignKey("ImplementerId")]
|
||||||
|
@ -3,17 +3,22 @@ using SushiBarContracts.ViewModels;
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace SushiBarDatabaseImplement.Models
|
namespace SushiBarDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Ingredient : IIngredientModel
|
public class Ingredient : IIngredientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string IngredientName { get; private set; } = string.Empty;
|
public string IngredientName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
[ForeignKey("IngredientId")]
|
[ForeignKey("IngredientId")]
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
using PrecastConcretePlantDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
|
||||||
namespace SushiBarDatabaseImplement.Models
|
namespace SushiBarDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
|
[DataMember]
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
@ -49,6 +52,6 @@ namespace SushiBarDatabaseImplement.Models
|
|||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
};
|
};
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,29 +3,40 @@ using SushiBarContracts.ViewModels;
|
|||||||
using SushiBarDataModels.Enums;
|
using SushiBarDataModels.Enums;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace SushiBarDatabaseImplement.Models
|
namespace SushiBarDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int SushiId { get; set; }
|
public int SushiId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; set; }
|
public OrderStatus Status { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
public int Id { get; set; }
|
[DataMember]
|
||||||
public virtual Client? Client { get; set; }
|
|
||||||
public Sushi? Sushi { get; set; }
|
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
|
||||||
|
public virtual Client? Client { get; set; }
|
||||||
|
public Sushi? Sushi { get; set; }
|
||||||
public virtual Implementer? Implementer { get; set; } = new();
|
public virtual Implementer? Implementer { get; set; } = new();
|
||||||
|
|
||||||
public static Order? Create(SushiBarDatabase context, OrderBindingModel? model)
|
public static Order? Create(SushiBarDatabase context, OrderBindingModel? model)
|
||||||
|
@ -3,22 +3,28 @@ using SushiBarContracts.ViewModels;
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace SushiBarDatabaseImplement.Models
|
namespace SushiBarDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Sushi : ISushiModel
|
public class Sushi : ISushiModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string SushiName { get; set; } = string.Empty;
|
public string SushiName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
private Dictionary<int, (IIngredientModel, int)>? _sushiIngredients = null;
|
private Dictionary<int, (IIngredientModel, int)>? _sushiIngredients = null;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[DataMember]
|
||||||
public Dictionary<int, (IIngredientModel, int)> SushiIngredients
|
public Dictionary<int, (IIngredientModel, int)> SushiIngredients
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
@ -20,4 +20,8 @@
|
|||||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -16,6 +16,7 @@ namespace SushiBarFileImplement
|
|||||||
public List<Sushi> ListSushi { get; private set; }
|
public List<Sushi> ListSushi { get; private set; }
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
public List<Implementer> Implementers { get; private set; }
|
public List<Implementer> Implementers { get; private set; }
|
||||||
|
public List<MessageInfo> Messages { get; private set; }
|
||||||
|
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
@ -32,6 +33,7 @@ namespace SushiBarFileImplement
|
|||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||||
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||||
|
public void SaveMessages() => SaveData(Orders, ImplementerFileName, "Messages", x => x.GetXElement);
|
||||||
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
using SushiBarContracts.DI;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarFileImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarFileImplement
|
||||||
|
{
|
||||||
|
public class FileImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 1;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IIngredientStorage, IngredientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
34
SushiBar/SushiBarFileImplement/Implements/BackUpInfo.cs
Normal file
34
SushiBar/SushiBarFileImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
// Получаем значения из singleton-объекта универсального свойства содержащее тип T
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
return (List<T>?)source.GetType().GetProperties()
|
||||||
|
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
|
||||||
|
?.GetValue(source);
|
||||||
|
}
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,12 @@
|
|||||||
using SushiBarContracts.BindingModel;
|
using SushiBarContracts.BindingModel;
|
||||||
using SushiBarContracts.SearchModel;
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarFileImplement.Models;
|
using SushiBarFileImplement.Models;
|
||||||
|
|
||||||
namespace SushiBarFileImplement.Implements
|
namespace SushiBarFileImplement.Implements
|
||||||
{
|
{
|
||||||
public class ClientStorage
|
public class ClientStorage : IClientStorage
|
||||||
{
|
{
|
||||||
private readonly DataFileSingleton source;
|
private readonly DataFileSingleton source;
|
||||||
public ClientStorage()
|
public ClientStorage()
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
using SushiBarFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton _source;
|
||||||
|
public MessageInfoStorage()
|
||||||
|
{
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.MessageId != null)
|
||||||
|
{
|
||||||
|
return _source.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
return _source.Messages
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return _source.Messages
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
var newMessage = MessageInfo.Create(model);
|
||||||
|
if (newMessage == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Messages.Add(newMessage);
|
||||||
|
_source.SaveMessages();
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,21 @@
|
|||||||
using SushiBarContracts.BindingModel;
|
using SushiBarContracts.BindingModel;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarDataModels;
|
using SushiBarDataModels;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SushiBarFileImplement.Models
|
namespace SushiBarFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; private set; } = string.Empty;
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Email { get; private set; } = string.Empty;
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
public static Client? Create(ClientBindingModel model)
|
public static Client? Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -4,22 +4,25 @@ using SushiBarDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SushiBarFileImplement.Models
|
namespace SushiBarFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; private set; }
|
public int WorkExperience { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; private set; }
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
public static Implementer? Create(XElement element)
|
public static Implementer? Create(XElement element)
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SushiBarFileImplement.Models
|
namespace SushiBarFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Ingredient : IIngredientModel
|
public class Ingredient : IIngredientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string IngredientName { get; private set; } = string.Empty;
|
public string IngredientName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public static Ingredient? Create(IngredientBindingModel model)
|
public static Ingredient? Create(IngredientBindingModel model)
|
||||||
{
|
{
|
||||||
|
84
SushiBar/SushiBarFileImplement/Models/MessageInfo.cs
Normal file
84
SushiBar/SushiBarFileImplement/Models/MessageInfo.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace SushiBarFileImplement.Models
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public int? ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
[DataMember]
|
||||||
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Body = model.Body,
|
||||||
|
Subject = model.Subject,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
MessageId = model.MessageId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageInfo? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Body = element.Attribute("Body")!.Value,
|
||||||
|
Subject = element.Attribute("Subject")!.Value,
|
||||||
|
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
||||||
|
MessageId = element.Attribute("MessageId")!.Value,
|
||||||
|
SenderName = element.Attribute("SenderName")!.Value,
|
||||||
|
DateDelivery = Convert.ToDateTime(element.Attribute("DateDelivery")!.Value),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Body = Body,
|
||||||
|
Subject = Subject,
|
||||||
|
ClientId = ClientId,
|
||||||
|
MessageId = MessageId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("MessageInfo",
|
||||||
|
new XAttribute("Body", Body),
|
||||||
|
new XAttribute("Subject", Subject),
|
||||||
|
new XAttribute("ClientId", ClientId),
|
||||||
|
new XAttribute("MessageId", MessageId),
|
||||||
|
new XAttribute("SenderName", SenderName),
|
||||||
|
new XAttribute("DateDelivery", DateDelivery)
|
||||||
|
);
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
@ -2,20 +2,31 @@
|
|||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarDataModels.Enums;
|
using SushiBarDataModels.Enums;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SushiBarFileImplement.Models
|
namespace SushiBarFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int SushiId { get; private set; }
|
public int SushiId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
[DataMember]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SushiBarFileImplement.Models
|
namespace SushiBarFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Sushi : ISushiModel
|
public class Sushi : ISushiModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string SushiName { get; private set; } = string.Empty;
|
public string SushiName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
public Dictionary<int, int> Ingredients { get; private set; } = new();
|
public Dictionary<int, int> Ingredients { get; private set; } = new();
|
||||||
private Dictionary<int, (IIngredientModel, int)>? _productIngredients = null;
|
private Dictionary<int, (IIngredientModel, int)>? _productIngredients = null;
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -11,6 +11,7 @@ namespace SushiBarListImplement
|
|||||||
public List<Sushi> ListSushi { get; set; }
|
public List<Sushi> ListSushi { get; set; }
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
public List<Implementer> Implementers { get; set; }
|
public List<Implementer> Implementers { get; set; }
|
||||||
|
public List<MessageInfo> Messages { get; set; }
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Ingredients = new List<Ingredient>();
|
Ingredients = new List<Ingredient>();
|
||||||
@ -18,6 +19,7 @@ namespace SushiBarListImplement
|
|||||||
ListSushi = new List<Sushi>();
|
ListSushi = new List<Sushi>();
|
||||||
Clients = new List<Client>();
|
Clients = new List<Client>();
|
||||||
Implementers = new List<Implementer>();
|
Implementers = new List<Implementer>();
|
||||||
|
Messages = new List<MessageInfo>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
|
22
SushiBar/SushiBarListImplement/Implements/BackUpInfo.cs
Normal file
22
SushiBar/SushiBarListImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarListImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using SushiBarContracts.BindingModel;
|
using SushiBarContracts.BindingModel;
|
||||||
using SushiBarContracts.SearchModel;
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarListImplement;
|
using SushiBarListImplement;
|
||||||
using SushiBarListImplements.Models;
|
using SushiBarListImplements.Models;
|
||||||
@ -11,7 +12,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SushiBarListImplements.Implements
|
namespace SushiBarListImplements.Implements
|
||||||
{
|
{
|
||||||
public class ClientStorage
|
public class ClientStorage : IClientStorage
|
||||||
{
|
{
|
||||||
private readonly DataListSingleton _source;
|
private readonly DataListSingleton _source;
|
||||||
public ClientStorage()
|
public ClientStorage()
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
|
||||||
|
|
||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
using SushiBarListImplement.Models;
|
||||||
|
|
||||||
|
namespace SushiBarListImplement.Implements
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public MessageInfoStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
foreach (var message in _source.Messages)
|
||||||
|
{
|
||||||
|
if (model.MessageId != null && model.MessageId.Equals(message.MessageId))
|
||||||
|
return message.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> result = new();
|
||||||
|
foreach (var item in _source.Messages)
|
||||||
|
{
|
||||||
|
if (item.ClientId.HasValue && item.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(item.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> result = new();
|
||||||
|
foreach (var item in _source.Messages)
|
||||||
|
{
|
||||||
|
result.Add(item.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
var newMessage = MessageInfo.Create(model);
|
||||||
|
if (newMessage == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Messages.Add(newMessage);
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarListImplement.Implements;
|
||||||
|
using SushiBarListImplements.Implements;
|
||||||
|
|
||||||
|
namespace SushiBarListImplement
|
||||||
|
{
|
||||||
|
public class ListImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IIngredientStorage, IngredientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,19 @@
|
|||||||
using SushiBarContracts.BindingModel;
|
using SushiBarContracts.BindingModel;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarDataModels;
|
using SushiBarDataModels;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace SushiBarListImplements.Models
|
namespace SushiBarListImplements.Models
|
||||||
{
|
{
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public string ClientFIO { get; private set; } = string.Empty;
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
public static Client? Create(ClientBindingModel? model)
|
public static Client? Create(ClientBindingModel? model)
|
||||||
{
|
{
|
||||||
|
@ -4,13 +4,16 @@ using SushiBarDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SushiBarListImplement.Models
|
namespace SushiBarListImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
52
SushiBar/SushiBarListImplement/Models/MessageInfo.cs
Normal file
52
SushiBar/SushiBarListImplement/Models/MessageInfo.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
|
||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
|
namespace SushiBarListImplement.Models
|
||||||
|
{
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; private set; }
|
||||||
|
|
||||||
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Body = model.Body,
|
||||||
|
Subject = model.Subject,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
MessageId = model.MessageId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Body = Body,
|
||||||
|
Subject = Subject,
|
||||||
|
ClientId = ClientId,
|
||||||
|
MessageId = MessageId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
};
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user