Я устал босс
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
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBarView
|
||||
{
|
||||
@ -20,14 +21,7 @@ namespace SushiBarView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка исполнителей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -45,13 +39,10 @@ namespace SushiBarView
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
var form = DependencyManager.Instance.Resolve<FormIngredient>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,14 +50,11 @@ namespace SushiBarView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
var form = DependencyManager.Instance.Resolve<FormIngredient>();
|
||||
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);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBarView
|
||||
{
|
||||
@ -40,27 +41,21 @@ namespace SushiBarView
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredient));
|
||||
if (service is FormIngredient form)
|
||||
var form = DependencyManager.Instance.Resolve<FormIngredient>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredient));
|
||||
if (service is FormIngredient form)
|
||||
var form = DependencyManager.Instance.Resolve<FormIngredient>();
|
||||
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);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBarView
|
||||
{
|
||||
@ -42,13 +43,10 @@ namespace SushiBarView
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
|
||||
if (service is FormSushi form)
|
||||
var form = DependencyManager.Instance.Resolve<FormSushi>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,14 +54,11 @@ namespace SushiBarView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
|
||||
if (service is FormSushi form)
|
||||
var form = DependencyManager.Instance.Resolve<FormSushi>();
|
||||
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);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
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();
|
||||
buttonUpdate = new Button();
|
||||
buttonSetToFinish = new Button();
|
||||
buttonSetToDone = new Button();
|
||||
buttonSetToWork = new Button();
|
||||
buttonCreateOrder = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
письмаToolStripMenuItem = new ToolStripMenuItem();
|
||||
создатьБекапToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem });
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, создатьБекапToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1112, 24);
|
||||
@ -69,35 +70,35 @@
|
||||
// ингредиентыToolStripMenuItem
|
||||
//
|
||||
ингредиентыToolStripMenuItem.Name = "ингредиентыToolStripMenuItem";
|
||||
ингредиентыToolStripMenuItem.Size = new Size(154, 22);
|
||||
ингредиентыToolStripMenuItem.Size = new Size(180, 22);
|
||||
ингредиентыToolStripMenuItem.Text = "Ингредиенты";
|
||||
ингредиентыToolStripMenuItem.Click += IngredientsToolStripMenuItem_Click;
|
||||
//
|
||||
// сушиToolStripMenuItem
|
||||
//
|
||||
сушиToolStripMenuItem.Name = "сушиToolStripMenuItem";
|
||||
сушиToolStripMenuItem.Size = new Size(154, 22);
|
||||
сушиToolStripMenuItem.Size = new Size(180, 22);
|
||||
сушиToolStripMenuItem.Text = "Суши";
|
||||
сушиToolStripMenuItem.Click += SushiToolStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(154, 22);
|
||||
клиентыToolStripMenuItem.Size = new Size(180, 22);
|
||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||
//
|
||||
// исполнителиToolStripMenuItem
|
||||
//
|
||||
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
исполнителиToolStripMenuItem.Size = new Size(154, 22);
|
||||
исполнителиToolStripMenuItem.Size = new Size(180, 22);
|
||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
исполнителиToolStripMenuItem.Click += employersToolStripMenuItem_Click;
|
||||
//
|
||||
// начатьРаботуToolStripMenuItem
|
||||
//
|
||||
начатьРаботуToolStripMenuItem.Name = "начатьРаботуToolStripMenuItem";
|
||||
начатьРаботуToolStripMenuItem.Size = new Size(154, 22);
|
||||
начатьРаботуToolStripMenuItem.Size = new Size(180, 22);
|
||||
начатьРаботуToolStripMenuItem.Text = "Начать работу";
|
||||
начатьРаботуToolStripMenuItem.Click += startWorkToolStripMenuItem_Click;
|
||||
//
|
||||
@ -129,6 +130,13 @@
|
||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
списокЗаказовToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||
//
|
||||
// письмаToolStripMenuItem
|
||||
//
|
||||
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
||||
письмаToolStripMenuItem.Size = new Size(203, 22);
|
||||
письмаToolStripMenuItem.Text = "Письма";
|
||||
письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
@ -201,12 +209,12 @@
|
||||
dataGridView.Size = new Size(919, 426);
|
||||
dataGridView.TabIndex = 7;
|
||||
//
|
||||
// письмаToolStripMenuItem
|
||||
// создатьБекапToolStripMenuItem
|
||||
//
|
||||
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
||||
письмаToolStripMenuItem.Size = new Size(203, 22);
|
||||
письмаToolStripMenuItem.Text = "Письма";
|
||||
письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click;
|
||||
создатьБекапToolStripMenuItem.Name = "создатьБекапToolStripMenuItem";
|
||||
создатьБекапToolStripMenuItem.Size = new Size(97, 20);
|
||||
создатьБекапToolStripMenuItem.Text = "Создать бекап";
|
||||
создатьБекапToolStripMenuItem.Click += создатьБекапToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
@ -251,5 +259,6 @@
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripMenuItem начатьРаботуToolStripMenuItem;
|
||||
private ToolStripMenuItem письмаToolStripMenuItem;
|
||||
private ToolStripMenuItem создатьБекапToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBarView
|
||||
{
|
||||
@ -10,8 +11,8 @@ namespace SushiBarView
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
private readonly IBackUpLogic _backUpLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
@ -19,6 +20,8 @@ namespace SushiBarView
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
_workProcess = workProcess;
|
||||
_backUpLogic = backUpLogic;
|
||||
LoadData();
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
@ -29,14 +32,7 @@ namespace SushiBarView
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["SushiId"].Visible = false;
|
||||
dataGridView.Columns["Implementerid"].Visible = false;
|
||||
dataGridView.Columns["ClientEmail"].Visible = false;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -47,28 +43,19 @@ namespace SushiBarView
|
||||
}
|
||||
private void IngredientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredients));
|
||||
if (service is FormIngredients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormIngredients>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void SushiToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormListSushi));
|
||||
if (service is FormListSushi form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormSushi>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -152,61 +139,67 @@ namespace SushiBarView
|
||||
}
|
||||
private void SushiListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveListSushiToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormListSushi>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void SushiIngredientToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportSushiIngredients));
|
||||
if (service is FormReportSushiIngredients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormSushiIngredients>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void employersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void startWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormViewMail));
|
||||
if (service is FormViewMail form)
|
||||
var form = DependencyManager.Instance.Resolve<FormViewMail>();
|
||||
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 SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
@ -70,23 +71,25 @@ namespace SushiBarView
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiIngredients));
|
||||
if (service is FormSushiIngredients form)
|
||||
var form = DependencyManager.Instance.Resolve<FormSushiIngredients>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.IngredientModel == null)
|
||||
{
|
||||
if (form.IngredientModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление нового ингредиента: { IngredientName} - { Count}", form.IngredientModel.IngredientName, form.Count);
|
||||
_logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.IngredientModel.IngredientName, form.Count);
|
||||
if (_sushiIngredients.ContainsKey(form.Id))
|
||||
{
|
||||
_sushiIngredients[form.Id] = (form.IngredientModel, form.Count);
|
||||
_sushiIngredients[form.Id] = (form.IngredientModel,
|
||||
form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sushiIngredients.Add(form.Id, (form.IngredientModel, form.Count));
|
||||
_sushiIngredients.Add(form.Id, (form.IngredientModel,
|
||||
form.Count));
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
@ -96,22 +99,19 @@ namespace SushiBarView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiIngredients));
|
||||
if (service is FormSushiIngredients form)
|
||||
var form = DependencyManager.Instance.Resolve<FormSushiIngredients>();
|
||||
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);
|
||||
form.Id = id;
|
||||
form.Count = _sushiIngredients[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.IngredientModel == null)
|
||||
{
|
||||
if (form.IngredientModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение ингредиента: { IngredientName} - { Count} ", form.IngredientModel.IngredientName, form.Count);
|
||||
_sushiIngredients[form.Id] = (form.IngredientModel, form.Count);
|
||||
LoadData();
|
||||
return;
|
||||
}
|
||||
_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.MailWorker;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBarView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -26,76 +26,69 @@ namespace SushiBarView
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
try
|
||||
{
|
||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
||||
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
||||
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
||||
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
||||
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
||||
});
|
||||
InitDependency();
|
||||
try
|
||||
{
|
||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>(); mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
||||
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
||||
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
||||
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
||||
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
||||
});
|
||||
|
||||
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = _serviceProvider.GetService<ILogger>();
|
||||
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
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>");
|
||||
}
|
||||
|
||||
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.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IIngredientStorage, IngredientStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ISushiStorage, SushiStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
DependencyManager.Instance.RegisterType<IIngredientLogic, IngredientLogic>();
|
||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
|
||||
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||
|
||||
services.AddTransient<IIngredientLogic, IngredientLogic>();
|
||||
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>();
|
||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormIngredient>();
|
||||
services.AddTransient<FormIngredients>();
|
||||
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<AbstractSaveToExcel, SaveToExcel>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
}
|
||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||
}
|
||||
DependencyManager.Instance.RegisterType<FormMain>();
|
||||
DependencyManager.Instance.RegisterType<FormIngredient>();
|
||||
DependencyManager.Instance.RegisterType<FormIngredients>();
|
||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||
DependencyManager.Instance.RegisterType<FormListSushi>();
|
||||
DependencyManager.Instance.RegisterType<FormSushiIngredients>();
|
||||
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 System;
|
||||
using System.Collections.Generic;
|
||||
@ -16,5 +16,6 @@ namespace SushiBarContracts.BindingModels
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Body { get; set; } = string.Empty;
|
||||
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>
|
||||
</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>
|
||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SushiBarDataModels;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -10,17 +11,14 @@ namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО Клиента")]
|
||||
[Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Логин (эл. почтаы)")]
|
||||
[Column("Логин (эл. почта)", width: 150)]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
[Column("Пароль", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SushiBarDataModels.Models;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -10,18 +11,19 @@ namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
[Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
[Column("Пароль", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Стаж работы")]
|
||||
[Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DisplayName("Квалификация")]
|
||||
[Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
using SushiBarDataModels.Models;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class IngredientViewModel : IIngredientModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название ингредиента")]
|
||||
[Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string IngredientName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
[Column("Цена", width: 80)]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using PrecastConcretePlantDataModels.Models;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels.Models;
|
||||
using SushiBarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -11,20 +12,23 @@ namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
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("Отправитель")]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
[Column("Дата письма", width: 100)]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
[DisplayName("Дата письма")]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
[Column("Заголовок", width: 150)]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Заголовок")]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Текст")]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
}
|
||||
[Column("Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SushiBarDataModels.Enums;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels.Enums;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
@ -6,34 +7,38 @@ namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
[Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Id { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int? ImplementerId { get; set; }
|
||||
[DisplayName("Исполнитель")]
|
||||
[Column("Фамилия исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string? ImplementerFIO { get; set; } = null;
|
||||
[Column(visible: false)]
|
||||
public int SushiId { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int ClientId { get; set; }
|
||||
[Column(visible: false)]
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("ФИО клиента")]
|
||||
[Column("Фамилия клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Изделие")]
|
||||
[Column("Изделие", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Количество")]
|
||||
[Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Count { get; set; }
|
||||
|
||||
[DisplayName("Сумма")]
|
||||
[Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public double Sum { get; set; }
|
||||
|
||||
[DisplayName("Статус")]
|
||||
[Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
||||
[DisplayName("Дата создания")]
|
||||
[Column("Дата создания", width: 100)]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
[DisplayName("Дата выполнения")]
|
||||
[Column("Дата выполнения", width: 100)]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
@ -1,15 +1,18 @@
|
||||
using SushiBarDataModels.Models;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class SushiViewModel : ISushiModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
[Column("Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
[Column("Цена", width: 100)]
|
||||
public double Price { get; set; }
|
||||
[Column(visible: false)]
|
||||
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.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PrecastConcretePlantDataModels.Models
|
||||
namespace SushiBarDataModels.Models
|
||||
{
|
||||
public interface IMessageInfoModel
|
||||
public interface IMessageInfoModel : IId
|
||||
{
|
||||
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;
|
||||
using SushiBarDataModels;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<MessageInfo> Messages { get; set; } = new();
|
||||
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
{
|
||||
|
@ -8,23 +8,30 @@ using System.Threading.Tasks;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarDatabaseImplement.Models;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SushiBarDataModels.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Qualification { get; set; }
|
||||
|
||||
[ForeignKey("ImplementerId")]
|
||||
|
@ -3,17 +3,22 @@ using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Ingredient : IIngredientModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string IngredientName { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Cost { get; set; }
|
||||
|
||||
[ForeignKey("IngredientId")]
|
||||
|
@ -1,14 +1,17 @@
|
||||
using PrecastConcretePlantDataModels.Models;
|
||||
using SushiBarDataModels.Models;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class MessageInfo : IMessageInfoModel
|
||||
{
|
||||
[Key]
|
||||
[DataMember]
|
||||
public string MessageId { get; private set; } = string.Empty;
|
||||
|
||||
public int? ClientId { get; private set; }
|
||||
@ -49,6 +52,6 @@ namespace SushiBarDatabaseImplement.Models
|
||||
SenderName = SenderName,
|
||||
DateDelivery = DateDelivery,
|
||||
};
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -3,29 +3,40 @@ using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Enums;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
[Required]
|
||||
public int SushiId { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Count { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int ClientId { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Sum { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public OrderStatus Status { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public DateTime DateCreate { get; set; }
|
||||
[DataMember]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public int Id { get; set; }
|
||||
public virtual Client? Client { get; set; }
|
||||
public Sushi? Sushi { get; set; }
|
||||
[DataMember]
|
||||
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 static Order? Create(SushiBarDatabase context, OrderBindingModel? model)
|
||||
|
@ -3,22 +3,28 @@ using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Sushi : ISushiModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Price { get; set; }
|
||||
|
||||
private Dictionary<int, (IIngredientModel, int)>? _sushiIngredients = null;
|
||||
|
||||
[NotMapped]
|
||||
[DataMember]
|
||||
public Dictionary<int, (IIngredientModel, int)> SushiIngredients
|
||||
{
|
||||
get
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@ -20,4 +20,8 @@
|
||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
@ -16,6 +16,7 @@ namespace SushiBarFileImplement
|
||||
public List<Sushi> ListSushi { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public List<Implementer> Implementers { get; private set; }
|
||||
public List<MessageInfo> Messages { get; private set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
@ -32,6 +33,7 @@ namespace SushiBarFileImplement
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", 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 SaveMessages() => SaveData(Orders, ImplementerFileName, "Messages", x => x.GetXElement);
|
||||
|
||||
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.SearchModel;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarFileImplement.Models;
|
||||
|
||||
namespace SushiBarFileImplement.Implements
|
||||
{
|
||||
public class ClientStorage
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
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.ViewModels;
|
||||
using SushiBarDataModels;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
|
@ -4,22 +4,25 @@ 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 Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public int WorkExperience { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public int Qualification { get; private set; }
|
||||
|
||||
public static Implementer? Create(XElement element)
|
||||
|
@ -1,14 +1,19 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Ingredient : IIngredientModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public string IngredientName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public double Cost { get; set; }
|
||||
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 SushiBarDataModels.Enums;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public int SushiId { get; private set; }
|
||||
[DataMember]
|
||||
public int ClientId { get; private set; }
|
||||
[DataMember]
|
||||
public int? ImplementerId { get; set; }
|
||||
[DataMember]
|
||||
public int Count { get; private set; }
|
||||
[DataMember]
|
||||
public double Sum { get; private set; }
|
||||
[DataMember]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
[DataMember]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
[DataMember]
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
|
@ -1,14 +1,19 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Sushi : ISushiModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public string SushiName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, int> Ingredients { get; private set; } = new();
|
||||
private Dictionary<int, (IIngredientModel, int)>? _productIngredients = null;
|
||||
|
@ -11,4 +11,8 @@
|
||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
@ -11,6 +11,7 @@ namespace SushiBarListImplement
|
||||
public List<Sushi> ListSushi { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
public List<Implementer> Implementers { get; set; }
|
||||
public List<MessageInfo> Messages { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Ingredients = new List<Ingredient>();
|
||||
@ -18,6 +19,7 @@ namespace SushiBarListImplement
|
||||
ListSushi = new List<Sushi>();
|
||||
Clients = new List<Client>();
|
||||
Implementers = new List<Implementer>();
|
||||
Messages = new List<MessageInfo>();
|
||||
}
|
||||
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.SearchModel;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarListImplement;
|
||||
using SushiBarListImplements.Models;
|
||||
@ -11,7 +12,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SushiBarListImplements.Implements
|
||||
{
|
||||
public class ClientStorage
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
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.ViewModels;
|
||||
using SushiBarDataModels;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SushiBarListImplements.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
{
|
||||
|
@ -4,13 +4,16 @@ using SushiBarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SushiBarListImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
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" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user