diff --git a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/OrderLogic.cs b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/OrderLogic.cs index 4efbcbd..3e48fea 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/OrderLogic.cs @@ -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 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) diff --git a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/WorkModeling.cs b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/WorkModeling.cs index 5fe6bf5..f3bdb8f 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/WorkModeling.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/WorkModeling.cs @@ -138,4 +138,4 @@ namespace AbstractLawFirmBusinessLogic.BusinessLogic } } } -} +} \ No newline at end of file diff --git a/LawFirm/AbstractLawFirmDatabaseImplement/Models/Order.cs b/LawFirm/AbstractLawFirmDatabaseImplement/Models/Order.cs index 5a7de35..2c82507 100644 --- a/LawFirm/AbstractLawFirmDatabaseImplement/Models/Order.cs +++ b/LawFirm/AbstractLawFirmDatabaseImplement/Models/Order.cs @@ -62,6 +62,7 @@ namespace AbstractLawFirmDatabaseImplement.Models } Status = model.Status; DateImplement = model.DateImplement; + ImplementerId = model.ImplementerId; } public OrderViewModel GetViewModel => new OrderViewModel diff --git a/LawFirm/AbstractLawFirmRestApi/Program.cs b/LawFirm/AbstractLawFirmRestApi/Program.cs index d9b1590..6adf78f 100644 --- a/LawFirm/AbstractLawFirmRestApi/Program.cs +++ b/LawFirm/AbstractLawFirmRestApi/Program.cs @@ -19,6 +19,8 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer();