one step is required
This commit is contained in:
parent
fe06793f3c
commit
8fdc5bc1cc
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
|
||||||
namespace SushiBar
|
namespace SushiBar
|
||||||
{
|
{
|
||||||
@ -18,57 +19,48 @@ namespace SushiBar
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
if (service is FormComponent form)
|
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)
|
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));
|
LoadData();
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
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);
|
throw new Exception("Error on deleting. Additional info below.");
|
||||||
_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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error delete component");
|
||||||
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
|
||||||
namespace SushiBar
|
namespace SushiBar
|
||||||
{
|
{
|
||||||
@ -17,29 +18,22 @@ namespace SushiBar
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
if (service is FormImplementer form)
|
if (service.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
LoadData();
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
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>();
|
||||||
|
if (service == null) return;
|
||||||
|
service.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (service.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
LoadData();
|
||||||
if (service is FormImplementer form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarBusinessLogic.BusinessLogics;
|
using SushiBarBusinessLogic.BusinessLogics;
|
||||||
|
using SushiBarContracts.Attributes;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
using SushiBarDataModels.Enums;
|
using SushiBarDataModels.Enums;
|
||||||
|
|
||||||
namespace SushiBar
|
namespace SushiBar
|
||||||
@ -32,33 +34,14 @@ namespace SushiBar
|
|||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Load components");
|
_logger.LogInformation("Load components");
|
||||||
try
|
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
if (service is FormCreateOrder form)
|
service.ShowDialog();
|
||||||
{
|
LoadData();
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSubmit_Click(object sender, EventArgs e)
|
private void ButtonSubmit_Click(object sender, EventArgs e)
|
||||||
@ -96,67 +79,63 @@ namespace SushiBar
|
|||||||
|
|
||||||
private void ButtonReady_Click(object sender, EventArgs e)
|
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);
|
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel {
|
||||||
_logger.LogInformation("Order №{id}. Change status on -Ready",id);
|
Id = id,
|
||||||
try
|
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 {
|
throw new Exception("Error on saving. Additional info below.");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
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)
|
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);
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel {
|
||||||
_logger.LogInformation("Order №{id}. Change status on -Issued", id);
|
Id = id,
|
||||||
try
|
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 {
|
throw new Exception("Error on saving. Additional info below.");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,85 +151,61 @@ namespace SushiBar
|
|||||||
|
|
||||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var service = DependencyManager.Instance.Resolve<FormComponents>();
|
||||||
if (service is FormComponents form)
|
service.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SushiToolStripMenuItem_Click(object sender, EventArgs e)
|
private void SushiToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiMoreThenOne));
|
var service = DependencyManager.Instance.Resolve<FormSushiMoreThenOne>();
|
||||||
|
service.ShowDialog();
|
||||||
if (service is FormSushiMoreThenOne form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ListComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
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
|
||||||
{
|
});
|
||||||
FileName = dialog.FileName
|
MessageBox.Show("Complete", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
});
|
|
||||||
MessageBox.Show("Complete", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComponentsOnSushiToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComponentsOnSushiToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiOnComponents));
|
var service = DependencyManager.Instance.Resolve<FormSushiOnComponents>();
|
||||||
if (service is FormSushiOnComponents form)
|
service.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ListOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
var service = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||||
if (service is FormReportOrders form)
|
service.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
var service = DependencyManager.Instance.Resolve<FormClients>();
|
||||||
if (service is FormClients form)
|
service.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
private void StartWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
||||||
MessageBox.Show("Process work is started", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Process work is started", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
var service = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||||
if (service is FormImplementers form)
|
service.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MailsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void MailsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
|
var service = DependencyManager.Instance.Resolve<FormMails>();
|
||||||
if (service is FormMails form)
|
service.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateBackupStripMenuItem_Click(object sender, EventArgs e)
|
private void CreateBackupStripMenuItem_Click(object sender, EventArgs e)
|
||||||
@ -266,7 +221,6 @@ namespace SushiBar
|
|||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
@ -27,15 +28,13 @@ namespace SushiBar
|
|||||||
_logger.LogInformation("Load components");
|
_logger.LogInformation("Load components");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_sushiComponents != null)
|
if (_sushiComponents == null) return;
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var pc in _sushiComponents)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||||
foreach (var pc in _sushiComponents)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
|
||||||
}
|
|
||||||
textBoxPrice.Text = CalcPrice().ToString();
|
|
||||||
}
|
}
|
||||||
|
textBoxPrice.Text = CalcPrice().ToString();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -82,7 +81,7 @@ namespace SushiBar
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
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 (service is FormSushiComponent form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -109,7 +108,7 @@ namespace SushiBar
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent));
|
var service = DependencyManager.Instance.Resolve<FormSushiComponent>();
|
||||||
if (service is FormSushiComponent form)
|
if (service is FormSushiComponent form)
|
||||||
{
|
{
|
||||||
int id =
|
int id =
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.DI;
|
||||||
|
|
||||||
namespace SushiBar
|
namespace SushiBar
|
||||||
{
|
{
|
||||||
@ -38,7 +39,7 @@ namespace SushiBar
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
|
var service = DependencyManager.Instance.Resolve<FormSushi>();
|
||||||
if (service is FormSushi form)
|
if (service is FormSushi form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -52,7 +53,7 @@ namespace SushiBar
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSushi));
|
var service = DependencyManager.Instance.Resolve<FormSushi>();
|
||||||
if (service is FormSushi form)
|
if (service is FormSushi form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using SushiBarBusinessLogic.BusinessLogics;
|
using SushiBarBusinessLogic.BusinessLogics;
|
||||||
@ -7,26 +6,20 @@ using SushiBarBusinessLogic.OfficePackage;
|
|||||||
using SushiBarBusinessLogic.OfficePackage.Implements;
|
using SushiBarBusinessLogic.OfficePackage.Implements;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
using SushiBarContracts.StoragesContracts;
|
using SushiBarContracts.DI;
|
||||||
using SushiBarDatabaseImplement.Implements;
|
|
||||||
|
|
||||||
namespace SushiBar
|
namespace SushiBar
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static ServiceProvider? _serviceProvider;
|
|
||||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
var services = new ServiceCollection();
|
InitDependency();
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||||
mailSender?.MailConfig(new MailConfigBindingModel
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
{
|
{
|
||||||
MailLogin =
|
MailLogin =
|
||||||
@ -49,56 +42,54 @@ namespace SushiBar
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
logger?.LogError(ex, "Error on working w/ email");
|
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.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ISushiStorage, SushiStorage>();
|
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageStorage>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
services.AddTransient<ISushiLogic, SushiLogic>();
|
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<IBackUpLogic, BackUpLogic>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<FormSushi>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<FormSushiComponent>();
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<FormSushiMoreThenOne>();
|
||||||
services.AddTransient<FormComponent>();
|
DependencyManager.Instance.RegisterType<FormSushiOnComponents>();
|
||||||
services.AddTransient<FormComponents>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
services.AddTransient<FormSushi>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
services.AddTransient<FormSushiComponent>();
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
services.AddTransient<FormSushiMoreThenOne>();
|
DependencyManager.Instance.RegisterType<FormMails>();
|
||||||
services.AddTransient<FormReportOrders>();
|
|
||||||
services.AddTransient<FormSushiOnComponents>();
|
|
||||||
services.AddTransient<FormClients>();
|
|
||||||
services.AddTransient<FormImplementers>();
|
|
||||||
services.AddTransient<FormImplementer>();
|
|
||||||
services.AddTransient<FormMails>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) =>
|
||||||
|
DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,4 +10,5 @@ public class MessageInfoBindingModel : IMessageInfoModel
|
|||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
public int Id { get; }
|
||||||
}
|
}
|
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>()!;
|
||||||
|
}
|
||||||
|
}
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
<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>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
using System.ComponentModel;
|
using SushiBarContracts.Attributes;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels;
|
namespace SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("FIO client")]
|
[Column("FIO client", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ClientFio { get; set; } = string.Empty;
|
public string ClientFio { get; set; } = string.Empty;
|
||||||
[DisplayName("Email")]
|
[Column("Email", width: 150)]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[DisplayName("Password")]
|
[Column("Password", width : 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
@ -1,16 +1,15 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel;
|
using SushiBarContracts.Attributes;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ComponentViewModel : IComponentModel
|
public class ComponentViewModel : IComponentModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[Column("Name of Component", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("Name of Component")]
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
[Column("Cost", width: 80)]
|
||||||
[DisplayName("Cost")]
|
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using SushiBarContracts.Attributes;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels;
|
namespace SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible : false)]
|
||||||
public int Id { get; init; }
|
public int Id { get; init; }
|
||||||
|
[Column("Implementer FIO", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("Implementer FIO")]
|
|
||||||
public string ImplementerFio { get; set; } = string.Empty;
|
public string ImplementerFio { get; set; } = string.Empty;
|
||||||
|
[Column("Password", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
[Column("Work Experience", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
[DisplayName("Work Experience")]
|
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
[Column("Qualification", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
[DisplayName("Qualification")]
|
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
@ -1,16 +1,22 @@
|
|||||||
using System.ComponentModel;
|
using SushiBarContracts.Attributes;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels;
|
namespace SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public string MessageId { get; set; }
|
public string MessageId { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
[DisplayName("Sender name")]
|
[Column("Sender name", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
|
||||||
public string SenderName { get; set; }
|
public string SenderName { get; set; }
|
||||||
[DisplayName("Date delivery")]
|
[Column("Date delivery", width: 100)]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
[Column("Subject", width:150)]
|
||||||
public string Subject { get; set; }
|
public string Subject { get; set; }
|
||||||
|
[Column("Body", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Body { get; set; }
|
public string Body { get; set; }
|
||||||
|
[Column(visible:false)]
|
||||||
|
public int Id { get; }
|
||||||
}
|
}
|
@ -1,40 +1,43 @@
|
|||||||
using SushiBarDataModels.Enums;
|
using SushiBarDataModels.Enums;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using SushiBarContracts.Attributes;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[DisplayName("Number")]
|
[Column("Number", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int Id { get; init; }
|
public int Id { get; init; }
|
||||||
|
[Column(visible:false)]
|
||||||
public int SushiId { get; init; }
|
public int SushiId { get; init; }
|
||||||
|
[Column(visible:false)]
|
||||||
public int ClientId { get; init; }
|
public int ClientId { get; init; }
|
||||||
|
[Column(visible:false)]
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Client FIO")]
|
[Column("Client FIO", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ClientFio { get; init; } = string.Empty;
|
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;
|
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;
|
public string SushiName { get; init; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Count")]
|
[Column("Count", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
[DisplayName("Sum")]
|
[Column("Sum", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
[DisplayName("Status")]
|
[Column("Status", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
|
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
|
||||||
|
|
||||||
[DisplayName("Date Create")]
|
[Column("Date Create", width:100)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
[DisplayName("Date Implement")]
|
[Column("Date Implement", width:100)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace SushiBarContracts.ViewModels
|
using SushiBarContracts.Attributes;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ReportOrdersViewModel
|
public class ReportOrdersViewModel
|
||||||
{
|
{
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using SushiBarContracts.Attributes;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class SushiViewModel : ISushiModel
|
public class SushiViewModel : ISushiModel
|
||||||
{
|
{
|
||||||
|
[Column(visible:false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("Name of Product")]
|
[Column("Name of Product", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string SushiName { get; set; } = string.Empty;
|
public string SushiName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Cost")]
|
[Column("Cost", width:100)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
[Column(visible:false)]
|
||||||
public Dictionary<int, (IComponentModel, int)> SushiComponents { get; set; } = new();
|
public Dictionary<int, (IComponentModel, int)> SushiComponents { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,4 +47,6 @@ public class Message : IMessageInfoModel
|
|||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public int Id { get; }
|
||||||
}
|
}
|
@ -66,4 +66,6 @@ public class Message : IMessageInfoModel
|
|||||||
new XAttribute("SenderName", SenderName),
|
new XAttribute("SenderName", SenderName),
|
||||||
new XAttribute("DateDelivery", DateDelivery)
|
new XAttribute("DateDelivery", DateDelivery)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public int Id { get; }
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
namespace SushiBarDataModels.Models;
|
namespace SushiBarDataModels.Models;
|
||||||
|
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
int? ClientId { 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,
|
ClientId = ClientId,
|
||||||
MessageId = MessageId
|
MessageId = MessageId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public int Id { get; }
|
||||||
}
|
}
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\SushiBarModels\SushiBarDataModels.csproj" />
|
<ProjectReference Include="..\SushiBarModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user