ISEbd-22 Mavrina J.E. Hard_Labwork 2 #10

Closed
Mavrina_Julia wants to merge 8 commits from Лаб_2_сложн into Лаб_1_сложн
Showing only changes of commit 14c5a5991c - Show all commits

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)
{