Сделали бд
This commit is contained in:
parent
44d0c40065
commit
8d3c75cdf9
@ -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<GuidanceViewModel> GetFullList()
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Guidances.Include(x => x.Service).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<GuidanceViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<MedicineViewModel> 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<MedicineViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<PharmacistViewModel> GetFullList()
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Pharmacists
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<PharmacistViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<ServiceViewModel> 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<ServiceViewModel> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
@ -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<int, IAnimalModel>? _medicineAnimals =
|
||||
null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IAnimalModel> MedicineAnimals
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_medicineAnimals == null)
|
||||
{
|
||||
_medicineAnimals = Animals
|
||||
.ToDictionary(recPC => recPC.AnimalId, recPC =>
|
||||
recPC.Animal as IAnimalModel);
|
||||
}
|
||||
return _medicineAnimals;
|
||||
}
|
||||
}
|
||||
[ForeignKey("MedicineId")]
|
||||
public virtual List<MedicineAnimal> Animals { get; set; } = new();
|
||||
[ForeignKey("MedicineId")]
|
||||
public virtual List<ServiceMedicine> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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<Medicine> Medicines { get; set; } =
|
||||
new();
|
||||
[ForeignKey("PharmacistId")]
|
||||
public virtual List<Service> 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
|
||||
};
|
||||
}
|
||||
}
|
@ -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<int, (IMedicineModel, int)>? _serviceMedicines =
|
||||
null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IMedicineModel, int)> 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<ServiceMedicine> Medicines { get; set; } = new();
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<VisitService> Visits { get; set; } = new();
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<Guidance> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -7,11 +7,16 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VetClinicContracts\VetClinicContracts.csproj" />
|
||||
<ProjectReference Include="..\VetClinicDataBaseImplement\VetClinicDataBaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -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)
|
||||
|
@ -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<VaccinationViewModel> GetFullList()
|
||||
{
|
||||
|
@ -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<VisitViewModel> GetFullList()
|
||||
{
|
||||
|
521
VetClinic/VetClinicDataBaseImplement/Migrations/20240424171203_InitialCreate.Designer.cs
generated
Normal file
521
VetClinic/VetClinicDataBaseImplement/Migrations/20240424171203_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,521 @@
|
||||
// <auto-generated />
|
||||
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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AdminFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AnimalName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Family")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("VaccinationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Animals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Guidances");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MedicineName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.ToTable("MedicineAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PharmacistFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Pharmacists");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceMedicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("CostVaccination")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("DateStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("NameVaccination")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.ToTable("Vaccinations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("NameVisit")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,388 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VetClinicDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Admins",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AdminFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Admins", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Pharmacists",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PharmacistFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Pharmacists", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Animals",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AdminId = table.Column<int>(type: "int", nullable: false),
|
||||
VaccinationId = table.Column<int>(type: "int", nullable: false),
|
||||
AnimalName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Family = table.Column<string>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AdminId = table.Column<int>(type: "int", nullable: false),
|
||||
NameVisit = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateVisit = table.Column<DateTime>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MedicineName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PharmacistId = table.Column<int>(type: "int", nullable: false),
|
||||
Price = table.Column<double>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false),
|
||||
PharmacistId = table.Column<int>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AnimalId = table.Column<int>(type: "int", nullable: false),
|
||||
NameVaccination = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CostVaccination = table.Column<double>(type: "float", nullable: false),
|
||||
DateStamp = table.Column<DateTime>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AnimalId = table.Column<int>(type: "int", nullable: false),
|
||||
VisitId = table.Column<int>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MedicineId = table.Column<int>(type: "int", nullable: false),
|
||||
AnimalId = table.Column<int>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Date = table.Column<DateTime>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
MedicineId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(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<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
VisitId = table.Column<int>(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");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,518 @@
|
||||
// <auto-generated />
|
||||
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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AdminFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AnimalName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Family")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("VaccinationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Animals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Guidances");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MedicineName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.ToTable("MedicineAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PharmacistFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Pharmacists");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceMedicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("CostVaccination")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("DateStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("NameVaccination")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.ToTable("Vaccinations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("NameVisit")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("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
|
||||
}
|
||||
}
|
||||
}
|
@ -24,8 +24,8 @@ namespace VetClinicDataBaseImplement.Models
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
// [ForeignKey("AdminId")]
|
||||
//public virtual List<Visit> Visits { get; set; } = new();
|
||||
[ForeignKey("AdminId")]
|
||||
public virtual List<Visit> Visits { get; set; } = new();
|
||||
[ForeignKey("AdminId")]
|
||||
public virtual List<Animal> 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
|
||||
|
@ -36,7 +36,6 @@ namespace VetClinicDataBaseImplement.Models
|
||||
public virtual List<Vaccination> Vaccinations { get; set; } = new();
|
||||
|
||||
public virtual Admin Admin { get; set; }
|
||||
public virtual Vaccination Vaccination { get; set; }
|
||||
|
||||
[ForeignKey("AnimalId")]
|
||||
public virtual List<VisitAnimal> Visits { get; set; } = new();
|
||||
@ -57,6 +56,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
return _visitAnimals;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public Dictionary<int, IMedicineModel> MedicineAnimals
|
||||
{
|
||||
get
|
||||
|
@ -35,7 +35,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
public virtual List<VisitService> Services { get; set; } = new();
|
||||
|
||||
public virtual Admin Admin { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IAnimalModel> VisitAnimals
|
||||
{
|
||||
get
|
||||
@ -48,6 +48,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
return _visitAnimals;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public Dictionary<int, IServiceModel> ServiceVisits
|
||||
{
|
||||
get
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user