Revert "make sure that foodplaces and relations don't appear twice in the DB"

This reverts commit 382b9be68a.
This commit is contained in:
Andreas Zweili 2018-09-02 15:58:30 +02:00
parent 6e9f708af7
commit e477b25be1
2 changed files with 29 additions and 49 deletions

View File

@ -23,16 +23,6 @@ namespace Server.DB
try
{
using (Context ctx = new Context())
{
var foodplaceFromDB = ctx.FoodPlaces.SingleOrDefault(x => x.Name == foodplace.Name
&& x.Streetname == foodplace.Streetname
&& x.Streetnumber == foodplace.Streetnumber
&& x.City.CityID == foodplace.City.CityID);
if (foodplaceFromDB != null)
{
return true;
}
else
{
var city = ctx.Cities.FirstOrDefault(c => c.CityID == foodplace.City.CityID);
var country = ctx.Countries.FirstOrDefault(c => c.CountryID == foodplace.City.Country.CountryID);
@ -44,10 +34,9 @@ namespace Server.DB
ctx.FoodPlaces.Add(foodplace);
ctx.SaveChanges();
}
return true;
}
}
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(e);

View File

@ -25,14 +25,6 @@ namespace Server.DB
try
{
using (Context ctx = new Context())
{
var relation = ctx.PatientAtFoodPlaces.SingleOrDefault(x => x.Patient.PersonID == patientAtFoodPlace.Patient.PersonID
&& x.FoodPlace.FoodPlaceID == patientAtFoodPlace.FoodPlace.FoodPlaceID);
if (relation != null)
{
return true;
}
else
{
var patient = ctx.Persons.FirstOrDefault(p => p.PersonID == patientAtFoodPlace.Patient.PersonID);
var foodplace = ctx.FoodPlaces.FirstOrDefault(f => f.FoodPlaceID == patientAtFoodPlace.FoodPlace.FoodPlaceID);
@ -57,10 +49,9 @@ namespace Server.DB
ctx.PatientAtFoodPlaces.Add(patientAtFoodPlace);
ctx.SaveChanges();
}
return true;
}
}
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(e);