diff --git a/VetClinic/DinerDataBaseImplement/Implements/GuidanceStorage.cs b/VetClinic/DinerDataBaseImplement/Implements/GuidanceStorage.cs deleted file mode 100644 index 19fbcdf..0000000 --- a/VetClinic/DinerDataBaseImplement/Implements/GuidanceStorage.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VetClinicContracts.BindingModels; -using VetClinicContracts.SearchModels; -using VetClinicContracts.StoragesContracts; -using VetClinicContracts.ViewModels; -using VetClinicDataBaseImplement.Models; - -namespace VetClinicDataBaseImplement.Implements -{ - public class GuidanceStorage : IGuidanceStorage - { - public List GetFullList() - { - using var context = new VetClinicDatabase(); - return context.Guidances.Include(x => x.Service).Select(x => x.GetViewModel).ToList(); - } - public List GetFilteredList(GuidanceSearchModel model) - { - - using var context = new VetClinicDatabase(); - return context.Guidances.Include(x => x.Service).Where(x => (!model.Id.HasValue || model.Id == x.Id) - && (!model.ServiceId.HasValue || model.ServiceId == x.ServiceId) && (!model.DateFrom.HasValue || model.DateFrom <= x.Date) - && (!model.DateTo.HasValue || model.DateTo >= x.Date)) - .Select(x => x.GetViewModel) - .ToList(); - } - public GuidanceViewModel? GetElement(GuidanceSearchModel model) - { - using var context = new VetClinicDatabase(); - return context.Guidances.Include(x => x.Service).FirstOrDefault(x => (!model.Id.HasValue || model.Id == x.Id) - && (!model.ServiceId.HasValue || model.ServiceId == x.ServiceId) && (!model.DateFrom.HasValue || model.DateFrom <= x.Date) - && (!model.DateTo.HasValue || model.DateTo >= x.Date))?.GetViewModel; - } - public GuidanceViewModel? Insert(GuidanceBindingModel model) - { - using var context = new VetClinicDatabase(); - var newGuidance = Guidance.Create(context, model); - if (newGuidance == null) - { - return null; - } - context.Guidances.Add(newGuidance); - context.SaveChanges(); - return newGuidance.GetViewModel; - } - public GuidanceViewModel? Update(GuidanceBindingModel model) - { - using var context = new VetClinicDatabase(); - var element = context.Guidances - .Include(x => x.Service) - .FirstOrDefault(rec => rec.Id == model.Id); - if (element != null) - { - context.Guidances.Remove(element); - context.SaveChanges(); - return element.GetViewModel; - } - return null; - } - public GuidanceViewModel? Delete(GuidanceBindingModel model) - { - using var context = new VetClinicDatabase(); - var element = context.Guidances.FirstOrDefault(rec => rec.Id == - model.Id); - if (element != null) - { - context.Guidances.Remove(element); - context.SaveChanges(); - return element.GetViewModel; - } - return null; - } - } -} \ No newline at end of file diff --git a/VetClinic/DinerDataBaseImplement/Implements/MedicineStorage.cs b/VetClinic/DinerDataBaseImplement/Implements/MedicineStorage.cs deleted file mode 100644 index 1f843dd..0000000 --- a/VetClinic/DinerDataBaseImplement/Implements/MedicineStorage.cs +++ /dev/null @@ -1,105 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VetClinicContracts.BindingModels; -using VetClinicContracts.SearchModels; -using VetClinicContracts.StoragesContracts; -using VetClinicContracts.ViewModels; -using VetClinicDataBaseImplement.Models; - -namespace VetClinicDataBaseImplement.Implements -{ - public class MedicineStorage : IMedicineStorage - { - public List GetFullList() - { - using var context = new VetClinicDatabase(); - return context.Medicines.Include(x => x.Pharmacist).Include(x => x.Animals) - .ThenInclude(x => x.Animal) - .ToList() - .Select(x => x.GetViewModel) - .ToList(); - } - public List GetFilteredList(MedicineSearchModel model) - { - using var context = new VetClinicDatabase(); - return context.Medicines.Include(x => x.Pharmacist).Include(x => x.Animals) - .ThenInclude(x => x.Animal) - .Where(x => (string.IsNullOrEmpty(model.MedicineName) || x.MedicineName.Contains(model.MedicineName) - && (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId))) - .ToList() - .Select(x => x.GetViewModel) - .ToList(); - } - public MedicineViewModel? GetElement(MedicineSearchModel model) - { - if (string.IsNullOrEmpty(model.MedicineName) && - !model.Id.HasValue) - { - return null; - } - using var context = new VetClinicDatabase(); - return context.Medicines.Include(x => x.Pharmacist) - .Include(x => x.Animals) - .ThenInclude(x => x.Animal) - .FirstOrDefault(x => (!string.IsNullOrEmpty(model.MedicineName) && - x.MedicineName == model.MedicineName) || - (model.Id.HasValue && x.Id == - model.Id)) - ?.GetViewModel; - } - public MedicineViewModel? Insert(MedicineBindingModel model) - { - using var context = new VetClinicDatabase(); - var newMedicine = Medicine.Create(context, model); - if (newMedicine == null) - { - return null; - } - context.Medicines.Add(newMedicine); - context.SaveChanges(); - return newMedicine.GetViewModel; - } - public MedicineViewModel? Update(MedicineBindingModel model) - { - using var context = new VetClinicDatabase(); - using var transaction = context.Database.BeginTransaction(); - try - { - var medicine = context.Medicines.FirstOrDefault(rec => - rec.Id == model.Id); - if (medicine == null) - { - return null; - } - medicine.Update(model); - context.SaveChanges(); - medicine.UpdateAnimals(context, model); - transaction.Commit(); - return medicine.GetViewModel; - } - catch - { - transaction.Rollback(); - throw; - } - } - public MedicineViewModel? Delete(MedicineBindingModel model) - { - using var context = new VetClinicDatabase(); - var element = context.Medicines - .Include(x => x.Animals).ThenInclude(x => x.Animal) - .FirstOrDefault(rec => rec.Id == model.Id); - if (element != null) - { - context.Medicines.Remove(element); - context.SaveChanges(); - return element.GetViewModel; - } - return null; - } - } -} diff --git a/VetClinic/DinerDataBaseImplement/Implements/PharmacistStorage.cs b/VetClinic/DinerDataBaseImplement/Implements/PharmacistStorage.cs deleted file mode 100644 index f48bbbb..0000000 --- a/VetClinic/DinerDataBaseImplement/Implements/PharmacistStorage.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VetClinicContracts.BindingModels; -using VetClinicContracts.SearchModels; -using VetClinicContracts.StoragesContracts; -using VetClinicContracts.ViewModels; -using VetClinicDataBaseImplement.Models; - -namespace VetClinicDataBaseImplement.Implements -{ - public class PharmacistStorage : IPharmacistStorage - { - public List GetFullList() - { - using var context = new VetClinicDatabase(); - return context.Pharmacists - .Select(x => x.GetViewModel) - .ToList(); - } - public List GetFilteredList(PharmacistSearchModel model) - { - if (string.IsNullOrEmpty(model.PharmacistFIO) && string.IsNullOrEmpty(model.Email) && - string.IsNullOrEmpty(model.Password)) - { - return new(); - } - using var context = new VetClinicDatabase(); - return context.Pharmacists - .Where(x => (string.IsNullOrEmpty(model.PharmacistFIO) || x.PharmacistFIO.Contains(model.PharmacistFIO) && - string.IsNullOrEmpty(model.Email) || x.Email.Contains(model.Email) && - string.IsNullOrEmpty(model.Password) || x.Password.Contains(model.Password))) - .Select(x => x.GetViewModel) - .ToList(); - } - public PharmacistViewModel? GetElement(PharmacistSearchModel model) - { - if (string.IsNullOrEmpty(model.PharmacistFIO) && string.IsNullOrEmpty(model.Email) && - !model.Id.HasValue) - { - return null; - } - using var context = new VetClinicDatabase(); - return context.Pharmacists - .FirstOrDefault(x => (string.IsNullOrEmpty(model.PharmacistFIO) || x.PharmacistFIO == model.PharmacistFIO) && - (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email) && - (string.IsNullOrEmpty(model.Password) || x.Password == model.Password)) - ?.GetViewModel; - } - public PharmacistViewModel? Insert(PharmacistBindingModel model) - { - var newPharmacist = Pharmacist.Create(model); - if (newPharmacist == null) - { - return null; - } - using var context = new VetClinicDatabase(); - context.Pharmacists.Add(newPharmacist); - context.SaveChanges(); - return newPharmacist.GetViewModel; - } - public PharmacistViewModel? Update(PharmacistBindingModel model) - { - using var context = new VetClinicDatabase(); - var pharmacist = context.Pharmacists.FirstOrDefault(x => x.Id == model.Id); - if (pharmacist == null) - { - return null; - } - pharmacist.Update(model); - context.SaveChanges(); - return pharmacist.GetViewModel; - } - public PharmacistViewModel? Delete(PharmacistBindingModel model) - { - using var context = new VetClinicDatabase(); - var element = context.Pharmacists.FirstOrDefault(rec => rec.Id == model.Id); - if (element != null) - { - context.Pharmacists.Remove(element); - context.SaveChanges(); - return element.GetViewModel; - } - return null; - } - } -} diff --git a/VetClinic/DinerDataBaseImplement/Implements/ServiceStorage.cs b/VetClinic/DinerDataBaseImplement/Implements/ServiceStorage.cs deleted file mode 100644 index 19a6bb0..0000000 --- a/VetClinic/DinerDataBaseImplement/Implements/ServiceStorage.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VetClinicContracts.BindingModels; -using VetClinicContracts.SearchModels; -using VetClinicContracts.StoragesContracts; -using VetClinicContracts.ViewModels; -using VetClinicDataBaseImplement.Models; - -namespace VetClinicDataBaseImplement.Implements -{ - public class ServiceStorage : IServiceStorage - { - public List GetFullList() - { - using var context = new VetClinicDatabase(); - return context.Services.Include(x => x.Pharmacist) - .Include(x => x.Medicines) - .ThenInclude(x => x.Medicine) - .ToList() - .Select(x => x.GetViewModel) - .ToList(); - } - public List GetFilteredList(ServiceSearchModel model) - { - using var context = new VetClinicDatabase(); - return context.Services.Include(x => x.Pharmacist) - .Include(x => x.Medicines) - .ThenInclude(x => x.Medicine) - .Where(x => (string.IsNullOrEmpty(model.ServiceName) || x.ServiceName.Contains(model.ServiceName) - && (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId))) - .ToList() - .Select(x => x.GetViewModel) - .ToList(); - } - public ServiceViewModel? GetElement(ServiceSearchModel model) - { - if (string.IsNullOrEmpty(model.ServiceName) && - !model.Id.HasValue) - { - return null; - } - using var context = new VetClinicDatabase(); - return context.Services.Include(x => x.Pharmacist) - .Include(x => x.Medicines) - .ThenInclude(x => x.Medicine) - .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ServiceName) && - x.ServiceName == model.ServiceName) || - (model.Id.HasValue && x.Id == - model.Id)) - ?.GetViewModel; - } - public ServiceViewModel? Insert(ServiceBindingModel model) - { - using var context = new VetClinicDatabase(); - var newService = Service.Create(context, model); - if (newService == null) - { - return null; - } - context.Services.Add(newService); - context.SaveChanges(); - return newService.GetViewModel; - } - public ServiceViewModel? Update(ServiceBindingModel model) - { - using var context = new VetClinicDatabase(); - using var transaction = context.Database.BeginTransaction(); - try - { - var iceCream = context.Services.FirstOrDefault(rec => - rec.Id == model.Id); - if (iceCream == null) - { - return null; - } - iceCream.Update(model); - context.SaveChanges(); - iceCream.UpdateMedicines(context, model); - transaction.Commit(); - return iceCream.GetViewModel; - } - catch - { - transaction.Rollback(); - throw; - } - } - public ServiceViewModel? Delete(ServiceBindingModel model) - { - using var context = new VetClinicDatabase(); - var element = context.Services - .Include(x => x.Medicines) - .ThenInclude(x => x.Medicine) - .ThenInclude(x => x.Animals).ThenInclude(x => x.Animal) - .FirstOrDefault(rec => rec.Id == model.Id); - if (element != null) - { - context.Services.Remove(element); - context.SaveChanges(); - return element.GetViewModel; - } - return null; - } - } -} diff --git a/VetClinic/DinerDataBaseImplement/Models/Guidance.cs b/VetClinic/DinerDataBaseImplement/Models/Guidance.cs deleted file mode 100644 index e8c68ad..0000000 --- a/VetClinic/DinerDataBaseImplement/Models/Guidance.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VetClinicContracts.BindingModels; -using VetClinicContracts.ViewModels; -using VetClinicDataModels.Models; - -namespace VetClinicDataBaseImplement.Models -{ - public class Guidance : IGuidanceModel - { - public int Id { get; private set; } - [Required] - public int ServiceId { get; private set; } - public virtual Service Service { get; private set; } - [Required] - public string Text { get; private set; } = string.Empty; - [Required] - public DateTime Date { get; private set; } - public static Guidance? Create(VetClinicDatabase context, GuidanceBindingModel model) - { - if (model == null) - { - return null; - } - return new Guidance() - { - Id = model.Id, - ServiceId = model.ServiceId, - Text = model.Text, - Date = model.Date, - Service = context.Services.FirstOrDefault(x => x.Id == model.ServiceId), - }; - } - - public void Update(GuidanceBindingModel? model) - { - if (model == null) - { - return; - } - Text = model.Text; - Date = model.Date; - } - - public GuidanceViewModel GetViewModel => new() - { - ServiceId = ServiceId, - Text = Text, - Date = Date, - Id = Id, - ServiceName = Service.ServiceName - }; - } -} diff --git a/VetClinic/DinerDataBaseImplement/Models/Medicine.cs b/VetClinic/DinerDataBaseImplement/Models/Medicine.cs deleted file mode 100644 index 91c993f..0000000 --- a/VetClinic/DinerDataBaseImplement/Models/Medicine.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VetClinicDataModels.Models; -using VetClinicContracts.BindingModels; -using VetClinicContracts.ViewModels; - -namespace VetClinicDataBaseImplement.Models -{ - public class Medicine : IMedicineModel - { - public int Id { get; set; } - [Required] - public string MedicineName { get; set; } = string.Empty; - [Required] - public int PharmacistId { get; set; } - public virtual Pharmacist Pharmacist { get; private set; } - [Required] - public double Price { get; set; } - private Dictionary? _medicineAnimals = - null; - [NotMapped] - public Dictionary MedicineAnimals - { - get - { - if (_medicineAnimals == null) - { - _medicineAnimals = Animals - .ToDictionary(recPC => recPC.AnimalId, recPC => - recPC.Animal as IAnimalModel); - } - return _medicineAnimals; - } - } - [ForeignKey("MedicineId")] - public virtual List Animals { get; set; } = new(); - [ForeignKey("MedicineId")] - public virtual List Services { get; set; } = new(); - public static Medicine Create(VetClinicDatabase context, - MedicineBindingModel model) - { - return new Medicine() - { - Id = model.Id, - MedicineName = model.MedicineName, - Price = model.Price, - Animals = model.MedicineAnimals.Select(x => new - MedicineAnimal - { - Animal = context.Animals.First(y => y.Id == x.Key), - }).ToList(), - Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId) - }; - } - public void Update(MedicineBindingModel model) - { - MedicineName = model.MedicineName; - Price = model.Price; - } - public MedicineViewModel GetViewModel => new() - { - Id = Id, - MedicineName = MedicineName, - Price = Price, - MedicineAnimals = MedicineAnimals, - PharmacistFIO = Pharmacist.PharmacistFIO - }; - public void UpdateAnimals(VetClinicDatabase context, - MedicineBindingModel model) - { - var medicineAnimals = context.MedicineAnimals.Where(rec => - rec.MedicineId == model.Id).ToList(); - if (medicineAnimals != null && medicineAnimals.Count > 0) - { - context.MedicineAnimals.RemoveRange(medicineAnimals.Where(rec -=> !model.MedicineAnimals.ContainsKey(rec.AnimalId))); - - context.SaveChanges(); - } - var medicine = context.Medicines.First(x => x.Id == Id); - foreach (var pc in model.MedicineAnimals) - { - context.MedicineAnimals.Add(new MedicineAnimal - { - Medicine = medicine, - Animal = context.Animals.First(x => x.Id == pc.Key), - }); - context.SaveChanges(); - } - _medicineAnimals = null; - } - } -} diff --git a/VetClinic/DinerDataBaseImplement/Models/MedicineAnimal.cs b/VetClinic/DinerDataBaseImplement/Models/MedicineAnimal.cs deleted file mode 100644 index 22d06e3..0000000 --- a/VetClinic/DinerDataBaseImplement/Models/MedicineAnimal.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VetClinicDataBaseImplement.Models -{ - public class MedicineAnimal - { - public int Id { get; set; } - [Required] - public int MedicineId { get; set; } - [Required] - public int AnimalId { get; set; } - public virtual Medicine Medicine { get; set; } = new(); - public virtual Animal Animal { get; set; } = new(); - } -} diff --git a/VetClinic/DinerDataBaseImplement/Models/Pharmacist.cs b/VetClinic/DinerDataBaseImplement/Models/Pharmacist.cs deleted file mode 100644 index 502cf68..0000000 --- a/VetClinic/DinerDataBaseImplement/Models/Pharmacist.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VetClinicContracts.BindingModels; -using VetClinicContracts.ViewModels; -using VetClinicDataModels.Models; - -namespace VetClinicDataBaseImplement.Models -{ - public class Pharmacist : IPharmacistModel - { - public int Id { get; private set; } - [Required] - public string PharmacistFIO { get; private set; } = string.Empty; - [Required] - public string Email { get; set; } = string.Empty; - [Required] - public string Password { get; set; } = string.Empty; - [ForeignKey("PharmacistId")] - public virtual List Medicines { get; set; } = - new(); - [ForeignKey("PharmacistId")] - public virtual List Services { get; set; } = - new(); - - public static Pharmacist? Create(PharmacistBindingModel model) - { - if (model == null) - { - return null; - } - return new Pharmacist() - { - Id = model.Id, - PharmacistFIO = model.PharmacistFIO, - Email = model.Email, - Password = model.Password - }; - } - - public static Pharmacist Create(PharmacistViewModel model) - { - return new Pharmacist() - { - Id = model.Id, - PharmacistFIO = model.PharmacistFIO, - Email = model.Email, - Password = model.Password - }; - } - public void Update( PharmacistBindingModel model) - { - if (model == null) - { - return; - } - PharmacistFIO = model.PharmacistFIO; - Email = model.Email; - Password = model.Password; - } - public PharmacistViewModel GetViewModel => new() - { - Id = Id, - PharmacistFIO = PharmacistFIO, - Email = Email, - Password = Password - }; - } -} diff --git a/VetClinic/DinerDataBaseImplement/Models/Service.cs b/VetClinic/DinerDataBaseImplement/Models/Service.cs deleted file mode 100644 index 751400d..0000000 --- a/VetClinic/DinerDataBaseImplement/Models/Service.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VetClinicDataModels.Models; -using VetClinicContracts.BindingModels; -using VetClinicContracts.ViewModels; -using Microsoft.EntityFrameworkCore; - -namespace VetClinicDataBaseImplement.Models -{ - public class Service : IServiceModel - { - public int Id { get; set; } - [Required] - public string ServiceName { get; set; } = string.Empty; - [Required] - public double Price { get; set; } - [Required] - public int PharmacistId { get; set; } - public virtual Pharmacist Pharmacist { get; private set; } - private Dictionary? _serviceMedicines = - null; - [NotMapped] - public Dictionary ServiceMedicines - { - get - { - if (_serviceMedicines == null) - { - _serviceMedicines = Medicines - .ToDictionary(recPC => recPC.MedicineId, recPC => - (recPC.Medicine as IMedicineModel, recPC.Count)); - } - return _serviceMedicines; - } - } - [ForeignKey("ServiceId")] - public virtual List Medicines { get; set; } = new(); - [ForeignKey("ServiceId")] - public virtual List Visits { get; set; } = new(); - [ForeignKey("ServiceId")] - public virtual List Guidances { get; set; } = new(); - public static Service Create(VetClinicDatabase context, - ServiceBindingModel model) - { - return new Service() - { - Id = model.Id, - ServiceName = model.ServiceName, - Price = model.Price, - Medicines = model.ServiceMedicines.Select(x => new - ServiceMedicine - { - Medicine = context.Medicines.First(y => y.Id == x.Key), - Count = x.Value.Item2 - }).ToList() - }; - } - public void Update(ServiceBindingModel model) - { - ServiceName = model.ServiceName; - Price = model.Price; - } - public ServiceViewModel GetViewModel => new() - { - Id = Id, - ServiceName = ServiceName, - Price = Price, - ServiceMedicines = ServiceMedicines - }; - public void UpdateMedicines(VetClinicDatabase context, - ServiceBindingModel model) - { - var serviceMedicines = context.ServiceMedicines.Where(rec => - rec.ServiceId == model.Id).ToList(); - if (serviceMedicines != null && serviceMedicines.Count > 0) - { - context.ServiceMedicines.RemoveRange(serviceMedicines.Where(rec -=> !model.ServiceMedicines.ContainsKey(rec.MedicineId))); - - context.SaveChanges(); - foreach (var updateComponent in serviceMedicines) - { - updateComponent.Count = - model.ServiceMedicines[updateComponent.MedicineId].Item2; - model.ServiceMedicines.Remove(updateComponent.MedicineId); - } - context.SaveChanges(); - } - var service = context.Services.First(x => x.Id == Id); - foreach (var pc in model.ServiceMedicines) - { - context.ServiceMedicines.Add(new ServiceMedicine - { - Service = service, - Medicine = context.Medicines.Include(x => x.Animals).ThenInclude(x => x.Animal).First(x => x.Id == pc.Key), - Count = pc.Value.Item2 - }); - context.SaveChanges(); - } - _serviceMedicines = null; - } - } -} diff --git a/VetClinic/DinerDataBaseImplement/Models/ServiceMedicine.cs b/VetClinic/DinerDataBaseImplement/Models/ServiceMedicine.cs deleted file mode 100644 index 5e3b3d0..0000000 --- a/VetClinic/DinerDataBaseImplement/Models/ServiceMedicine.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VetClinicDataBaseImplement.Models -{ - public class ServiceMedicine - { - public int Id { get; set; } - [Required] - public int ServiceId { get; set; } - [Required] - public int MedicineId { get; set; } - [Required] - public int Count { get; set; } - public virtual Service Service { get; set; } = new(); - public virtual Medicine Medicine { get; set; } = new(); - } -} diff --git a/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs b/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs index 511acbb..97c4d2d 100644 --- a/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs +++ b/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs @@ -52,7 +52,7 @@ namespace VetClinicAdminApp.Controllers APIAdmin.PostRequest("api/admin/updatedata", new AdminBindingModel { - AdminId = APIAdmin.Admin.Id, + Id = APIAdmin.Admin.Id, AdminFIO = fio, Email = login, Password = password diff --git a/VetClinic/VetClinicAdminApi/VetClinicAdminApp.csproj b/VetClinic/VetClinicAdminApi/VetClinicAdminApp.csproj index 15d14fc..ed11aff 100644 --- a/VetClinic/VetClinicAdminApi/VetClinicAdminApp.csproj +++ b/VetClinic/VetClinicAdminApi/VetClinicAdminApp.csproj @@ -7,11 +7,16 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/AnimalStorage.cs b/VetClinic/VetClinicDataBaseImplement/Implements/AnimalStorage.cs index 5114525..a6e2270 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/AnimalStorage.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/AnimalStorage.cs @@ -15,7 +15,7 @@ namespace VetClinicBaseImplement.Implements using var context = new VetClinicDatabase(); return context.Animals - .Include(x => x.Vaccination) + .Include(x => x.Vaccinations) .Include(x => x.Admin) .Include(x => x.Visits) .ThenInclude(x => x.Visit) @@ -32,7 +32,7 @@ namespace VetClinicBaseImplement.Implements using var context = new VetClinicDatabase(); return context.Animals .Include(x => x.Admin) - .Include(x => x.Vaccination) + .Include(x => x.Vaccinations) .Include(x => x.Visits) .ThenInclude(x => x.Visit) .Where(x => x.AnimalName.Contains(model.AnimalName)) @@ -48,10 +48,10 @@ namespace VetClinicBaseImplement.Implements using var context = new VetClinicDatabase(); return context.Animals .Include(x => x.Admin) - .Include(x => x.Vaccination) + .Include(x => x.Vaccinations) .Include(x => x.Visits) .ThenInclude(x => x.Visit) - .Include(x => x.Vaccination) + .Include(x => x.Vaccinations) .FirstOrDefault(x => (!string.IsNullOrEmpty(model.AnimalName) && x.AnimalName == model.AnimalName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } public AnimalViewModel? Insert(AnimalBindingModel model) diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/VaccinationStorage.cs b/VetClinic/VetClinicDataBaseImplement/Implements/VaccinationStorage.cs index cf0f619..bf8a591 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/VaccinationStorage.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/VaccinationStorage.cs @@ -6,12 +6,13 @@ using System.Text; using System.Threading.Tasks; using VetClinicContracts.BindingModels; using VetClinicContracts.SearchModels; +using VetClinicContracts.StoragesContracts; using VetClinicContracts.ViewModels; using VetClinicDataBaseImplement.Models; namespace VetClinicDataBaseImplement.Implements { - public class VaccinationStorage + public class VaccinationStorage : IVaccinationStorage { public List GetFullList() { diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/VisitStorage.cs b/VetClinic/VetClinicDataBaseImplement/Implements/VisitStorage.cs index 4ecbbf4..7ac26a3 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/VisitStorage.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/VisitStorage.cs @@ -6,12 +6,13 @@ using System.Text; using System.Threading.Tasks; using VetClinicContracts.BindingModels; using VetClinicContracts.SearchModels; +using VetClinicContracts.StoragesContracts; using VetClinicContracts.ViewModels; using VetClinicDataBaseImplement.Models; namespace VetClinicDataBaseImplement.Implements { - public class VisitStorage + public class VisitStorage : IVisitStorage { public List GetFullList() { diff --git a/VetClinic/VetClinicDataBaseImplement/Migrations/20240424171203_InitialCreate.Designer.cs b/VetClinic/VetClinicDataBaseImplement/Migrations/20240424171203_InitialCreate.Designer.cs new file mode 100644 index 0000000..f5b6d86 --- /dev/null +++ b/VetClinic/VetClinicDataBaseImplement/Migrations/20240424171203_InitialCreate.Designer.cs @@ -0,0 +1,521 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using VetClinicDataBaseImplement; + +#nullable disable + +namespace VetClinicDataBaseImplement.Migrations +{ + [DbContext(typeof(VetClinicDatabase))] + [Migration("20240424171203_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdminFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Admins"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdminId") + .HasColumnType("int"); + + b.Property("AnimalName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Family") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VaccinationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AdminId"); + + b.ToTable("Animals"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.Property("Text") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.ToTable("Guidances"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MedicineName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PharmacistId") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("PharmacistId"); + + b.ToTable("Medicines"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("int"); + + b.Property("MedicineId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("MedicineId"); + + b.ToTable("MedicineAnimals"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PharmacistFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Pharmacists"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PharmacistId") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("ServiceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("PharmacistId"); + + b.ToTable("Services"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("MedicineId") + .HasColumnType("int"); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MedicineId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceMedicines"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("int"); + + b.Property("CostVaccination") + .HasColumnType("float"); + + b.Property("DateStamp") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("NameVaccination") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.ToTable("Vaccinations"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdminId") + .HasColumnType("int"); + + b.Property("DateVisit") + .HasColumnType("datetime2"); + + b.Property("NameVisit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AdminId"); + + b.ToTable("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("int"); + + b.Property("VisitId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("VisitId"); + + b.ToTable("VisitAnimals"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.Property("VisitId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.HasIndex("VisitId"); + + b.ToTable("ServiceVisits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin") + .WithMany("Animals") + .HasForeignKey("AdminId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Admin"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Guidances") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist") + .WithMany("Medicines") + .HasForeignKey("PharmacistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Pharmacist"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Medicines") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine") + .WithMany("Animals") + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Medicine"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist") + .WithMany("Services") + .HasForeignKey("PharmacistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Pharmacist"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine") + .WithMany("Services") + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Medicines") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medicine"); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Vaccinations") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin") + .WithMany("Visits") + .HasForeignKey("AdminId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Admin"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Visits") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit") + .WithMany("Animals") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Visits") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit") + .WithMany("Services") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Service"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b => + { + b.Navigation("Animals"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.Navigation("Medicines"); + + b.Navigation("Vaccinations"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.Navigation("Animals"); + + b.Navigation("Services"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b => + { + b.Navigation("Medicines"); + + b.Navigation("Services"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.Navigation("Guidances"); + + b.Navigation("Medicines"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.Navigation("Animals"); + + b.Navigation("Services"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/VetClinic/VetClinicDataBaseImplement/Migrations/20240424171203_InitialCreate.cs b/VetClinic/VetClinicDataBaseImplement/Migrations/20240424171203_InitialCreate.cs new file mode 100644 index 0000000..3a3e9ba --- /dev/null +++ b/VetClinic/VetClinicDataBaseImplement/Migrations/20240424171203_InitialCreate.cs @@ -0,0 +1,388 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VetClinicDataBaseImplement.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Admins", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AdminFIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Admins", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Pharmacists", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PharmacistFIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Pharmacists", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Animals", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AdminId = table.Column(type: "int", nullable: false), + VaccinationId = table.Column(type: "int", nullable: false), + AnimalName = table.Column(type: "nvarchar(max)", nullable: false), + Family = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Animals", x => x.Id); + table.ForeignKey( + name: "FK_Animals_Admins_AdminId", + column: x => x.AdminId, + principalTable: "Admins", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Visits", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AdminId = table.Column(type: "int", nullable: false), + NameVisit = table.Column(type: "nvarchar(max)", nullable: false), + DateVisit = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Visits", x => x.Id); + table.ForeignKey( + name: "FK_Visits_Admins_AdminId", + column: x => x.AdminId, + principalTable: "Admins", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Medicines", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MedicineName = table.Column(type: "nvarchar(max)", nullable: false), + PharmacistId = table.Column(type: "int", nullable: false), + Price = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Medicines", x => x.Id); + table.ForeignKey( + name: "FK_Medicines_Pharmacists_PharmacistId", + column: x => x.PharmacistId, + principalTable: "Pharmacists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Services", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceName = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "float", nullable: false), + PharmacistId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Services", x => x.Id); + table.ForeignKey( + name: "FK_Services_Pharmacists_PharmacistId", + column: x => x.PharmacistId, + principalTable: "Pharmacists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Vaccinations", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AnimalId = table.Column(type: "int", nullable: false), + NameVaccination = table.Column(type: "nvarchar(max)", nullable: false), + CostVaccination = table.Column(type: "float", nullable: false), + DateStamp = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Vaccinations", x => x.Id); + table.ForeignKey( + name: "FK_Vaccinations_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VisitAnimals", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AnimalId = table.Column(type: "int", nullable: false), + VisitId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VisitAnimals", x => x.Id); + table.ForeignKey( + name: "FK_VisitAnimals_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_VisitAnimals_Visits_VisitId", + column: x => x.VisitId, + principalTable: "Visits", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "MedicineAnimals", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MedicineId = table.Column(type: "int", nullable: false), + AnimalId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MedicineAnimals", x => x.Id); + table.ForeignKey( + name: "FK_MedicineAnimals_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_MedicineAnimals_Medicines_MedicineId", + column: x => x.MedicineId, + principalTable: "Medicines", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Guidances", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceId = table.Column(type: "int", nullable: false), + Text = table.Column(type: "nvarchar(max)", nullable: false), + Date = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Guidances", x => x.Id); + table.ForeignKey( + name: "FK_Guidances_Services_ServiceId", + column: x => x.ServiceId, + principalTable: "Services", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ServiceMedicines", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceId = table.Column(type: "int", nullable: false), + MedicineId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ServiceMedicines", x => x.Id); + table.ForeignKey( + name: "FK_ServiceMedicines_Medicines_MedicineId", + column: x => x.MedicineId, + principalTable: "Medicines", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ServiceMedicines_Services_ServiceId", + column: x => x.ServiceId, + principalTable: "Services", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "ServiceVisits", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceId = table.Column(type: "int", nullable: false), + VisitId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ServiceVisits", x => x.Id); + table.ForeignKey( + name: "FK_ServiceVisits_Services_ServiceId", + column: x => x.ServiceId, + principalTable: "Services", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ServiceVisits_Visits_VisitId", + column: x => x.VisitId, + principalTable: "Visits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Animals_AdminId", + table: "Animals", + column: "AdminId"); + + migrationBuilder.CreateIndex( + name: "IX_Guidances_ServiceId", + table: "Guidances", + column: "ServiceId"); + + migrationBuilder.CreateIndex( + name: "IX_MedicineAnimals_AnimalId", + table: "MedicineAnimals", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_MedicineAnimals_MedicineId", + table: "MedicineAnimals", + column: "MedicineId"); + + migrationBuilder.CreateIndex( + name: "IX_Medicines_PharmacistId", + table: "Medicines", + column: "PharmacistId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceMedicines_MedicineId", + table: "ServiceMedicines", + column: "MedicineId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceMedicines_ServiceId", + table: "ServiceMedicines", + column: "ServiceId"); + + migrationBuilder.CreateIndex( + name: "IX_Services_PharmacistId", + table: "Services", + column: "PharmacistId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceVisits_ServiceId", + table: "ServiceVisits", + column: "ServiceId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceVisits_VisitId", + table: "ServiceVisits", + column: "VisitId"); + + migrationBuilder.CreateIndex( + name: "IX_Vaccinations_AnimalId", + table: "Vaccinations", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitAnimals_AnimalId", + table: "VisitAnimals", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitAnimals_VisitId", + table: "VisitAnimals", + column: "VisitId"); + + migrationBuilder.CreateIndex( + name: "IX_Visits_AdminId", + table: "Visits", + column: "AdminId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Guidances"); + + migrationBuilder.DropTable( + name: "MedicineAnimals"); + + migrationBuilder.DropTable( + name: "ServiceMedicines"); + + migrationBuilder.DropTable( + name: "ServiceVisits"); + + migrationBuilder.DropTable( + name: "Vaccinations"); + + migrationBuilder.DropTable( + name: "VisitAnimals"); + + migrationBuilder.DropTable( + name: "Medicines"); + + migrationBuilder.DropTable( + name: "Services"); + + migrationBuilder.DropTable( + name: "Animals"); + + migrationBuilder.DropTable( + name: "Visits"); + + migrationBuilder.DropTable( + name: "Pharmacists"); + + migrationBuilder.DropTable( + name: "Admins"); + } + } +} diff --git a/VetClinic/VetClinicDataBaseImplement/Migrations/VetClinicDatabaseModelSnapshot.cs b/VetClinic/VetClinicDataBaseImplement/Migrations/VetClinicDatabaseModelSnapshot.cs new file mode 100644 index 0000000..a1b5f0f --- /dev/null +++ b/VetClinic/VetClinicDataBaseImplement/Migrations/VetClinicDatabaseModelSnapshot.cs @@ -0,0 +1,518 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using VetClinicDataBaseImplement; + +#nullable disable + +namespace VetClinicDataBaseImplement.Migrations +{ + [DbContext(typeof(VetClinicDatabase))] + partial class VetClinicDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdminFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Admins"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdminId") + .HasColumnType("int"); + + b.Property("AnimalName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Family") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VaccinationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AdminId"); + + b.ToTable("Animals"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.Property("Text") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.ToTable("Guidances"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MedicineName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PharmacistId") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("PharmacistId"); + + b.ToTable("Medicines"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("int"); + + b.Property("MedicineId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("MedicineId"); + + b.ToTable("MedicineAnimals"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PharmacistFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Pharmacists"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PharmacistId") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("ServiceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("PharmacistId"); + + b.ToTable("Services"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("MedicineId") + .HasColumnType("int"); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MedicineId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceMedicines"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("int"); + + b.Property("CostVaccination") + .HasColumnType("float"); + + b.Property("DateStamp") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("NameVaccination") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.ToTable("Vaccinations"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdminId") + .HasColumnType("int"); + + b.Property("DateVisit") + .HasColumnType("datetime2"); + + b.Property("NameVisit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AdminId"); + + b.ToTable("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("int"); + + b.Property("VisitId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("VisitId"); + + b.ToTable("VisitAnimals"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.Property("VisitId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.HasIndex("VisitId"); + + b.ToTable("ServiceVisits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin") + .WithMany("Animals") + .HasForeignKey("AdminId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Admin"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Guidances") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist") + .WithMany("Medicines") + .HasForeignKey("PharmacistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Pharmacist"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Medicines") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine") + .WithMany("Animals") + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Medicine"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist") + .WithMany("Services") + .HasForeignKey("PharmacistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Pharmacist"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine") + .WithMany("Services") + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Medicines") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medicine"); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Vaccinations") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin") + .WithMany("Visits") + .HasForeignKey("AdminId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Admin"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Visits") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit") + .WithMany("Animals") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Visits") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit") + .WithMany("Services") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Service"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b => + { + b.Navigation("Animals"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.Navigation("Medicines"); + + b.Navigation("Vaccinations"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.Navigation("Animals"); + + b.Navigation("Services"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b => + { + b.Navigation("Medicines"); + + b.Navigation("Services"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.Navigation("Guidances"); + + b.Navigation("Medicines"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.Navigation("Animals"); + + b.Navigation("Services"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/VetClinic/VetClinicDataBaseImplement/Models/Admin.cs b/VetClinic/VetClinicDataBaseImplement/Models/Admin.cs index ee0a3aa..16662a8 100644 --- a/VetClinic/VetClinicDataBaseImplement/Models/Admin.cs +++ b/VetClinic/VetClinicDataBaseImplement/Models/Admin.cs @@ -24,8 +24,8 @@ namespace VetClinicDataBaseImplement.Models [Required] public string Password { get; set; } = string.Empty; - // [ForeignKey("AdminId")] - //public virtual List Visits { get; set; } = new(); + [ForeignKey("AdminId")] + public virtual List Visits { get; set; } = new(); [ForeignKey("AdminId")] public virtual List Animals { get; set; } = new(); public static Admin? Create(AdminBindingModel model) @@ -36,7 +36,7 @@ namespace VetClinicDataBaseImplement.Models } return new Admin() { - Id = model.AdminId, + Id = model.Id, AdminFIO = model.AdminFIO, Email = model.Email, Password = model.Password diff --git a/VetClinic/VetClinicDataBaseImplement/Models/Animal.cs b/VetClinic/VetClinicDataBaseImplement/Models/Animal.cs index 7c37bf3..db49a49 100644 --- a/VetClinic/VetClinicDataBaseImplement/Models/Animal.cs +++ b/VetClinic/VetClinicDataBaseImplement/Models/Animal.cs @@ -36,7 +36,6 @@ namespace VetClinicDataBaseImplement.Models public virtual List Vaccinations { get; set; } = new(); public virtual Admin Admin { get; set; } - public virtual Vaccination Vaccination { get; set; } [ForeignKey("AnimalId")] public virtual List Visits { get; set; } = new(); @@ -57,6 +56,7 @@ namespace VetClinicDataBaseImplement.Models return _visitAnimals; } } + [NotMapped] public Dictionary MedicineAnimals { get diff --git a/VetClinic/VetClinicDataBaseImplement/Models/Visit.cs b/VetClinic/VetClinicDataBaseImplement/Models/Visit.cs index e68a0a3..a27c9b4 100644 --- a/VetClinic/VetClinicDataBaseImplement/Models/Visit.cs +++ b/VetClinic/VetClinicDataBaseImplement/Models/Visit.cs @@ -35,7 +35,7 @@ namespace VetClinicDataBaseImplement.Models public virtual List Services { get; set; } = new(); public virtual Admin Admin { get; set; } - + [NotMapped] public Dictionary VisitAnimals { get @@ -48,6 +48,7 @@ namespace VetClinicDataBaseImplement.Models return _visitAnimals; } } + [NotMapped] public Dictionary ServiceVisits { get diff --git a/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs b/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs index e3aa818..3aa2bb9 100644 --- a/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs +++ b/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs @@ -11,7 +11,7 @@ namespace VetClinicDataBaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS02;Initial Catalog=DinerDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); }