вроде всё
This commit is contained in:
parent
d0e74d8b3a
commit
005c8c0b3e
@ -30,8 +30,7 @@ namespace FoodOrdersView
|
|||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
ConfigureServices(services);
|
ConfigureServices(services);
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||||
@ -53,6 +52,8 @@ namespace FoodOrdersView
|
|||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = _serviceProvider.GetService<ILogger>();
|
||||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
@ -63,13 +63,14 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
model.Status = OrderStatus.Принят;
|
model.Status = OrderStatus.Принят;
|
||||||
if (_orderStorage.Insert(model) == null)
|
var order = _orderStorage.Insert(model);
|
||||||
|
if (order == null)
|
||||||
{
|
{
|
||||||
model.Status = OrderStatus.Неизвестен;
|
model.Status = OrderStatus.Неизвестен;
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SendToClient(model.ClientId, $"Заказ №{model.Id}", $"Заказ №{model.Id} от {model.DateCreate} на сумму {model.Sum} был создан.");
|
SendToClient(order.ClientId, $"Заказ №{order.Id}", $"Заказ №{order.Id} от {order.DateCreate} на сумму {order.Sum} принят.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,21 +144,23 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
model.DateImplement = viewModel.DateImplement;
|
model.DateImplement = viewModel.DateImplement;
|
||||||
}
|
}
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
if (_orderStorage.Update(model) == null)
|
var order = _orderStorage.Update(model);
|
||||||
|
if (order == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Change status operation failed");
|
_logger.LogWarning("Change status operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SendToClient(model.ClientId, $"Заказ №{model.Id}", $"У заказа №{model.Id} изменен статус на {model.Status}.");
|
|
||||||
|
SendToClient(order.ClientId, $"Заказ №{order.Id}", $"У заказа №{order.Id} изменен статус на {order.Status}.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendToClient(int clientId, string subject, string text)
|
private bool SendToClient(int clientId, string subject, string text)
|
||||||
{
|
{
|
||||||
var client = _clientLogic.ReadElement(new() { Id = clientId });
|
var client = _clientLogic.ReadElement(new() { Id = clientId });
|
||||||
if (client == null)
|
if (client == null)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
_mailWorker.MailSendAsync(new()
|
_mailWorker.MailSendAsync(new()
|
||||||
{
|
{
|
||||||
@ -165,6 +168,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
Subject = subject,
|
Subject = subject,
|
||||||
Text = text
|
Text = text
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
using FoodOrdersContracts.BindingModels;
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
using FoodOrdersContracts.BusinessLogicsContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Net.Mail;
|
||||||
|
|
||||||
namespace FoodOrdersBusinessLogic.MailWorker
|
namespace FoodOrdersBusinessLogic.MailWorker
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user