Make sure that the nodes are unique

This commit is contained in:
Andreas Zweili 2018-09-02 14:36:06 +02:00
parent 382b9be68a
commit 6e9f708af7
1 changed files with 4 additions and 1 deletions

View File

@ -15,14 +15,17 @@ namespace Server.Models
this.Patients = new List<Person>();
this.FoodPlaces = new List<FoodPlace>();
List <FoodPlace> RawFoodPlaces = new List<FoodPlace>();
List <Person> RawPatients = new List<Person>();
PatientAtFoodPlaceDB relationsDB = new PatientAtFoodPlaceDB();
this.Relations = new List<PatientAtFoodPlace>(relationsDB.GetAllRelations());
foreach (var relation in this.Relations)
{
this.Patients.Add(relation.Patient);
RawPatients.Add(relation.Patient);
RawFoodPlaces.Add(relation.FoodPlace);
}
var unique_foodplaces = new HashSet<FoodPlace>(RawFoodPlaces);
var unique_patients = new HashSet<Person>(RawPatients);
this.Patients = unique_patients.ToList();
this.FoodPlaces = unique_foodplaces.ToList();
}
public List<Node> GenerateNodes()