Add mappings for the PatientAtFoodPlaceDB
I have no idea why we need this but shit keeps breaking without it :)
This commit is contained in:
parent
afe5d23865
commit
3ce42280d3
|
@ -26,6 +26,27 @@ namespace Server.DB
|
|||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
var patient = ctx.Persons.FirstOrDefault(p => p.PersonID == patientAtFoodPlace.Patient.PersonID);
|
||||
var foodplace = ctx.FoodPlaces.FirstOrDefault(f => f.FoodPlaceID == patientAtFoodPlace.FoodPlace.FoodPlaceID);
|
||||
var pcity = ctx.Cities.FirstOrDefault(c => c.CityID == patient.City.CityID);
|
||||
var fcity = ctx.Cities.FirstOrDefault(c => c.CityID == patientAtFoodPlace.FoodPlace.City.CityID);
|
||||
var pcountry = ctx.Countries.FirstOrDefault(c => c.CountryID == pcity.Country.CountryID);
|
||||
var fcountry = ctx.Countries.FirstOrDefault(c => c.CountryID == fcity.Country.CountryID);
|
||||
var salutation = ctx.Salutations.FirstOrDefault(s => s.SalutationID == patient.Salutation.SalutationID);
|
||||
var gender = ctx.Genders.FirstOrDefault(g => g.GenderID == patient.Gender.GenderID);
|
||||
|
||||
ctx.Cities.Attach(pcity);
|
||||
ctx.Cities.Attach(fcity);
|
||||
ctx.Countries.Attach(pcountry);
|
||||
ctx.Countries.Attach(fcountry);
|
||||
ctx.Genders.Attach(gender);
|
||||
ctx.Salutations.Attach(salutation);
|
||||
ctx.Persons.Attach(patient);
|
||||
ctx.FoodPlaces.Attach(foodplace);
|
||||
|
||||
patientAtFoodPlace.FoodPlace = foodplace;
|
||||
patientAtFoodPlace.Patient = patient;
|
||||
|
||||
ctx.PatientAtFoodPlaces.Add(patientAtFoodPlace);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue