From e3f5e6b2902ed3a9d4f3bb9a6b2e13b38cb81701 Mon Sep 17 00:00:00 2001 From: Yunusov_Niyaz Date: Tue, 30 Apr 2024 01:48:04 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/PurchaseLogic.cs | 41 +++++++++++++++++-- .../BusinessLogic/VisitLogic.cs | 30 ++++++++++++++ .../BindingModels/DoctorBindingModel.cs | 4 +- .../BindingModels/DrugBindingModel.cs | 4 +- .../BindingModels/MedicationBindingModel.cs | 4 +- .../BindingModels/OwnerBindingModel.cs | 4 +- .../BindingModels/PetBindingModel.cs | 4 +- .../BindingModels/PurchaseBindingModel.cs | 10 +++-- .../BindingModels/ServiceBindingModel.cs | 4 +- .../BindingModels/VisitBindingModel.cs | 6 ++- .../BusinessLogicContracts/IPurchaseLogic.cs | 3 ++ .../BusinessLogicContracts/IVisitLogic.cs | 2 + .../SearchModels/PurchaseSearchModel.cs | 8 +++- .../SearchModels/VisitSearchModel.cs | 5 ++- .../StorageContracts/IPurchaseStorage.cs | 1 + .../StorageContracts/IVisitStorage.cs | 1 + .../ViewModels/DoctorViewModel.cs | 4 +- .../ViewModels/DrugViewModel.cs | 4 +- .../ViewModels/MedicationViewModel.cs | 4 +- .../ViewModels/OwnerViewModel.cs | 4 +- .../ViewModels/PetViewModel.cs | 4 +- .../ViewModels/PurchaseViewModel.cs | 11 +++-- .../ViewModels/ServiceViewModel.cs | 4 +- .../ViewModels/VisitViewModel.cs | 7 +++- .../Enums/PurchaseStatus.cs | 11 +++++ .../VeterinaryDataModels/Enums/VisitStatus.cs | 10 +++++ .../VeterinaryDataModels/IDoctorModel.cs | 16 -------- .../VeterinaryDataModels/IDrugModel.cs | 16 -------- .../VeterinaryDataModels/IMedicationModel.cs | 15 ------- .../VeterinaryDataModels/IOwnerModel.cs | 9 ---- .../VeterinaryDataModels/IPetModel.cs | 11 ----- .../VeterinaryDataModels/IPurchaseModel.cs | 12 ------ .../VeterinaryDataModels/IServiceModel.cs | 17 -------- .../VeterinaryDataModels/IVisitModel.cs | 10 ----- .../Models/IDoctorModel.cs | 16 ++++++++ .../VeterinaryDataModels/Models/IDrugModel.cs | 16 ++++++++ .../Models/IMedicationModel.cs | 15 +++++++ .../Models/IOwnerModel.cs | 9 ++++ .../VeterinaryDataModels/Models/IPetModel.cs | 11 +++++ .../Models/IPurchaseModel.cs | 16 ++++++++ .../Models/IServiceModel.cs | 17 ++++++++ .../Models/IVisitModel.cs | 13 ++++++ .../Implements/PurchaseStorage.cs | 25 ++++++++--- .../Implements/VisitStorage.cs | 23 +++++++++-- .../Models/Doctor.cs | 4 +- .../Models/Drug.cs | 4 +- .../Models/Medication.cs | 4 +- .../Models/Owner.cs | 4 +- .../VeterinaryDatabaseImplement/Models/Pet.cs | 4 +- .../Models/Purchase.cs | 27 +++++++++--- .../Models/Service.cs | 4 +- .../Models/Visit.cs | 17 +++++++- 52 files changed, 355 insertions(+), 174 deletions(-) create mode 100644 VeterinaryView/VeterinaryDataModels/Enums/PurchaseStatus.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Enums/VisitStatus.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IDoctorModel.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IDrugModel.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IMedicationModel.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IOwnerModel.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IPetModel.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IPurchaseModel.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IServiceModel.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IVisitModel.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Models/IDoctorModel.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Models/IDrugModel.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Models/IMedicationModel.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Models/IOwnerModel.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Models/IPetModel.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Models/IPurchaseModel.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Models/IServiceModel.cs create mode 100644 VeterinaryView/VeterinaryDataModels/Models/IVisitModel.cs diff --git a/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/PurchaseLogic.cs b/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/PurchaseLogic.cs index 2c59dff..40e2a96 100644 --- a/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/PurchaseLogic.cs +++ b/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/PurchaseLogic.cs @@ -4,6 +4,7 @@ using VeterinaryContracts.BusinessLogicContracts; using VeterinaryContracts.SearchModels; using VeterinaryContracts.StorageContracts; using VeterinaryContracts.ViewModels; +using VeterinaryDataModels.Enums; namespace VeterinaryBusinessLogic.BusinessLogic { @@ -58,6 +59,40 @@ namespace VeterinaryBusinessLogic.BusinessLogic } return true; } + public bool ChangeStatus(PurchaseBindingModel model, PurchaseStatus status) + { + CheckModel(model); + var element = _purchaseStorage.GetElement(new PurchaseSearchModel { Id = model.Id }); + if (element == null) + { + _logger.LogWarning("Read operation failed"); + return false; + } + if (element.Status != status - 1) + { + _logger.LogWarning("Status change operation failed"); + throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный"); + } + model.Status = status; + if (model.Status == PurchaseStatus.Выдан) model.DateImplement = DateTime.Now; + _purchaseStorage.Update(model); + return true; + } + + public bool BeginPurchase(PurchaseBindingModel model) + { + return ChangeStatus(model, PurchaseStatus.Собирается); + } + + public bool FinishPurchase(PurchaseBindingModel model) + { + return ChangeStatus(model, PurchaseStatus.Готов); + } + + public bool DeliveryPurchase(PurchaseBindingModel model) + { + return ChangeStatus(model, PurchaseStatus.Выдан); + } private void CheckModel(PurchaseBindingModel model, bool withParams = true) { if (model == null) @@ -72,15 +107,15 @@ namespace VeterinaryBusinessLogic.BusinessLogic { throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum)); } - if (model.DatePurchase <= DateTime.Now) + if (model.DateCreate <= DateTime.Now) { - throw new ArgumentNullException("Дата покупки не должна быть в прошлом", nameof(model.DatePurchase)); + throw new ArgumentNullException("Дата покупки не должна быть в прошлом", nameof(model.DateCreate)); } if (model.Count <= 0) { throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count)); } - _logger.LogInformation("Purchase. DatePuchase: { DatePurchase}. Count:{ Count}. Id: { Id}", model.DatePurchase, model.Count, model.Id); + _logger.LogInformation("Purchase. DatePuchase: { DatePurchase}. Count:{ Count}. Id: { Id}", model.DateCreate, model.Count, model.Id); } } } diff --git a/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/VisitLogic.cs b/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/VisitLogic.cs index f73d3cd..f5f6b42 100644 --- a/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/VisitLogic.cs +++ b/VeterinaryView/VeterinaryBusinessLogic/BusinessLogic/VisitLogic.cs @@ -4,6 +4,7 @@ using VeterinaryContracts.BusinessLogicContracts; using VeterinaryContracts.SearchModels; using VeterinaryContracts.StorageContracts; using VeterinaryContracts.ViewModels; +using VeterinaryDataModels.Enums; namespace VeterinaryBusinessLogic.BusinessLogic { @@ -59,6 +60,35 @@ namespace VeterinaryBusinessLogic.BusinessLogic } return true; } + public bool ChangeStatus(VisitBindingModel model, VisitStatus status) + { + CheckModel(model); + var element = _visitStorage.GetElement(new VisitSearchModel { Id = model.Id }); + if (element == null) + { + _logger.LogWarning("Read operation failed"); + return false; + } + if (element.Status != status - 1) + { + _logger.LogWarning("Status change operation failed"); + throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный"); + } + model.Status = status; + if (model.Status == VisitStatus.Закончен) model.DateVisit = DateTime.Now; + _visitStorage.Update(model); + return true; + } + + public bool BeginVisit(VisitBindingModel model) + { + return ChangeStatus(model, VisitStatus.Выполняется); + } + + public bool FinishVisit(VisitBindingModel model) + { + return ChangeStatus(model, VisitStatus.Закончен); + } private void CheckModel(VisitBindingModel model, bool withParams = true) { if (model == null) diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/DoctorBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/DoctorBindingModel.cs index 3817d54..c3e79ea 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/DoctorBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/DoctorBindingModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.BindingModels { - public class DoctorBindingModel : IDoctorModel + public class DoctorBindingModel : IDoctorModel { public int Id { get; set; } public string DoctorFIO { get; set; } = string.Empty; diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/DrugBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/DrugBindingModel.cs index a955aa0..b3a192a 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/DrugBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/DrugBindingModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.BindingModels { - public class DrugBindingModel : IDrugModel + public class DrugBindingModel : IDrugModel { public int Id { get; set; } public string DrugName { get; set; } = string.Empty; diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/MedicationBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/MedicationBindingModel.cs index ba71ea7..da2c532 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/MedicationBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/MedicationBindingModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.BindingModels { - public class MedicationBindingModel : IMedicationModel + public class MedicationBindingModel : IMedicationModel { public int Id { get; set; } public string MedicationName { get; set; } = string.Empty; diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/OwnerBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/OwnerBindingModel.cs index 046422e..115d1f6 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/OwnerBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/OwnerBindingModel.cs @@ -1,8 +1,8 @@ -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.BindingModels { - public class OwnerBindingModel : IOwnerModel + public class OwnerBindingModel : IOwnerModel { public int Id { get; set; } public string OwnerFIO { get; set; } = string.Empty; diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/PetBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/PetBindingModel.cs index a4cb97c..b8a792c 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/PetBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/PetBindingModel.cs @@ -1,8 +1,8 @@ -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.BindingModels { - public class PetBindingModel : IPetModel + public class PetBindingModel : IPetModel { public int Id { get; set; } public int OwnerId { get; set; } diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/PurchaseBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/PurchaseBindingModel.cs index e5361d0..e06f468 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/PurchaseBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/PurchaseBindingModel.cs @@ -1,15 +1,19 @@ -using VeterinaryDataModels; +using VeterinaryDataModels.Enums; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.BindingModels { - public class PurchaseBindingModel : IPurchaseModel + public class PurchaseBindingModel : IPurchaseModel { public int Id { get; set; } public int OwnerId { get; set; } public int DrugId { get; set; } public int Count { get; set; } public double Sum { get; set; } - public DateTime DatePurchase { get; set; } + public PurchaseStatus Status { get; set; } + public DateTime DateCreate { get; set; } + public DateTime DateImplement { get; set; } + public Dictionary PurchasePet { get; set; } = new(); } } diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/ServiceBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/ServiceBindingModel.cs index d52578b..1fd5503 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/ServiceBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/ServiceBindingModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.BindingModels { - public class ServiceBindingModel : IServiceModel + public class ServiceBindingModel : IServiceModel { public int Id { get; set; } public string ServiceName { get; set; } = string.Empty; diff --git a/VeterinaryView/VeterinaryContracts/BindingModels/VisitBindingModel.cs b/VeterinaryView/VeterinaryContracts/BindingModels/VisitBindingModel.cs index e0f1d1b..a4672da 100644 --- a/VeterinaryView/VeterinaryContracts/BindingModels/VisitBindingModel.cs +++ b/VeterinaryView/VeterinaryContracts/BindingModels/VisitBindingModel.cs @@ -1,12 +1,14 @@ -using VeterinaryDataModels; +using VeterinaryDataModels.Enums; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.BindingModels { - public class VisitBindingModel : IVisitModel + public class VisitBindingModel : IVisitModel { public int Id { get; set; } public int OwnerId { get; set; } public int? DoctorId { get; set; } = null; + public VisitStatus Status { get; set; } public DateTime DateVisit { get; set; } public Dictionary VisitPet { get; set; } = new(); } diff --git a/VeterinaryView/VeterinaryContracts/BusinessLogicContracts/IPurchaseLogic.cs b/VeterinaryView/VeterinaryContracts/BusinessLogicContracts/IPurchaseLogic.cs index 9066477..b2580c1 100644 --- a/VeterinaryView/VeterinaryContracts/BusinessLogicContracts/IPurchaseLogic.cs +++ b/VeterinaryView/VeterinaryContracts/BusinessLogicContracts/IPurchaseLogic.cs @@ -9,5 +9,8 @@ namespace VeterinaryContracts.BusinessLogicContracts List? ReadList(PurchaseSearchModel? model); PurchaseViewModel? ReadElement(PurchaseSearchModel model); bool CreatePurchase(PurchaseBindingModel model); + bool BeginPurchase(PurchaseBindingModel model); + bool FinishPurchase(PurchaseBindingModel model); + bool DeliveryPurchase(PurchaseBindingModel model); } } diff --git a/VeterinaryView/VeterinaryContracts/BusinessLogicContracts/IVisitLogic.cs b/VeterinaryView/VeterinaryContracts/BusinessLogicContracts/IVisitLogic.cs index a6bdafc..1c2e9ce 100644 --- a/VeterinaryView/VeterinaryContracts/BusinessLogicContracts/IVisitLogic.cs +++ b/VeterinaryView/VeterinaryContracts/BusinessLogicContracts/IVisitLogic.cs @@ -9,5 +9,7 @@ namespace VeterinaryContracts.BusinessLogicContracts List? ReadList(VisitSearchModel? model); VisitViewModel? ReadElement(VisitSearchModel model); bool CreateVisit(VisitBindingModel model); + bool BeginVisit(VisitBindingModel model); + bool FinishVisit(VisitBindingModel model); } } diff --git a/VeterinaryView/VeterinaryContracts/SearchModels/PurchaseSearchModel.cs b/VeterinaryView/VeterinaryContracts/SearchModels/PurchaseSearchModel.cs index 0d126c5..6db757a 100644 --- a/VeterinaryView/VeterinaryContracts/SearchModels/PurchaseSearchModel.cs +++ b/VeterinaryView/VeterinaryContracts/SearchModels/PurchaseSearchModel.cs @@ -1,10 +1,14 @@ -namespace VeterinaryContracts.SearchModels +using VeterinaryDataModels.Enums; + +namespace VeterinaryContracts.SearchModels { public class PurchaseSearchModel { public int? Id { get; set; } public int? OwnerId { get; set; } public int? DrugId { get; set; } - public DateTime? DatePurchase { get; set; } + public PurchaseStatus? Status { get; set; } + public DateTime? DateCreate { get; set; } + public DateTime? DateImplement { get; set; } } } diff --git a/VeterinaryView/VeterinaryContracts/SearchModels/VisitSearchModel.cs b/VeterinaryView/VeterinaryContracts/SearchModels/VisitSearchModel.cs index 914cf89..3796418 100644 --- a/VeterinaryView/VeterinaryContracts/SearchModels/VisitSearchModel.cs +++ b/VeterinaryView/VeterinaryContracts/SearchModels/VisitSearchModel.cs @@ -1,10 +1,13 @@ -namespace VeterinaryContracts.SearchModels +using VeterinaryDataModels.Enums; + +namespace VeterinaryContracts.SearchModels { public class VisitSearchModel { public int? Id { get; set; } public int? OwnerId { get; set; } public int? DoctorId { get; set; } + public VisitStatus? Status { get; set; } public DateTime? DateVisit { get; set; } } } diff --git a/VeterinaryView/VeterinaryContracts/StorageContracts/IPurchaseStorage.cs b/VeterinaryView/VeterinaryContracts/StorageContracts/IPurchaseStorage.cs index e110722..3add211 100644 --- a/VeterinaryView/VeterinaryContracts/StorageContracts/IPurchaseStorage.cs +++ b/VeterinaryView/VeterinaryContracts/StorageContracts/IPurchaseStorage.cs @@ -10,6 +10,7 @@ namespace VeterinaryContracts.StorageContracts List GetFilteredList(PurchaseSearchModel model); PurchaseViewModel? GetElement(PurchaseSearchModel model); PurchaseViewModel? Insert(PurchaseBindingModel model); + PurchaseViewModel? Update(PurchaseBindingModel model); PurchaseViewModel? Delete(PurchaseBindingModel model); } } diff --git a/VeterinaryView/VeterinaryContracts/StorageContracts/IVisitStorage.cs b/VeterinaryView/VeterinaryContracts/StorageContracts/IVisitStorage.cs index 5e9e560..9702870 100644 --- a/VeterinaryView/VeterinaryContracts/StorageContracts/IVisitStorage.cs +++ b/VeterinaryView/VeterinaryContracts/StorageContracts/IVisitStorage.cs @@ -10,6 +10,7 @@ namespace VeterinaryContracts.StorageContracts List GetFilteredList(VisitSearchModel model); VisitViewModel? GetElement(VisitSearchModel model); VisitViewModel? Insert(VisitBindingModel model); + VisitViewModel? Update(VisitBindingModel model); VisitViewModel? Delete(VisitBindingModel model); } } diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/DoctorViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/DoctorViewModel.cs index 5294a9e..6bffa20 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/DoctorViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/DoctorViewModel.cs @@ -4,11 +4,11 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels { - public class DoctorViewModel : IDoctorModel + public class DoctorViewModel : IDoctorModel { public int Id { get; set; } [DisplayName("ФИО доктора")] diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/DrugViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/DrugViewModel.cs index 7970b42..3d0a0e4 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/DrugViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/DrugViewModel.cs @@ -4,11 +4,11 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels { - public class DrugViewModel : IDrugModel + public class DrugViewModel : IDrugModel { public int Id { get; set; } [DisplayName("Название лекарства")] diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/MedicationViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/MedicationViewModel.cs index 37b54e8..eca0a4d 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/MedicationViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/MedicationViewModel.cs @@ -4,11 +4,11 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels { - public class MedicationViewModel : IMedicationModel + public class MedicationViewModel : IMedicationModel { public int Id { get; set; } [DisplayName("Название медикамента")] diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/OwnerViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/OwnerViewModel.cs index d562597..4da4a0a 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/OwnerViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/OwnerViewModel.cs @@ -1,9 +1,9 @@ using System.ComponentModel; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels { - public class OwnerViewModel : IOwnerModel + public class OwnerViewModel : IOwnerModel { public int Id { get; set; } [DisplayName("ФИО хозяина")] diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/PetViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/PetViewModel.cs index 593a4b8..ca31ef8 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/PetViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/PetViewModel.cs @@ -1,9 +1,9 @@ using System.ComponentModel; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels { - public class PetViewModel : IPetModel + public class PetViewModel : IPetModel { public int Id { get; set; } [DisplayName("Хозяин")] diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/PurchaseViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/PurchaseViewModel.cs index 934271f..33eb3a3 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/PurchaseViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/PurchaseViewModel.cs @@ -1,9 +1,10 @@ using System.ComponentModel; -using VeterinaryDataModels; +using VeterinaryDataModels.Enums; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels { - public class PurchaseViewModel : IPurchaseModel + public class PurchaseViewModel : IPurchaseModel { public int Id { get; set; } [DisplayName("Хозяин")] @@ -14,8 +15,12 @@ namespace VeterinaryContracts.ViewModels public int Count { get; set; } [DisplayName("Сумма")] public double Sum { get; set; } + [DisplayName("Статус")] + public PurchaseStatus Status { get; set; } [DisplayName("Дата покупки")] - public DateTime DatePurchase { get; set; } + public DateTime DateCreate { get; set; } + [DisplayName("Дата завершения покупки")] + public DateTime DateImplement { get; set; } public Dictionary PurchasePet { get; set; } = new(); } } diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/ServiceViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/ServiceViewModel.cs index cb0c0c8..78591da 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/ServiceViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/ServiceViewModel.cs @@ -4,11 +4,11 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels { - public class ServiceViewModel : IServiceModel + public class ServiceViewModel : IServiceModel { public int Id { get; set; } [DisplayName("Название услуги")] diff --git a/VeterinaryView/VeterinaryContracts/ViewModels/VisitViewModel.cs b/VeterinaryView/VeterinaryContracts/ViewModels/VisitViewModel.cs index 2c482e1..111a4d3 100644 --- a/VeterinaryView/VeterinaryContracts/ViewModels/VisitViewModel.cs +++ b/VeterinaryView/VeterinaryContracts/ViewModels/VisitViewModel.cs @@ -1,15 +1,18 @@ using System.ComponentModel; -using VeterinaryDataModels; +using VeterinaryDataModels.Enums; +using VeterinaryDataModels.Models; namespace VeterinaryContracts.ViewModels { - public class VisitViewModel : IVisitModel + public class VisitViewModel : IVisitModel { public int Id { get; set; } [DisplayName("Хозяин")] public int OwnerId { get; set; } [DisplayName("Врач")] public int? DoctorId { get; set; } = null; + [DisplayName("Статус")] + public VisitStatus Status { get; set; } [DisplayName("Дата посещения")] public DateTime DateVisit { get; set; } public Dictionary VisitPet { get; set; } = new(); diff --git a/VeterinaryView/VeterinaryDataModels/Enums/PurchaseStatus.cs b/VeterinaryView/VeterinaryDataModels/Enums/PurchaseStatus.cs new file mode 100644 index 0000000..3fc343d --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Enums/PurchaseStatus.cs @@ -0,0 +1,11 @@ +namespace VeterinaryDataModels.Enums +{ + public enum PurchaseStatus + { + Неизвестен = -1, + Принят = 0, + Собирается = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/VeterinaryView/VeterinaryDataModels/Enums/VisitStatus.cs b/VeterinaryView/VeterinaryDataModels/Enums/VisitStatus.cs new file mode 100644 index 0000000..1021c08 --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Enums/VisitStatus.cs @@ -0,0 +1,10 @@ +namespace VeterinaryDataModels.Enums +{ + public enum VisitStatus + { + Неизвестен = -1, + Забронировано = 0, + Выполняется = 1, + Закончен = 2, + } +} diff --git a/VeterinaryView/VeterinaryDataModels/IDoctorModel.cs b/VeterinaryView/VeterinaryDataModels/IDoctorModel.cs deleted file mode 100644 index 8d19924..0000000 --- a/VeterinaryView/VeterinaryDataModels/IDoctorModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VeterinaryDataModels -{ - public interface IDoctorModel : IId - { - string DoctorFIO { get; } - string Login { get; } - string Password { get; } - - } -} diff --git a/VeterinaryView/VeterinaryDataModels/IDrugModel.cs b/VeterinaryView/VeterinaryDataModels/IDrugModel.cs deleted file mode 100644 index db46b81..0000000 --- a/VeterinaryView/VeterinaryDataModels/IDrugModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VeterinaryDataModels -{ - public interface IDrugModel :IId - { - string DrugName { get; } - int Count { get; } - double Price { get; } - Dictionary DrugMedications { get; } - } -} diff --git a/VeterinaryView/VeterinaryDataModels/IMedicationModel.cs b/VeterinaryView/VeterinaryDataModels/IMedicationModel.cs deleted file mode 100644 index 034ad8a..0000000 --- a/VeterinaryView/VeterinaryDataModels/IMedicationModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VeterinaryDataModels -{ - public interface IMedicationModel : IId - { - string MedicationName { get;} - double Price { get;} - int DoctorId { get;} - } -} diff --git a/VeterinaryView/VeterinaryDataModels/IOwnerModel.cs b/VeterinaryView/VeterinaryDataModels/IOwnerModel.cs deleted file mode 100644 index 0156074..0000000 --- a/VeterinaryView/VeterinaryDataModels/IOwnerModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace VeterinaryDataModels -{ - public interface IOwnerModel : IId - { - string OwnerFIO { get; } - string Login { get; } - string Password { get; } - } -} diff --git a/VeterinaryView/VeterinaryDataModels/IPetModel.cs b/VeterinaryView/VeterinaryDataModels/IPetModel.cs deleted file mode 100644 index 3fa9688..0000000 --- a/VeterinaryView/VeterinaryDataModels/IPetModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace VeterinaryDataModels -{ - public interface IPetModel : IId - { - int OwnerId { get; } - string PetName { get; } - string PetType { get; } - string PetBreed { get; } - string PetGender { get; } - } -} diff --git a/VeterinaryView/VeterinaryDataModels/IPurchaseModel.cs b/VeterinaryView/VeterinaryDataModels/IPurchaseModel.cs deleted file mode 100644 index 3041d66..0000000 --- a/VeterinaryView/VeterinaryDataModels/IPurchaseModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace VeterinaryDataModels -{ - public interface IPurchaseModel : IId - { - int OwnerId { get; } - int DrugId { get; } - int Count { get; } - double Sum { get; } - DateTime DatePurchase { get; } - Dictionary PurchasePet { get; } - } -} diff --git a/VeterinaryView/VeterinaryDataModels/IServiceModel.cs b/VeterinaryView/VeterinaryDataModels/IServiceModel.cs deleted file mode 100644 index a54cf76..0000000 --- a/VeterinaryView/VeterinaryDataModels/IServiceModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VeterinaryDataModels -{ - public interface IServiceModel : IId - { - String ServiceName { get;} - int VisitId { get; } - int DoctorId { get; } - Dictionary ServiceMedications { get; } - - } -} diff --git a/VeterinaryView/VeterinaryDataModels/IVisitModel.cs b/VeterinaryView/VeterinaryDataModels/IVisitModel.cs deleted file mode 100644 index 571cf4e..0000000 --- a/VeterinaryView/VeterinaryDataModels/IVisitModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace VeterinaryDataModels -{ - public interface IVisitModel : IId - { - int OwnerId { get; } - int? DoctorId { get; } - DateTime DateVisit { get; } - Dictionary VisitPet { get; } - } -} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IDoctorModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IDoctorModel.cs new file mode 100644 index 0000000..036136f --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Models/IDoctorModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VeterinaryDataModels.Models +{ + public interface IDoctorModel : IId + { + string DoctorFIO { get; } + string Login { get; } + string Password { get; } + + } +} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IDrugModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IDrugModel.cs new file mode 100644 index 0000000..5ba6bd0 --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Models/IDrugModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VeterinaryDataModels.Models +{ + public interface IDrugModel : IId + { + string DrugName { get; } + int Count { get; } + double Price { get; } + Dictionary DrugMedications { get; } + } +} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IMedicationModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IMedicationModel.cs new file mode 100644 index 0000000..d320fe3 --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Models/IMedicationModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VeterinaryDataModels.Models +{ + public interface IMedicationModel : IId + { + string MedicationName { get; } + double Price { get; } + int DoctorId { get; } + } +} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IOwnerModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IOwnerModel.cs new file mode 100644 index 0000000..f7618d7 --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Models/IOwnerModel.cs @@ -0,0 +1,9 @@ +namespace VeterinaryDataModels.Models +{ + public interface IOwnerModel : IId + { + string OwnerFIO { get; } + string Login { get; } + string Password { get; } + } +} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IPetModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IPetModel.cs new file mode 100644 index 0000000..d9ce5b7 --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Models/IPetModel.cs @@ -0,0 +1,11 @@ +namespace VeterinaryDataModels.Models +{ + public interface IPetModel : IId + { + int OwnerId { get; } + string PetName { get; } + string PetType { get; } + string PetBreed { get; } + string PetGender { get; } + } +} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IPurchaseModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IPurchaseModel.cs new file mode 100644 index 0000000..c0f188f --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Models/IPurchaseModel.cs @@ -0,0 +1,16 @@ +using VeterinaryDataModels.Enums; + +namespace VeterinaryDataModels.Models +{ + public interface IPurchaseModel : IId + { + int OwnerId { get; } + int DrugId { get; } + int Count { get; } + double Sum { get; } + PurchaseStatus Status { get; } + DateTime DateCreate { get; } + DateTime DateImplement { get; } + Dictionary PurchasePet { get; } + } +} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IServiceModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IServiceModel.cs new file mode 100644 index 0000000..75903a2 --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Models/IServiceModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VeterinaryDataModels.Models +{ + public interface IServiceModel : IId + { + string ServiceName { get; } + int VisitId { get; } + int DoctorId { get; } + Dictionary ServiceMedications { get; } + + } +} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IVisitModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IVisitModel.cs new file mode 100644 index 0000000..e2008b9 --- /dev/null +++ b/VeterinaryView/VeterinaryDataModels/Models/IVisitModel.cs @@ -0,0 +1,13 @@ +using VeterinaryDataModels.Enums; + +namespace VeterinaryDataModels.Models +{ + public interface IVisitModel : IId + { + int OwnerId { get; } + int? DoctorId { get; } + DateTime DateVisit { get; } + VisitStatus Status { get; } + Dictionary VisitPet { get; } + } +} diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Implements/PurchaseStorage.cs b/VeterinaryView/VeterinaryDatabaseImplement/Implements/PurchaseStorage.cs index 46677bc..4d254b6 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Implements/PurchaseStorage.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Implements/PurchaseStorage.cs @@ -21,7 +21,8 @@ namespace VeterinaryDatabaseImplement.Implements using var context = new VeterinaryDatabase(); 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.DatePurchase.HasValue || x.DatePurchase >= model.DatePurchase) && + (!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) @@ -29,11 +30,13 @@ namespace VeterinaryDatabaseImplement.Implements } public PurchaseViewModel? GetElement(PurchaseSearchModel model) { + if (!model.Id.HasValue) + { + return null; + } using var context = new VeterinaryDatabase(); - return context.Purchases.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Drug).FirstOrDefault( - x => ((model.Id.HasValue && x.Id == model.Id) || - (model.OwnerId.HasValue && model.DrugId.HasValue && - x.OwnerId == model.OwnerId && x.DrugId == model.DrugId)))?.GetViewModel; + return context.Purchases.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Drug) + .FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; } public PurchaseViewModel? Insert(PurchaseBindingModel model) { @@ -47,6 +50,18 @@ namespace VeterinaryDatabaseImplement.Implements context.SaveChanges(); return newPurchase.GetViewModel; } + public PurchaseViewModel? Update(PurchaseBindingModel model) + { + using var context = new VeterinaryDatabase(); + var purchase = context.Purchases.Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Owner).FirstOrDefault(x => x.Id == model.Id); + if (purchase == null) + { + return null; + } + purchase.Update(model); + context.SaveChanges(); + return purchase.GetViewModel; + } public PurchaseViewModel? Delete(PurchaseBindingModel model) { using var context = new VeterinaryDatabase(); diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Implements/VisitStorage.cs b/VeterinaryView/VeterinaryDatabaseImplement/Implements/VisitStorage.cs index 4268238..896889c 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Implements/VisitStorage.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Implements/VisitStorage.cs @@ -29,11 +29,13 @@ namespace VeterinaryDatabaseImplement.Implements } public VisitViewModel? GetElement(VisitSearchModel model) { + if (!model.Id.HasValue) + { + return null; + } using var context = new VeterinaryDatabase(); - return context.Visits.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Doctor).FirstOrDefault( - x => ((model.Id.HasValue && x.Id == model.Id) || - (model.OwnerId.HasValue && model.DoctorId.HasValue && - x.OwnerId == model.OwnerId && x.DoctorId == model.DoctorId)))?.GetViewModel; + return context.Visits.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Doctor) + .FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; } public VisitViewModel? Insert(VisitBindingModel model) { @@ -47,6 +49,19 @@ namespace VeterinaryDatabaseImplement.Implements context.SaveChanges(); return newVisit.GetViewModel; } + public VisitViewModel? Update(VisitBindingModel model) + { + using var context = new VeterinaryDatabase(); + var visit = context.Visits.Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Owner) + .FirstOrDefault(x => x.Id == model.Id); + if (visit == null) + { + return null; + } + visit.Update(model); + context.SaveChanges(); + return visit.GetViewModel; + } public VisitViewModel? Delete(VisitBindingModel model) { using var context = new VeterinaryDatabase(); diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Doctor.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Doctor.cs index de79787..7e310cb 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Doctor.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Doctor.cs @@ -5,13 +5,13 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; +using VeterinaryDataModels.Models; namespace VeterinaryDatabaseImplement.Models { - public class Doctor : IDoctorModel + public class Doctor : IDoctorModel { public int Id { get; private set; } [Required] diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs index 1287932..faee98e 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Drug.cs @@ -5,13 +5,13 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; +using VeterinaryDataModels.Models; namespace VeterinaryDatabaseImplement.Models { - public class Drug : IDrugModel + public class Drug : IDrugModel { public int Id { get; set; } [Required] diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Medication.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Medication.cs index 415fc81..66a84f3 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Medication.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Medication.cs @@ -6,13 +6,13 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; +using VeterinaryDataModels.Models; namespace VeterinaryDatabaseImplement.Models { - public class Medication : IMedicationModel + public class Medication : IMedicationModel { public int Id { get; private set; } [Required] diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Owner.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Owner.cs index 7ab13ac..eeac234 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Owner.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Owner.cs @@ -1,12 +1,12 @@ using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations; -using VeterinaryDataModels; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; +using VeterinaryDataModels.Models; namespace VeterinaryDatabaseImplement.Models { - public class Owner : IOwnerModel + public class Owner : IOwnerModel { public int Id { get; private set; } [Required] diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Pet.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Pet.cs index b97c1ba..12f1bee 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Pet.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Pet.cs @@ -1,12 +1,12 @@ using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations; -using VeterinaryDataModels; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; +using VeterinaryDataModels.Models; namespace VeterinaryDatabaseImplement.Models { - public class Pet : IPetModel + public class Pet : IPetModel { public int Id { get; private set; } [Required] diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Purchase.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Purchase.cs index 9c9adc9..ce544cd 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Purchase.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Purchase.cs @@ -2,11 +2,12 @@ using System.ComponentModel.DataAnnotations.Schema; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; -using VeterinaryDataModels; +using VeterinaryDataModels.Enums; +using VeterinaryDataModels.Models; namespace VeterinaryDatabaseImplement.Models { - public class Purchase : IPurchaseModel + public class Purchase : IPurchaseModel { public int Id { get; private set; } [Required] @@ -20,7 +21,10 @@ namespace VeterinaryDatabaseImplement.Models [Required] public double Sum { get; private set; } [Required] - public DateTime DatePurchase { get; private set; } + public PurchaseStatus Status { get; private set; } + [Required] + public DateTime DateCreate { get; private set; } + public DateTime DateImplement { get; private set; } private Dictionary? _purchasePet = null; [NotMapped] public Dictionary PurchasePet @@ -47,7 +51,9 @@ namespace VeterinaryDatabaseImplement.Models Sum = model.Sum, OwnerId = model.OwnerId, DrugId = model.DrugId, - DatePurchase = model.DatePurchase, + 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), @@ -55,6 +61,15 @@ namespace VeterinaryDatabaseImplement.Models }).ToList() }; } + public void Update(PurchaseBindingModel? model) + { + if (model == null) + { + return; + } + Status = model.Status; + DateImplement = model.DateImplement; + } public PurchaseViewModel GetViewModel => new() { Id = Id, @@ -62,7 +77,9 @@ namespace VeterinaryDatabaseImplement.Models Sum = Sum, OwnerId = OwnerId, DrugId = DrugId, - DatePurchase = DatePurchase + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement }; } } diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Service.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Service.cs index 951f2c0..1e0b807 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Service.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Service.cs @@ -6,13 +6,13 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; -using VeterinaryDataModels; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; +using VeterinaryDataModels.Models; namespace VeterinaryDatabaseImplement.Models { - public class Service : IServiceModel + public class Service : IServiceModel { public int Id { get; set; } [Required] diff --git a/VeterinaryView/VeterinaryDatabaseImplement/Models/Visit.cs b/VeterinaryView/VeterinaryDatabaseImplement/Models/Visit.cs index 4221879..23c1506 100644 --- a/VeterinaryView/VeterinaryDatabaseImplement/Models/Visit.cs +++ b/VeterinaryView/VeterinaryDatabaseImplement/Models/Visit.cs @@ -2,11 +2,12 @@ using System.ComponentModel.DataAnnotations; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; +using VeterinaryDataModels.Enums; namespace VeterinaryDatabaseImplement.Models { - public class Visit : IVisitModel + public class Visit : IVisitModel { public int Id { get; private set; } [Required] @@ -16,6 +17,8 @@ namespace VeterinaryDatabaseImplement.Models public int? DoctorId { get; private set; } public virtual Doctor? Doctor { get; private set; } [Required] + public VisitStatus Status { get; private set; } + [Required] public DateTime DateVisit { get; private set; } private Dictionary? _visitPet = null; [NotMapped] @@ -43,6 +46,7 @@ namespace VeterinaryDatabaseImplement.Models Id = model.Id, OwnerId = model.OwnerId, DoctorId = model.DoctorId, + Status = model.Status, DateVisit = model.DateVisit, Pets = model.VisitPet.Select(x => new VisitPet { @@ -51,11 +55,20 @@ namespace VeterinaryDatabaseImplement.Models }).ToList() }; } + public void Update(VisitBindingModel? model) + { + if (model == null) + { + return; + } + Status = model.Status; + } public VisitViewModel GetViewModel => new() { Id = Id, OwnerId = OwnerId, DoctorId = DoctorId, + Status = Status, DateVisit = DateVisit }; }