diff --git a/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs b/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs index 52e6f46..fb61b4e 100644 --- a/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs @@ -94,15 +94,21 @@ namespace FishFactoryBusinessLogic.BusinessLogic throw new ArgumentNullException(nameof(element)); } - model.CannedId = element.CannedId; + if (element.ImplementerId != null && model.ImplementerId != null && model.ImplementerId != element.ImplementerId) + { + throw new InvalidOperationException(nameof(model.ImplementerId)); + } + + model.CannedId = element.CannedId; model.ClientId = element.ClientId; model.DateCreate = element.DateCreate; model.DateImplement = element.DateImplement; model.Status = element.Status; model.Count = element.Count; model.Sum = element.Sum; + model.ImplementerId = element.ImplementerId.HasValue ? element.ImplementerId : model.ImplementerId; - if (model.Status != orderStatus - 1) + if (model.Status != orderStatus - 1) { _logger.LogWarning("Status update to " + orderStatus + " operation failed"); return false; diff --git a/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs b/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs index be9c97f..2420ab5 100644 --- a/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs +++ b/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs @@ -4,7 +4,7 @@ namespace FishFactoryContracts.SearchModels public class ImplementerSearchModel { public int? Id { get; set; } - public string? ImplementerFIO { get; set; } - public string? Password { get; set; } - } + public string? ImplementerFIO { get; set; } = string.Empty; + public string? Password { get; set; } = string.Empty; + } } diff --git a/FishFactoryContracts/ViewModels/ImplementerViewModel.cs b/FishFactoryContracts/ViewModels/ImplementerViewModel.cs index ceaae40..6c8008a 100644 --- a/FishFactoryContracts/ViewModels/ImplementerViewModel.cs +++ b/FishFactoryContracts/ViewModels/ImplementerViewModel.cs @@ -1,9 +1,9 @@ - +using FishFactoryDataModel.Models; using System.ComponentModel; namespace FishFactoryContracts.ViewModels { - public class ImplementerViewModel + public class ImplementerViewModel : IImplementerModel { public int Id { get; set; } [DisplayName("ФИО исполнителя")] diff --git a/FishFactoryDatabaseImplement/Models/Implementer.cs b/FishFactoryDatabaseImplement/Models/Implementer.cs index f68ae31..dd3193e 100644 --- a/FishFactoryDatabaseImplement/Models/Implementer.cs +++ b/FishFactoryDatabaseImplement/Models/Implementer.cs @@ -1,6 +1,7 @@ using FishFactoryContracts.BindingModels; using FishFactoryContracts.ViewModels; using FishFactoryDataModel.Models; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace FishFactoryDatabaseImplement.Models @@ -8,14 +9,14 @@ namespace FishFactoryDatabaseImplement.Models public class Implementer : IImplementerModel { public int Id { get; private set; } - - public string ImplementerFIO { get; private set; } = string.Empty; - - public string Password { get; private set; } = string.Empty; - - public int WorkExperience { get; private set; } = 0; - - public int Qualification { get; private set; } = 0; + [Required] + public string ImplementerFIO { get; private set; } = string.Empty; + [Required] + public string Password { get; private set; } = string.Empty; + [Required] + public int WorkExperience { get; private set; } = 0; + [Required] + public int Qualification { get; private set; } = 0; [ForeignKey("ImplementerId")] public virtual List Order { get; set; } = new();