refactor ClusterConverter and Model

This commit is contained in:
Ivan Hörler 2018-07-18 19:19:47 +02:00
parent 7473c46d73
commit d835495591
2 changed files with 18 additions and 12 deletions

View File

@ -10,11 +10,12 @@ namespace EHEC_Server
{
public void WriteJson()
{
ClusterPatient clusterp = new ClusterPatient();
List<ClusterPatient> clusterPatientList = new List<ClusterPatient>();
clusterPatientList = clusterp.GetClusterPatients();
ClusterPatient p = new ClusterPatient();
List<ClusterPatient> clusterPatientsList = new List<ClusterPatient>();
clusterPatientsList = p.GetClusterPatients();
//clusterPatient =
var json = JsonConverter.Serialize(clusterPatientList);
var json = JsonConverter.Serialize(clusterPatientsList);
System.IO.File.WriteAllText(@"C:\Users\novski\Desktop\cluster.json", json);
}
private List<ClusterPatient> GetCluster()

View File

@ -8,28 +8,33 @@ namespace EHEC_Server
public class ClusterPatient
{
public List<Patient> Patients { get; set; }
public List<ClusterPatient> ClusterPatients { get; set; }
public int Id { get; set; }
public string Name { get; set; }
private int Id { get; set; }
private string Name { get; set; }
private string Nodetype { get; set; }
public ClusterPatient() { }
public List<ClusterPatient> GetClusterPatients()
{
Patient p = new Patient();
Patients = p.GetAllPatients();
Patient patient = new Patient();
List<Patient> patients = new List<Patient>();
patients = patient.GetAllPatients();
List<ClusterPatient> ClusterPatients = new List<ClusterPatient>();
foreach (Patient element in Patients)
foreach (Patient element in patients)
{
ClusterPatient clusterPatient = new ClusterPatient
{
Id = element.PatientId,
Nodetype = "patient",
Name = element.FirstName + " " + element.LastName
};
ClusterPatients.Add(clusterPatient);
}
return ClusterPatients;
}
}
}