Вроде всё

This commit is contained in:
GokaPek 2024-05-05 13:12:35 +04:00
parent 931ee171ee
commit 29f610e929
4 changed files with 14 additions and 3 deletions

View File

@ -16,6 +16,7 @@ namespace AbstractLawFirmBusinessLogic.BusinessLogic
public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
static readonly object locker = new object();
private readonly IOrderStorage _orderStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
@ -68,7 +69,7 @@ namespace AbstractLawFirmBusinessLogic.BusinessLogic
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
{
//CheckModel(model);
CheckModel(model, false);
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (element == null)
{
@ -81,14 +82,21 @@ namespace AbstractLawFirmBusinessLogic.BusinessLogic
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
}
model.Status = status;
if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now;
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
if (element.ImplementerId.HasValue) {
model.ImplementerId = element.ImplementerId;
}
_orderStorage.Update(model);
return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
return ChangeStatus(model, OrderStatus.Выполняется);
lock (locker)
{
return ChangeStatus(model, OrderStatus.Выполняется);
}
}
public bool FinishOrder(OrderBindingModel model)

View File

@ -138,4 +138,4 @@ namespace AbstractLawFirmBusinessLogic.BusinessLogic
}
}
}
}
}

View File

@ -62,6 +62,7 @@ namespace AbstractLawFirmDatabaseImplement.Models
}
Status = model.Status;
DateImplement = model.DateImplement;
ImplementerId = model.ImplementerId;
}
public OrderViewModel GetViewModel => new OrderViewModel

View File

@ -19,6 +19,8 @@ builder.Services.AddTransient<IDocumentStorage, DocumentStorage>();
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<IDocumentLogic, DocumentLogic>();
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();