Лаб_2сложн

This commit is contained in:
yuliya.mavrina@internet.ru 2024-04-23 15:48:49 +03:00
parent 21a3fe7c63
commit 14c5a5991c

View File

@ -49,14 +49,15 @@ namespace RenovationWorkBusinessLogic.BusinessLogics
}
private bool StatusUpdate(OrderBindingModel model, OrderStatus status)
{
CheckModel(model);
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (element == null)
{
_logger.LogWarning("Read operation failed");
return false;
}
if (element.Status != status - 1)
CheckModel(element);
if (element.Status != status - 1)
{
_logger.LogWarning("Status change operation failed");
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
@ -130,7 +131,31 @@ namespace RenovationWorkBusinessLogic.BusinessLogics
}
_logger.LogInformation("Order. Count: {Count}. Sum: {Sum}. Id: {Id}", model.Count, model.Sum, model.Id);
}
private bool CheckSupply(IRepairModel repair, int count)
private void CheckModel(OrderViewModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.RepairId < 0)
{
throw new ArgumentNullException("Некорректный идентификатор документа", nameof(model.RepairId));
}
if (model.Count <= 0)
{
throw new ArgumentNullException("Количество работ в заказе должно быть больше 0", nameof(model.Count));
}
if (model.Sum <= 0)
{
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
}
_logger.LogInformation("Order. Count: {Count}. Sum: {Sum}. Id: {Id}", model.Count, model.Sum, model.Id);
}
private bool CheckSupply(IRepairModel repair, int count)
{
if (count <= 0)
{