diff --git a/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/PurchaseLogic.cs b/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/PurchaseLogic.cs index 173e70c..38aebd6 100644 --- a/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/PurchaseLogic.cs +++ b/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/PurchaseLogic.cs @@ -58,6 +58,7 @@ namespace VeterinaryBusinessLogic.BusinessLogic } return true; } + // dateImplement private void CheckModel(PurchaseBindingModel model, bool withParams = true) { if (model == null) diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/PurchaseBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/PurchaseBindingModel.cs index 151003a..3fee9c2 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/PurchaseBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/PurchaseBindingModel.cs @@ -10,6 +10,7 @@ namespace VeterinaryContracts.BindingModels public int Count { get; set; } public double Sum { get; set; } public DateTime DateCreate { get; set; } + public DateTime DateImplement { get; set; } public Dictionary PurchasePet { get; set; } = new(); } } diff --git a/VeterinaryView/VeterinaryContracts/SearchModels/PurchaseSearchModel.cs b/VeterinaryView/VeterinaryContracts/SearchModels/PurchaseSearchModel.cs index f29daec..f1d8336 100644 --- a/VeterinaryView/VeterinaryContracts/SearchModels/PurchaseSearchModel.cs +++ b/VeterinaryView/VeterinaryContracts/SearchModels/PurchaseSearchModel.cs @@ -6,5 +6,6 @@ public int? OwnerId { get; set; } public int? DrugId { get; set; } public DateTime? DateCreate { get; set; } + public DateTime? DateImplement { get; set;} } } diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/PurchaseViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/PurchaseViewModel.cs index 1fdca01..39920bb 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/PurchaseViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/PurchaseViewModel.cs @@ -1,5 +1,4 @@ using System.ComponentModel; -using VeterinaryDataModels.Enums; using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels @@ -17,6 +16,8 @@ namespace VeterinaryContracts.ViewModels public double Sum { get; set; } [DisplayName("Дата покупки")] public DateTime DateCreate { get; set; } + [DisplayName("Дата завершения покупки")] + public DateTime DateImplement { get; set; } public Dictionary PurchasePet { get; set; } = new(); } } diff --git a/VeterinaryView/VeterinaryDataModels/Models/IPurchaseModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IPurchaseModel.cs index 3fff72a..39bb826 100644 --- a/VeterinaryView/VeterinaryDataModels/Models/IPurchaseModel.cs +++ b/VeterinaryView/VeterinaryDataModels/Models/IPurchaseModel.cs @@ -7,6 +7,7 @@ int Count { get; } double Sum { get; } DateTime DateCreate { get; } - Dictionary PurchasePet { get; } + DateTime DateImplement { get; } + Dictionary PurchasePet { get; } } } diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Implements/PurchaseStorage.cs b/VeterinaryView/VeterinaryDatabaseImplement/Implements/PurchaseStorage.cs index 4d254b6..3f3eb5b 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Implements/PurchaseStorage.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Implements/PurchaseStorage.cs @@ -22,7 +22,6 @@ namespace VeterinaryDatabaseImplement.Implements return context.Purchases.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Drug) .Where(x => ((!model.Id.HasValue || x.Id == model.Id) && (!model.DateCreate.HasValue || x.DateCreate >= model.DateCreate) && - (!model.DateImplement.HasValue || x.DateImplement >= model.DateImplement) && (!model.OwnerId.HasValue || x.OwnerId <= model.OwnerId) && (!model.DrugId.HasValue || x.DrugId == model.DrugId))) .Select(x => x.GetViewModel) diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Purchase.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Purchase.cs index ce544cd..b8f4f55 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Purchase.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Purchase.cs @@ -2,7 +2,6 @@ using System.ComponentModel.DataAnnotations.Schema; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; -using VeterinaryDataModels.Enums; using VeterinaryDataModels.Models; namespace VeterinaryDatabaseImplement.Models @@ -21,10 +20,9 @@ namespace VeterinaryDatabaseImplement.Models [Required] public double Sum { get; private set; } [Required] - public PurchaseStatus Status { get; private set; } - [Required] public DateTime DateCreate { get; private set; } - public DateTime DateImplement { get; private set; } + [Required] + public DateTime DateImplement { get; private set; } private Dictionary? _purchasePet = null; [NotMapped] public Dictionary PurchasePet @@ -51,9 +49,7 @@ namespace VeterinaryDatabaseImplement.Models Sum = model.Sum, OwnerId = model.OwnerId, DrugId = model.DrugId, - Status = model.Status, DateCreate = model.DateCreate, - DateImplement = model.DateImplement, Pets = model.PurchasePet.Select(x => new PurchasePet { Pet = context.Pets.First(y => y.Id == x.Key), @@ -67,7 +63,6 @@ namespace VeterinaryDatabaseImplement.Models { return; } - Status = model.Status; DateImplement = model.DateImplement; } public PurchaseViewModel GetViewModel => new() @@ -77,7 +72,6 @@ namespace VeterinaryDatabaseImplement.Models Sum = Sum, OwnerId = OwnerId, DrugId = DrugId, - Status = Status, DateCreate = DateCreate, DateImplement = DateImplement }; diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Visit.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Visit.cs index 6872219..665f7a4 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Visit.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Visit.cs @@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; using VeterinaryDataModels.Models; -using VeterinaryDataModels.Enums; namespace VeterinaryDatabaseImplement.Models { @@ -17,9 +16,7 @@ namespace VeterinaryDatabaseImplement.Models public int? DoctorId { get; private set; } public virtual Doctor? Doctor { get; private set; } [Required] - public string VisitName { get; private set; } - [Required] - public VisitStatus Status { get; private set; } + public string VisitName { get; private set; } = string.Empty; [Required] public DateTime DateVisit { get; private set; } private Dictionary? _visitPet = null; @@ -48,7 +45,7 @@ namespace VeterinaryDatabaseImplement.Models Id = model.Id, OwnerId = model.OwnerId, DoctorId = model.DoctorId, - Status = model.Status, + VisitName = model.VisitName, DateVisit = model.DateVisit, Pets = model.VisitPet.Select(x => new VisitPet { @@ -63,14 +60,14 @@ namespace VeterinaryDatabaseImplement.Models { return; } - Status = model.Status; + VisitName = model.VisitName; } public VisitViewModel GetViewModel => new() { Id = Id, OwnerId = OwnerId, + VisitName = VisitName, DoctorId = DoctorId, - Status = Status, DateVisit = DateVisit }; } diff --git a/VeterinaryView/VeterinaryRestApi/Controllers/VisitController.cs b/VeterinaryView/VeterinaryRestApi/Controllers/VisitController.cs index e171e8d..396bd79 100644 --- a/VeterinaryView/VeterinaryRestApi/Controllers/VisitController.cs +++ b/VeterinaryView/VeterinaryRestApi/Controllers/VisitController.cs @@ -52,7 +52,7 @@ namespace VeterinaryRestApi.Controllers { try { - return _visit.CreateVisit(model); + return _visit.Create(model); } catch (Exception ex) {