add mapping between the service and server entities

This commit is contained in:
Andreas Zweili 2018-08-06 22:52:47 +02:00
parent 5d7b10148e
commit 090b09c4a0
4 changed files with 17 additions and 0 deletions

View File

@ -24,8 +24,12 @@ namespace Server.DB
using (Context ctx = new Context())
{
var country = ctx.Countries.FirstOrDefault(c => c.CountryID == city.Country.CountryID);
ctx.Countries.Attach(country);
ctx.Cities.Add(city);
city.Country = country;
ctx.SaveChanges();
}
return true;

View File

@ -34,6 +34,11 @@ namespace Server.DB
ctx.Countries.Attach(country);
ctx.Genders.Attach(gender);
ctx.Salutations.Attach(salutation);
doctor.City = city;
doctor.Salutation = salutation;
doctor.Gender = gender;
ctx.Doctors.Add(doctor);
ctx.SaveChanges();
}

View File

@ -47,6 +47,11 @@ namespace Server.DB
ctx.Genders.Attach(pGender);
ctx.Salutations.Attach(dSalutation);
ctx.Salutations.Attach(pSalutation);
exam.Doctor = doctor;
exam.Patient = patient;
exam.Strain = strain;
ctx.Exams.Add(exam);
ctx.SaveChanges();
}

View File

@ -29,6 +29,9 @@ namespace Server.DB
ctx.Cities.Attach(city);
ctx.Countries.Attach(country);
foodplace.City = city;
ctx.FoodPlaces.Add(foodplace);
ctx.SaveChanges();
}