This commit is contained in:
Николай 2023-03-12 12:32:12 +04:00
parent 512d2741d5
commit 33316f60a6
6 changed files with 26 additions and 26 deletions

View File

@ -8,7 +8,7 @@ namespace FoodOrdersView
public partial class FormComponent : Form public partial class FormComponent : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IComponentLogic _logic; private readonly IComponentLogic _logicC;
private int? _id; private int? _id;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
@ -16,7 +16,7 @@ namespace FoodOrdersView
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logicC = logic;
} }
private void FormComponent_Load(object sender, EventArgs e) private void FormComponent_Load(object sender, EventArgs e)
@ -26,7 +26,7 @@ namespace FoodOrdersView
try try
{ {
_logger.LogInformation("Получение блюда"); _logger.LogInformation("Получение блюда");
var view = _logic.ReadElement(new ComponentSearchModel var view = _logicC.ReadElement(new ComponentSearchModel
{ {
Id = _id.Value Id = _id.Value
}); });
@ -61,7 +61,7 @@ namespace FoodOrdersView
ComponentName = textBoxName.Text, ComponentName = textBoxName.Text,
Cost = Convert.ToDouble(textBoxCost.Text) Cost = Convert.ToDouble(textBoxCost.Text)
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logicC.Update(model) : _logicC.Create(model);
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");

View File

@ -7,12 +7,12 @@ namespace FoodOrdersView
public partial class FormComponents : Form public partial class FormComponents : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IComponentLogic _logic; private readonly IComponentLogic _logicC;
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic) public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logicC = logic;
} }
private void FormComponents_Load(object sender, EventArgs e) private void FormComponents_Load(object sender, EventArgs e)
{ {
@ -22,7 +22,7 @@ namespace FoodOrdersView
{ {
try try
{ {
var list = _logic.ReadList(null); var list = _logicC.ReadList(null);
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
@ -74,7 +74,7 @@ namespace FoodOrdersView
_logger.LogInformation("Удаление блюда"); _logger.LogInformation("Удаление блюда");
try try
{ {
if (!_logic.Delete(new ComponentBindingModel { Id = id })) if (!_logicC.Delete(new ComponentBindingModel { Id = id }))
{ {
throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
} }

View File

@ -8,13 +8,13 @@ namespace FoodOrdersView
public partial class FormCreateOrder : Form public partial class FormCreateOrder : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDishLogic _logicS; private readonly IDishLogic _logicD;
private readonly IOrderLogic _logicO; private readonly IOrderLogic _logicO;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IDishLogic logicS, IOrderLogic logicO) public FormCreateOrder(ILogger<FormCreateOrder> logger, IDishLogic logicS, IOrderLogic logicO)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logicS = logicS; _logicD = logicS;
_logicO = logicO; _logicO = logicO;
} }
private void FormCreateOrder_Load(object sender, EventArgs e) private void FormCreateOrder_Load(object sender, EventArgs e)
@ -22,7 +22,7 @@ namespace FoodOrdersView
_logger.LogInformation("Загрузка Набор блюд для заказа"); _logger.LogInformation("Загрузка Набор блюд для заказа");
try try
{ {
var list = _logicS.ReadList(null); var list = _logicD.ReadList(null);
if (list != null) if (list != null)
{ {
comboBoxDish.DisplayMember = "DishName"; comboBoxDish.DisplayMember = "DishName";
@ -45,7 +45,7 @@ namespace FoodOrdersView
try try
{ {
int id = Convert.ToInt32(comboBoxDish.SelectedValue); int id = Convert.ToInt32(comboBoxDish.SelectedValue);
var product = _logicS.ReadElement(new DishSearchModel { Id = id }); var product = _logicD.ReadElement(new DishSearchModel { Id = id });
int count = Convert.ToInt32(textBoxCount.Text); int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString(); textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
_logger.LogInformation("Расчет суммы заказа"); _logger.LogInformation("Расчет суммы заказа");

View File

@ -9,7 +9,7 @@ namespace FoodOrdersView
public partial class FormDish : Form public partial class FormDish : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDishLogic _logic; private readonly IDishLogic _logicD;
private int? _id; private int? _id;
private Dictionary<int, (IComponentModel, int)> _dishComponents; private Dictionary<int, (IComponentModel, int)> _dishComponents;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
@ -17,7 +17,7 @@ namespace FoodOrdersView
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logicD = logic;
_dishComponents = new Dictionary<int, (IComponentModel, int)>(); _dishComponents = new Dictionary<int, (IComponentModel, int)>();
} }
private void FormDish_Load(object sender, EventArgs e) private void FormDish_Load(object sender, EventArgs e)
@ -27,7 +27,7 @@ namespace FoodOrdersView
_logger.LogInformation("Загрузка набор блюд"); _logger.LogInformation("Загрузка набор блюд");
try try
{ {
var view = _logic.ReadElement(new DishSearchModel var view = _logicD.ReadElement(new DishSearchModel
{ {
Id = _id.Value Id = _id.Value
}); });
@ -171,7 +171,7 @@ namespace FoodOrdersView
Price = Convert.ToDouble(textBoxPrice.Text), Price = Convert.ToDouble(textBoxPrice.Text),
DishComponents = _dishComponents DishComponents = _dishComponents
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logicD.Update(model) : _logicD.Create(model);
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");

View File

@ -7,12 +7,12 @@ namespace FoodOrdersView
public partial class FormDishes : Form public partial class FormDishes : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDishLogic _logic; private readonly IDishLogic _logicD;
public FormDishes(ILogger<FormDishes> logger, IDishLogic logic) public FormDishes(ILogger<FormDishes> logger, IDishLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logicD = logic;
} }
private void FormDocuments_Load(object sender, EventArgs e) private void FormDocuments_Load(object sender, EventArgs e)
@ -23,7 +23,7 @@ namespace FoodOrdersView
{ {
try try
{ {
var list = _logic.ReadList(null); var list = _logicD.ReadList(null);
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
@ -78,7 +78,7 @@ namespace FoodOrdersView
_logger.LogInformation("Удаление набор блюд"); _logger.LogInformation("Удаление набор блюд");
try try
{ {
if (!_logic.Delete(new DishBindingModel if (!_logicD.Delete(new DishBindingModel
{ {
Id = id Id = id
})) }))

View File

@ -8,12 +8,12 @@ namespace FoodOrdersView
public partial class FormMain : Form public partial class FormMain : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _logicO;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic) public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _logicO = orderLogic;
} }
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
{ {
@ -24,7 +24,7 @@ namespace FoodOrdersView
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
try try
{ {
var list = _orderLogic.ReadList(null); var list = _logicO.ReadList(null);
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
@ -71,7 +71,7 @@ namespace FoodOrdersView
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try try
{ {
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel var operationResult = _logicO.TakeOrderInWork(new OrderBindingModel
{ {
Id = id, Id = id,
DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value),
@ -101,7 +101,7 @@ namespace FoodOrdersView
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try try
{ {
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel var operationResult = _logicO.FinishOrder(new OrderBindingModel
{ {
Id = id, Id = id,
DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value),
@ -131,7 +131,7 @@ namespace FoodOrdersView
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try try
{ {
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel var operationResult = _logicO.DeliveryOrder(new OrderBindingModel
{ {
Id = id, Id = id,
DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value),