Bazunov A.I. Lab Work #8 #17
@ -2,6 +2,7 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using System.Windows.Forms;
|
||||
using SushiBarContracts.Attributes;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
@ -21,13 +22,7 @@ namespace SushiBar
|
||||
{
|
||||
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("Load clients");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
@ -18,57 +20,48 @@ namespace SushiBar
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
if (service is FormComponent form)
|
||||
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
if (service is not { }) return;
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
if (service is not { }) return;
|
||||
service.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
if (service is FormComponent form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
|
||||
DialogResult.Yes) return;
|
||||
var id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Delete component");
|
||||
try
|
||||
{
|
||||
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
if (!_logic.Delete(new ComponentBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Delete component");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ComponentBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Error on deleting. Additional info below.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error delete component");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
throw new Exception("Error on deleting. Additional info below.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error delete component");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,13 +79,7 @@ namespace SushiBar
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Load components");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
@ -17,29 +19,21 @@ namespace SushiBar
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
service.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,13 +82,7 @@ namespace SushiBar
|
||||
{
|
||||
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("Load implementers");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace SushiBar
|
||||
@ -20,14 +21,7 @@ namespace SushiBar
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["MessageId"].Visible = false;
|
||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Load mails");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
8
SushiBar/SushiBar/FormMain.Designer.cs
generated
8
SushiBar/SushiBar/FormMain.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
this.componentsOnSushiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.listOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.startWorkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.createBackUpMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonSubmit = new System.Windows.Forms.Button();
|
||||
this.buttonReady = new System.Windows.Forms.Button();
|
||||
@ -65,6 +66,7 @@
|
||||
this.directoryToolStripMenuItem,
|
||||
this.reportsToolStripMenuItem,
|
||||
this.startWorkToolStripMenuItem,
|
||||
this.createBackUpMenuItem,
|
||||
this.mailsToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
@ -148,6 +150,11 @@
|
||||
this.startWorkToolStripMenuItem.Size = new System.Drawing.Size(72, 20);
|
||||
this.startWorkToolStripMenuItem.Text = "Start work";
|
||||
this.startWorkToolStripMenuItem.Click += new System.EventHandler(this.StartWorkToolStripMenuItem_Click);
|
||||
|
||||
this.createBackUpMenuItem.Name = "createBackUpMenuItem";
|
||||
this.createBackUpMenuItem.Size = new System.Drawing.Size(72, 20);
|
||||
this.createBackUpMenuItem.Text = "Create backup";
|
||||
this.createBackUpMenuItem.Click += new System.EventHandler(this.CreateBackupStripMenuItem_Click);
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
@ -248,6 +255,7 @@
|
||||
private ToolStripMenuItem listOrdersToolStripMenuItem;
|
||||
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||
private ToolStripMenuItem startWorkToolStripMenuItem;
|
||||
private ToolStripMenuItem createBackUpMenuItem;
|
||||
private ToolStripMenuItem implementersToolStripMenuItem;
|
||||
private ToolStripMenuItem mailsToolStripMenuItem;
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarBusinessLogic.BusinessLogics;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
using SushiBarDataModels.Enums;
|
||||
|
||||
namespace SushiBar
|
||||
@ -13,49 +15,33 @@ namespace SushiBar
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
private readonly IBackUpLogic _backUpLogic;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger,
|
||||
IOrderLogic orderLogic,
|
||||
IReportLogic reportLogic,
|
||||
IWorkProcess workProcess)
|
||||
IWorkProcess workProcess,
|
||||
IBackUpLogic backUpLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
_backUpLogic = backUpLogic;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Load components");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["SushiId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
dataGridView.Columns["ClientFio"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on load orders");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||
}
|
||||
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||
service.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonSubmit_Click(object sender, EventArgs e)
|
||||
@ -93,67 +79,63 @@ namespace SushiBar
|
||||
|
||||
private void ButtonReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
var id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Order №{id}. Change status on -Ready",id);
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Order №{id}. Change status on -Ready",id);
|
||||
try
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel {
|
||||
Id = id,
|
||||
SushiId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SushiId"].Value),
|
||||
SushiName = dataGridView.SelectedRows[0].Cells["SushiName"].Value.ToString() ?? "",
|
||||
ClientFio = dataGridView.SelectedRows[0].Cells["ClientFio"].Value.ToString() ?? "",
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString() ?? "Unknown"),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString() ?? "0"),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString() ?? ""),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel {
|
||||
Id = id,
|
||||
SushiId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SushiId"].Value),
|
||||
SushiName = dataGridView.SelectedRows[0].Cells["SushiName"].Value.ToString() ?? "",
|
||||
ClientFio = dataGridView.SelectedRows[0].Cells["ClientFio"].Value.ToString() ?? "",
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString() ?? "Unknown"),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString() ?? "0"),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString() ?? ""),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Error on saving. Additional info below.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on change status");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
throw new Exception("Error on saving. Additional info below.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on change status");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonIssue_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
var id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Order №{id}. Change status on -Issued", id);
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Order №{id}. Change status on -Issued", id);
|
||||
try
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel {
|
||||
Id = id,
|
||||
SushiId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SushiId"].Value),
|
||||
SushiName = dataGridView.SelectedRows[0].Cells["SushiName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
ClientFio = dataGridView.SelectedRows[0].Cells["ClientFio"].Value.ToString(),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel {
|
||||
Id = id,
|
||||
SushiId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SushiId"].Value),
|
||||
SushiName = dataGridView.SelectedRows[0].Cells["SushiName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
ClientFio = dataGridView.SelectedRows[0].Cells["ClientFio"].Value.ToString(),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Error on saving. Additional info below.");
|
||||
}
|
||||
_logger.LogInformation("Order №{id} issued", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on change status");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
throw new Exception("Error on saving. Additional info below.");
|
||||
}
|
||||
_logger.LogInformation("Order №{id} issued", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error on change status");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,84 +151,75 @@ namespace SushiBar
|
||||
|
||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var service = DependencyManager.Instance.Resolve<FormComponents>();
|
||||
service.ShowDialog();
|
||||
}
|
||||
|
||||
private void SushiToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiMoreThenOne));
|
||||
|
||||
if (service is FormSushiMoreThenOne form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var service = DependencyManager.Instance.Resolve<FormSushiMoreThenOne>();
|
||||
service.ShowDialog();
|
||||
}
|
||||
|
||||
private void ListComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
if (dialog.ShowDialog() != DialogResult.OK) return;
|
||||
_reportLogic.SaveSushiToWordFile(new ReportBindingModel
|
||||
{
|
||||
_reportLogic.SaveSushiToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
MessageBox.Show("Complete", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
MessageBox.Show("Complete", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void ComponentsOnSushiToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiOnComponents));
|
||||
if (service is FormSushiOnComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var service = DependencyManager.Instance.Resolve<FormSushiOnComponents>();
|
||||
service.ShowDialog();
|
||||
}
|
||||
|
||||
private void ListOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var service = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||
service.ShowDialog();
|
||||
}
|
||||
|
||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var service = DependencyManager.Instance.Resolve<FormClients>();
|
||||
service.ShowDialog();
|
||||
}
|
||||
|
||||
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("Process work is started", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var service = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||
service.ShowDialog();
|
||||
}
|
||||
|
||||
private void MailsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
|
||||
if (service is FormMails form)
|
||||
var service = DependencyManager.Instance.Resolve<FormMails>();
|
||||
service.ShowDialog();
|
||||
}
|
||||
|
||||
private void CreateBackupStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
form.ShowDialog();
|
||||
var fbd = new FolderBrowserDialog();
|
||||
if (fbd.ShowDialog() != DialogResult.OK) return;
|
||||
_backUpLogic.CreateBackUp(new BackUpSaveBindingModel { FolderName = fbd.SelectedPath });
|
||||
MessageBox.Show("Backup is ready", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Error", 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;
|
||||
|
||||
@ -27,15 +28,13 @@ namespace SushiBar
|
||||
_logger.LogInformation("Load components");
|
||||
try
|
||||
{
|
||||
if (_sushiComponents != null)
|
||||
if (_sushiComponents == null) return;
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var pc in _sushiComponents)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var pc in _sushiComponents)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||
}
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||
}
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -82,7 +81,7 @@ namespace SushiBar
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent));
|
||||
var service = DependencyManager.Instance.Resolve<FormSushiComponent>();
|
||||
if (service is FormSushiComponent form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
@ -109,7 +108,7 @@ namespace SushiBar
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent));
|
||||
var service = DependencyManager.Instance.Resolve<FormSushiComponent>();
|
||||
if (service is FormSushiComponent form)
|
||||
{
|
||||
int id =
|
||||
@ -184,7 +183,7 @@ namespace SushiBar
|
||||
SushiComponents = _sushiComponents
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||
_logic.Create(model);
|
||||
_logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Error on saving. Additional info below.");
|
||||
|
@ -10,14 +10,8 @@ namespace SushiBar
|
||||
private readonly List<ComponentViewModel>? _list;
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxComponent.SelectedValue = value;
|
||||
}
|
||||
get => Convert.ToInt32(comboBoxComponent.SelectedValue);
|
||||
set => comboBoxComponent.SelectedValue = value;
|
||||
}
|
||||
public IComponentModel? ComponentModel
|
||||
{
|
||||
@ -39,21 +33,19 @@ namespace SushiBar
|
||||
}
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||
set { textBoxCount.Text = value.ToString(); }
|
||||
get => Convert.ToInt32(textBoxCount.Text);
|
||||
set => textBoxCount.Text = value.ToString();
|
||||
}
|
||||
|
||||
public FormSushiComponent(IComponentLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_list = logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
comboBoxComponent.DisplayMember = "ComponentName";
|
||||
comboBoxComponent.ValueMember = "Id";
|
||||
comboBoxComponent.DataSource = _list;
|
||||
comboBoxComponent.SelectedItem = null;
|
||||
}
|
||||
if (_list == null) return;
|
||||
comboBoxComponent.DisplayMember = "ComponentName";
|
||||
comboBoxComponent.ValueMember = "Id";
|
||||
comboBoxComponent.DataSource = _list;
|
||||
comboBoxComponent.SelectedItem = null;
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
@ -19,14 +21,7 @@ namespace SushiBar
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["SushiName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["SushiComponents"].Visible = false;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Load sushi");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -38,54 +33,43 @@ namespace SushiBar
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
|
||||
if (service is FormSushi form)
|
||||
var service = DependencyManager.Instance.Resolve<FormSushi>();
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
var service = DependencyManager.Instance.Resolve<FormSushi>();
|
||||
service.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
|
||||
if (service is FormSushi form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
|
||||
DialogResult.Yes) return;
|
||||
var id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Delete sushi");
|
||||
try
|
||||
{
|
||||
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
if (!_logic.Delete(new SushiBindingModel { Id = id }))
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Delete sushi");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new SushiBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Error on deleting. Additional info below.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error delete sushi");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
throw new Exception("Error on deleting. Additional info below.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error delete sushi");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,25 +22,23 @@ namespace SushiBar
|
||||
{
|
||||
Filter = "xlsx|*.xlsx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
if (dialog.ShowDialog() != DialogResult.OK) return;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveProductComponentToExcelFile(new
|
||||
_logic.SaveProductComponentToExcelFile(new
|
||||
ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
_logger.LogInformation("Saving list sushi on components");
|
||||
_logger.LogInformation("Saving list sushi on components");
|
||||
|
||||
MessageBox.Show("Success", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||
MessageBox.Show("Success", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
@ -50,19 +48,16 @@ namespace SushiBar
|
||||
try
|
||||
{
|
||||
var dict = _logic.GetSushi();
|
||||
if (dict != null)
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in dict)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in dict)
|
||||
dataGridView.Rows.Add(elem.SushiName, "", "");
|
||||
foreach (var listElem in elem.Components)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { elem.SushiName, "", "" });
|
||||
foreach (var listElem in elem.Components)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||
}
|
||||
dataGridView.Rows.Add(new object[] { "Count", "", elem.TotalCount });
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
dataGridView.Rows.Add("", listElem.Item1, listElem.Item2);
|
||||
}
|
||||
dataGridView.Rows.Add("Count", "", elem.TotalCount);
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
_logger.LogInformation("Load list sushi on components");
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using SushiBarBusinessLogic.BusinessLogics;
|
||||
@ -7,26 +6,20 @@ using SushiBarBusinessLogic.OfficePackage;
|
||||
using SushiBarBusinessLogic.OfficePackage.Implements;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarDatabaseImplement.Implements;
|
||||
using SushiBarContracts.DI;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
InitDependency();
|
||||
try
|
||||
{
|
||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin =
|
||||
@ -49,55 +42,54 @@ namespace SushiBar
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
var logger = _serviceProvider.GetService<ILogger>();
|
||||
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||
logger?.LogError(ex, "Error on working w/ email");
|
||||
}
|
||||
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||
}
|
||||
private static void ConfigureServices(IServiceCollection services)
|
||||
|
||||
private static void InitDependency()
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
DependencyManager.InitDependency();
|
||||
|
||||
DependencyManager.Instance.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ISushiStorage, SushiStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageStorage>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<ISushiLogic, SushiLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormSushi>();
|
||||
services.AddTransient<FormSushiComponent>();
|
||||
services.AddTransient<FormSushiMoreThenOne>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormSushiOnComponents>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormMails>();
|
||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||
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>();
|
||||
|
||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
DependencyManager.Instance.RegisterType<FormMain>();
|
||||
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||
DependencyManager.Instance.RegisterType<FormSushi>();
|
||||
DependencyManager.Instance.RegisterType<FormSushiComponent>();
|
||||
DependencyManager.Instance.RegisterType<FormSushiMoreThenOne>();
|
||||
DependencyManager.Instance.RegisterType<FormSushiOnComponents>();
|
||||
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||
DependencyManager.Instance.RegisterType<FormClients>();
|
||||
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||
DependencyManager.Instance.RegisterType<FormMails>();
|
||||
}
|
||||
|
||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||
private static void MailCheck(object obj) =>
|
||||
DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||
}
|
||||
}
|
87
SushiBar/SushiBarBusinessLogic/BusinessLogics/BackUpLogic.cs
Normal file
87
SushiBar/SushiBarBusinessLogic/BusinessLogics/BackUpLogic.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System.IO.Compression;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarDataModels;
|
||||
|
||||
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)
|
||||
{
|
||||
_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");
|
||||
var 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("Not found", 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) continue;
|
||||
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||
|
||||
if (modelType == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Not fount model {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);
|
||||
}
|
||||
|
||||
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($"{folderName}/{typeof(T).Name}.json", FileMode.OpenOrCreate);
|
||||
jsonFormatter.WriteObject(fs, records);
|
||||
}
|
||||
}
|
@ -82,11 +82,6 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
{
|
||||
_logger.LogInformation("ReadList .Id:{Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
23
SushiBar/SushiBarContracts/Attributes/ColumnAttribute.cs
Normal file
23
SushiBar/SushiBarContracts/Attributes/ColumnAttribute.cs
Normal file
@ -0,0 +1,23 @@
|
||||
namespace SushiBarContracts.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class ColumnAttribute : Attribute
|
||||
{
|
||||
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;
|
||||
}
|
||||
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; }
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SushiBarContracts.Attributes;
|
||||
|
||||
public 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($"In type {type.Name} not found references with {column.Name}");
|
||||
}
|
||||
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
|
||||
switch (attribute)
|
||||
{
|
||||
case null:
|
||||
throw new InvalidOperationException($"Not found attribute ColumnAttribute to property {property.Name}");
|
||||
case 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;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
SushiBar/SushiBarContracts/Attributes/GridViewAutoSize.cs
Normal file
13
SushiBar/SushiBarContracts/Attributes/GridViewAutoSize.cs
Normal file
@ -0,0 +1,13 @@
|
||||
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,6 @@
|
||||
namespace SushiBarContracts.BindingModels;
|
||||
|
||||
public class BackUpSaveBindingModel
|
||||
{
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
}
|
@ -10,4 +10,5 @@ public class MessageInfoBindingModel : IMessageInfoModel
|
||||
public DateTime DateDelivery { get; set; }
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Body { get; set; } = string.Empty;
|
||||
public int Id { get; }
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
|
||||
namespace SushiBarContracts.BusinessLogicsContracts;
|
||||
|
||||
public interface IBackUpLogic
|
||||
{
|
||||
void CreateBackUp(BackUpSaveBindingModel model);
|
||||
}
|
45
SushiBar/SushiBarContracts/DI/DependencyManager.cs
Normal file
45
SushiBar/SushiBarContracts/DI/DependencyManager.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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)
|
||||
return
|
||||
_manager;
|
||||
lock (_locjObject) { _manager = new DependencyManager(); }
|
||||
return
|
||||
_manager; } }
|
||||
|
||||
public static void InitDependency()
|
||||
{
|
||||
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||
if (ext == null)
|
||||
{
|
||||
throw new ArgumentNullException("Missing components to load module dependencies");
|
||||
}
|
||||
ext.RegisterServices();
|
||||
}
|
||||
|
||||
public void AddLogging(Action<ILoggingBuilder> configure) =>
|
||||
_dependencyManager.AddLogging(configure);
|
||||
|
||||
public void RegisterType<T, TU>(bool isSingle = false) where TU : class, T where T : class =>
|
||||
_dependencyManager.RegisterType<T, TU>(isSingle);
|
||||
|
||||
public void RegisterType<T>(bool isSingle = false) where T : class =>
|
||||
_dependencyManager.RegisterType<T>(isSingle);
|
||||
|
||||
public T Resolve<T>() =>
|
||||
_dependencyManager.Resolve<T>();
|
||||
}
|
11
SushiBar/SushiBarContracts/DI/IDependencyContainer.cs
Normal file
11
SushiBar/SushiBarContracts/DI/IDependencyContainer.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace SushiBarContracts.DI;
|
||||
|
||||
public interface IDependencyContainer
|
||||
{
|
||||
void AddLogging(Action<ILoggingBuilder> configure);
|
||||
void RegisterType<T, TU>(bool isSingle) where TU : class, T where T : class;
|
||||
void RegisterType<T>(bool isSingle) where T : class;
|
||||
T Resolve<T>();
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace SushiBarContracts.DI;
|
||||
|
||||
public interface IImplementationExtension
|
||||
{
|
||||
public int Priority { get; }
|
||||
public void RegisterServices();
|
||||
}
|
56
SushiBar/SushiBarContracts/DI/ServiceDependencyContainer.cs
Normal file
56
SushiBar/SushiBarContracts/DI/ServiceDependencyContainer.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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>()!;
|
||||
}
|
||||
}
|
47
SushiBar/SushiBarContracts/DI/ServiceProviderLoader.cs
Normal file
47
SushiBar/SushiBarContracts/DI/ServiceProviderLoader.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace SushiBarContracts.DI;
|
||||
|
||||
public static partial class ServiceProviderLoader
|
||||
{
|
||||
public static IImplementationExtension? GetImplementationExtensions()
|
||||
{
|
||||
IImplementationExtension? source = null;
|
||||
var files =
|
||||
Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll",
|
||||
SearchOption.AllDirectories);
|
||||
foreach (var file in files.Distinct())
|
||||
{
|
||||
var asm = Assembly.LoadFrom(file);
|
||||
foreach (var t in asm.GetExportedTypes())
|
||||
{
|
||||
if (!t.IsClass || !typeof(IImplementationExtension).IsAssignableFrom(t)) continue;
|
||||
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)
|
||||
.All(x => x.Name != "ImplementationExtensions"))
|
||||
{
|
||||
directory = directory.Parent;
|
||||
}
|
||||
return $"{directory?.FullName}\\ImplementationExtensions";
|
||||
}
|
||||
}
|
37
SushiBar/SushiBarContracts/DI/UnityDependencyContainer.cs
Normal file
37
SushiBar/SushiBarContracts/DI/UnityDependencyContainer.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace SushiBarContracts.StoragesContracts;
|
||||
|
||||
public interface IBackUpInfo
|
||||
{
|
||||
List<T>? GetList<T>() where T : class, new();
|
||||
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||
}
|
@ -10,4 +10,16 @@
|
||||
<ProjectReference Include="..\SushiBarModels\SushiBarDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<HintPath>..\..\..\..\..\..\..\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.8\System.Windows.Forms.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,15 +1,16 @@
|
||||
using System.ComponentModel;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarContracts.ViewModels;
|
||||
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[DisplayName("FIO client")]
|
||||
[Column("FIO client", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFio { get; set; } = string.Empty;
|
||||
[DisplayName("Email")]
|
||||
[Column("Email", width: 150)]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Password")]
|
||||
[Column("Password", width : 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using SushiBarContracts.Attributes;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class ComponentViewModel : IComponentModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Name of Component")]
|
||||
[Column("Name of Component", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Cost")]
|
||||
[Column("Cost", width: 80)]
|
||||
public double Cost { get; set; }
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
using System.ComponentModel;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarContracts.ViewModels;
|
||||
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
[Column(visible : false)]
|
||||
public int Id { get; init; }
|
||||
|
||||
[DisplayName("Implementer FIO")]
|
||||
[Column("Implementer FIO", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ImplementerFio { get; set; } = string.Empty;
|
||||
|
||||
[Column("Password", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Work Experience")]
|
||||
[Column("Work Experience", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DisplayName("Qualification")]
|
||||
[Column("Qualification", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Qualification { get; set; }
|
||||
}
|
@ -1,16 +1,22 @@
|
||||
using System.ComponentModel;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarContracts.ViewModels;
|
||||
|
||||
public class MessageInfoViewModel : IMessageInfoModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public string MessageId { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int? ClientId { get; set; }
|
||||
[DisplayName("Sender name")]
|
||||
[Column("Sender name", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
|
||||
public string SenderName { get; set; }
|
||||
[DisplayName("Date delivery")]
|
||||
[Column("Date delivery", width: 100)]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
[Column("Subject", width:150)]
|
||||
public string Subject { get; set; }
|
||||
[Column("Body", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string Body { get; set; }
|
||||
[Column(visible:false)]
|
||||
public int Id { get; }
|
||||
}
|
@ -1,40 +1,43 @@
|
||||
using SushiBarDataModels.Enums;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using SushiBarContracts.Attributes;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[DisplayName("Number")]
|
||||
[Column("Number", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Id { get; init; }
|
||||
|
||||
[Column(visible:false)]
|
||||
public int SushiId { get; init; }
|
||||
[Column(visible:false)]
|
||||
public int ClientId { get; init; }
|
||||
[Column(visible:false)]
|
||||
public int? ImplementerId { get; set; }
|
||||
|
||||
[DisplayName("Client FIO")]
|
||||
[Column("Client FIO", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFio { get; init; } = string.Empty;
|
||||
|
||||
[DisplayName("Implementer FIO")]
|
||||
[Column("Implementer FIO", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ImplementerFio { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Name of Product")]
|
||||
[Column("Name of Product", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public string SushiName { get; init; } = string.Empty;
|
||||
|
||||
[DisplayName("Count")]
|
||||
[Column("Count", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Count { get; set; }
|
||||
|
||||
[DisplayName("Sum")]
|
||||
[Column("Sum", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public double Sum { get; set; }
|
||||
|
||||
[DisplayName("Status")]
|
||||
[Column("Status", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
|
||||
|
||||
[DisplayName("Date Create")]
|
||||
[Column("Date Create", width:100)]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
[DisplayName("Date Implement")]
|
||||
[Column("Date Implement", width:100)]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace SushiBarContracts.ViewModels
|
||||
using SushiBarContracts.Attributes;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class ReportOrdersViewModel
|
||||
{
|
||||
|
@ -1,17 +1,20 @@
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using SushiBarContracts.Attributes;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class SushiViewModel : ISushiModel
|
||||
{
|
||||
[Column(visible:false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Name of Product")]
|
||||
[Column("Name of Product", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Cost")]
|
||||
[Column("Cost", width:100)]
|
||||
public double Price { get; set; }
|
||||
[Column(visible:false)]
|
||||
public Dictionary<int, (IComponentModel, int)> SushiComponents { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
using SushiBarContracts.DI;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarDatabaseImplement.Implements;
|
||||
|
||||
namespace SushiBarDatabaseImplement;
|
||||
|
||||
public class DatabaseImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 2;
|
||||
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
26
SushiBar/SushiBarDatabaseImplement/Implements/BackUpInfo.cs
Normal file
26
SushiBar/SushiBarDatabaseImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Implements;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,18 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models;
|
||||
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private init; }
|
||||
[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;
|
||||
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
|
@ -3,55 +3,59 @@ using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
namespace SushiBarDatabaseImplement.Models;
|
||||
|
||||
[DataContract]
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Cost { get; set; }
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<SushiComponent> SushiComponent { get; set; } = new();
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<SushiComponent> SushiComponent { get; set; } = new();
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
if (model == null)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Component()
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
return null;
|
||||
}
|
||||
public static Component Create(ComponentViewModel model)
|
||||
return new Component()
|
||||
{
|
||||
return new Component
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public void Update(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ComponentName = model.ComponentName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public ComponentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
public static Component Create(ComponentViewModel model)
|
||||
{
|
||||
return new Component
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public void Update(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ComponentName = model.ComponentName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public ComponentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost
|
||||
};
|
||||
|
||||
}
|
@ -1,17 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models;
|
||||
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private init; }
|
||||
[Required] public string ImplementerFio { get; private set; } = string.Empty;
|
||||
[Required] public string Password { get; private set; } = string.Empty;
|
||||
public int WorkExperience { get; private set; }
|
||||
public int Qualification { get; private set; }
|
||||
[Required] [DataMember] public string ImplementerFio { get; private set; } = string.Empty;
|
||||
[Required] [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(ImplementerBindingModel? model)
|
||||
{
|
||||
|
@ -1,18 +1,23 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models;
|
||||
|
||||
[DataContract]
|
||||
public class Message : IMessageInfoModel
|
||||
{
|
||||
[Key]
|
||||
[DataMember]
|
||||
public string MessageId { get; private set; } = string.Empty;
|
||||
public int? ClientId { get; private set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string SenderName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||
[Required]
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
@ -47,4 +52,6 @@ public class Message : IMessageInfoModel
|
||||
SenderName = SenderName,
|
||||
DateDelivery = DateDelivery,
|
||||
};
|
||||
|
||||
public int Id { get; }
|
||||
}
|
@ -3,100 +3,109 @@ using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Enums;
|
||||
using SushiBarDataModels.Models;
|
||||
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; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int SushiId { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int ClientId { get; private set; }
|
||||
[DataMember]
|
||||
public int? ImplementerId { get; private set; }
|
||||
[DataMember]
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Count { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Sum { get; private set; }
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Unknown;
|
||||
|
||||
[Required]
|
||||
[DataMember]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public virtual Sushi Sushi { get; set; }
|
||||
|
||||
public virtual Client Client { get; set; }
|
||||
|
||||
public virtual Implementer? Implementer { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int SushiId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public int? ImplementerId { get; private set; } = null;
|
||||
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
|
||||
[Required]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Unknown;
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public virtual Sushi Sushi { get; set; }
|
||||
|
||||
public virtual Client Client { get; set; }
|
||||
|
||||
public virtual Implementer? Implementer { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
if (model == null)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Order
|
||||
{
|
||||
Id = model.Id,
|
||||
SushiId = model.SushiId,
|
||||
SushiName = model.SushiName,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement
|
||||
};
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
return new Order
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SushiId = model.SushiId;
|
||||
SushiName = model.SushiName;
|
||||
ClientId = model.ClientId;
|
||||
ImplementerId = model.ImplementerId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel { get
|
||||
{
|
||||
var context = new SushiBarDatabase();
|
||||
return new OrderViewModel
|
||||
{
|
||||
Id = Id,
|
||||
ClientId = ClientId,
|
||||
SushiId = SushiId,
|
||||
Count = Count,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ImplementerId = ImplementerId,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
ClientFio = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFio ?? string.Empty,
|
||||
SushiName = context.Sushi.FirstOrDefault(x => x.Id == SushiId)?.SushiName ?? string.Empty,
|
||||
ImplementerFio = context.Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFio ?? string.Empty,
|
||||
};
|
||||
} }
|
||||
Id = model.Id,
|
||||
SushiId = model.SushiId,
|
||||
SushiName = model.SushiName,
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SushiId = model.SushiId;
|
||||
SushiName = model.SushiName;
|
||||
ClientId = model.ClientId;
|
||||
ImplementerId = model.ImplementerId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel { get
|
||||
{
|
||||
var context = new SushiBarDatabase();
|
||||
return new OrderViewModel
|
||||
{
|
||||
Id = Id,
|
||||
ClientId = ClientId,
|
||||
SushiId = SushiId,
|
||||
Count = Count,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ImplementerId = ImplementerId,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
ClientFio = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFio ?? string.Empty,
|
||||
SushiName = context.Sushi.FirstOrDefault(x => x.Id == SushiId)?.SushiName ?? string.Empty,
|
||||
ImplementerFio = context.Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFio ?? string.Empty,
|
||||
};
|
||||
} }
|
||||
}
|
@ -1,88 +1,92 @@
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
public class Sushi : ISushiModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
private Dictionary<int, (IComponentModel, int)>? _sushiComponents = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> SushiComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
_sushiComponents ??= Components
|
||||
.ToDictionary(recPC => recPC.ComponentId, recPC =>
|
||||
(recPC.Component as IComponentModel, recPC.Count));
|
||||
return _sushiComponents;
|
||||
}
|
||||
}
|
||||
[ForeignKey("SushiId")]
|
||||
public virtual List<SushiComponent> Components { get; set; } = new();
|
||||
[ForeignKey("SushiId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public static Sushi Create(SushiBarDatabase context, SushiBindingModel model)
|
||||
{
|
||||
return new Sushi()
|
||||
{
|
||||
Id = model.Id,
|
||||
SushiName = model.SushiName,
|
||||
Price = model.Price,
|
||||
Components = model.SushiComponents.Select(x => new SushiComponent
|
||||
{
|
||||
Component = context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(SushiBindingModel model)
|
||||
{
|
||||
SushiName = model.SushiName;
|
||||
Price = model.Price;
|
||||
}
|
||||
public SushiViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
SushiName = SushiName,
|
||||
Price = Price,
|
||||
SushiComponents = SushiComponents
|
||||
};
|
||||
public void UpdateComponents(SushiBarDatabase context, SushiBindingModel model)
|
||||
{
|
||||
var sushiComponents = context.SushiComponents.Where(rec => rec.SushiId == model.Id).ToList();
|
||||
if (sushiComponents != null && sushiComponents.Count > 0)
|
||||
{
|
||||
context.SushiComponents.RemoveRange(sushiComponents.Where(rec => !model.SushiComponents.ContainsKey(rec.ComponentId)));
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateComponent in sushiComponents)
|
||||
{
|
||||
updateComponent.Count = model.SushiComponents[updateComponent.ComponentId].Item2;
|
||||
model.SushiComponents.Remove(updateComponent.ComponentId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var sushi = context.Sushi.First(x => x.Id == Id);
|
||||
foreach (var pc in model.SushiComponents)
|
||||
{
|
||||
context.SushiComponents.Add(new SushiComponent
|
||||
{
|
||||
Sushi = sushi,
|
||||
Component = context.Components.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_sushiComponents = null;
|
||||
}
|
||||
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, (IComponentModel, int)>? _sushiComponents = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> SushiComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
_sushiComponents ??= Components
|
||||
.ToDictionary(recPC => recPC.ComponentId, recPC =>
|
||||
(recPC.Component as IComponentModel, recPC.Count));
|
||||
return _sushiComponents;
|
||||
}
|
||||
}
|
||||
}
|
||||
[ForeignKey("SushiId")]
|
||||
public virtual List<SushiComponent> Components { get; set; } = new();
|
||||
[ForeignKey("SushiId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public static Sushi Create(SushiBarDatabase context, SushiBindingModel model)
|
||||
{
|
||||
return new Sushi()
|
||||
{
|
||||
Id = model.Id,
|
||||
SushiName = model.SushiName,
|
||||
Price = model.Price,
|
||||
Components = model.SushiComponents.Select(x => new SushiComponent
|
||||
{
|
||||
Component = context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(SushiBindingModel model)
|
||||
{
|
||||
SushiName = model.SushiName;
|
||||
Price = model.Price;
|
||||
}
|
||||
public SushiViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
SushiName = SushiName,
|
||||
Price = Price,
|
||||
SushiComponents = SushiComponents
|
||||
};
|
||||
public void UpdateComponents(SushiBarDatabase context, SushiBindingModel model)
|
||||
{
|
||||
var sushiComponents = context.SushiComponents.Where(rec => rec.SushiId == model.Id).ToList();
|
||||
if (sushiComponents != null && sushiComponents.Count > 0)
|
||||
{
|
||||
context.SushiComponents.RemoveRange(sushiComponents.Where(rec => !model.SushiComponents.ContainsKey(rec.ComponentId)));
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateComponent in sushiComponents)
|
||||
{
|
||||
updateComponent.Count = model.SushiComponents[updateComponent.ComponentId].Item2;
|
||||
model.SushiComponents.Remove(updateComponent.ComponentId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var sushi = context.Sushi.First(x => x.Id == Id);
|
||||
foreach (var pc in model.SushiComponents)
|
||||
{
|
||||
context.SushiComponents.Add(new SushiComponent
|
||||
{
|
||||
Sushi = sushi,
|
||||
Component = context.Components.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_sushiComponents = null;
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
namespace SushiBarDatabaseImplement.Models;
|
||||
|
||||
public class SushiComponent
|
||||
{
|
||||
public class SushiComponent
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int SushiId { get; set; }
|
||||
[Required]
|
||||
public int ComponentId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Component Component { get; set; } = new();
|
||||
public virtual Sushi Sushi { get; set; } = new();
|
||||
}
|
||||
}
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int SushiId { get; set; }
|
||||
[Required]
|
||||
public int ComponentId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Component Component { get; set; } = new();
|
||||
public virtual Sushi Sushi { get; set; } = new();
|
||||
}
|
@ -19,4 +19,8 @@
|
||||
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
@ -66,4 +66,6 @@ public class Message : IMessageInfoModel
|
||||
new XAttribute("SenderName", SenderName),
|
||||
new XAttribute("DateDelivery", DateDelivery)
|
||||
);
|
||||
|
||||
public int Id { get; }
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
namespace SushiBarDataModels.Models;
|
||||
|
||||
public interface IMessageInfoModel
|
||||
public interface IMessageInfoModel : IId
|
||||
{
|
||||
string MessageId { get; }
|
||||
int? ClientId { get; }
|
||||
|
17
SushiBar/SushibarListImplement/Implements/BackUpInfo.cs
Normal file
17
SushiBar/SushibarListImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
39
SushiBar/SushibarListImplement/Implements/ClientStorage.cs
Normal file
39
SushiBar/SushibarListImplement/Implements/ClientStorage.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushibarListImplement.Implements;
|
||||
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel? model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using SushiBarContracts.DI;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushibarListImplement.Implements;
|
||||
|
||||
namespace SushibarListImplement;
|
||||
|
||||
public class ListImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 0;
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||
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>();
|
||||
}
|
||||
}
|
@ -39,4 +39,6 @@ public class Message : IMessageInfoModel
|
||||
ClientId = ClientId,
|
||||
MessageId = MessageId
|
||||
};
|
||||
|
||||
public int Id { get; }
|
||||
}
|
@ -11,4 +11,8 @@
|
||||
<ProjectReference Include="..\SushiBarModels\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