add mapping between the service and server entities
This commit is contained in:
parent
f51572ed14
commit
224383ed0f
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ namespace Server.DB
|
|||
|
||||
ctx.Cities.Attach(city);
|
||||
ctx.Countries.Attach(country);
|
||||
|
||||
foodplace.City = city;
|
||||
|
||||
ctx.FoodPlaces.Add(foodplace);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue