put all the randomizer functions into 1 service to use
This commit is contained in:
parent
ac076fb52d
commit
2bb15a26eb
|
@ -56,12 +56,12 @@ namespace EHEC_Server
|
||||||
|
|
||||||
private static List<string> Foods = new List<string>(new string[]
|
private static List<string> Foods = new List<string>(new string[]
|
||||||
{
|
{
|
||||||
"SanktMonika", "DisneyWorld", "Kantonsspital Baden", "Online Schulung"
|
"SanktMonika", "DisneyWorld", "Kantonsspital Baden", "Online Schulung", "Heaven"
|
||||||
});
|
});
|
||||||
|
|
||||||
private static List<string> Names = new List<string>(new string[]
|
private static List<string> Names = new List<string>(new string[]
|
||||||
{
|
{
|
||||||
"SanktMonika", "DisneyWorld", "Kantonsspital Baden", "Online Schulung"
|
"SanktMonika", "DisneyWorld", "Kantonsspital Baden", "Online Schulung", "Heaven"
|
||||||
});
|
});
|
||||||
|
|
||||||
private static List<int> DoctorId = new List<int>(new int[]
|
private static List<int> DoctorId = new List<int>(new int[]
|
||||||
|
@ -79,97 +79,17 @@ namespace EHEC_Server
|
||||||
1, 2, 3, 4, 5
|
1, 2, 3, 4, 5
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private static List<int> ExamId = new List<int>(new int[]
|
||||||
public static Patient CreateRandomPatients(Patient patients)
|
|
||||||
{
|
{
|
||||||
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
1, 2, 3, 4, 5
|
||||||
{
|
});
|
||||||
Random p = new Random();
|
|
||||||
for (int i = 0; i < 50; i++)
|
private static List<int> OriginId = new List<int>(new int[]
|
||||||
{
|
|
||||||
Patient patient = new Patient
|
|
||||||
{
|
|
||||||
PatientUid = Guid.NewGuid().ToString(),
|
|
||||||
FirstName = FirstNames[p.Next(0, 5)].ToString(),
|
|
||||||
LastName = LastNames[p.Next(0, 7)].ToString(),
|
|
||||||
BirthDate = Convert.ToDateTime(BirthDates[p.Next(0, 3)].ToString()),
|
|
||||||
Street = Streets[p.Next(0, 7)].ToString(),
|
|
||||||
City = Cities[p.Next(0, 7)].ToString(),
|
|
||||||
Region = Regions[p.Next(0, 6)].ToString()
|
|
||||||
};
|
|
||||||
//Global.GlobalInstance.DbAccess.Patients.Add(patient);
|
|
||||||
ctx.Patients.Add(patient);
|
|
||||||
ctx.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return patients;
|
|
||||||
}
|
|
||||||
public static Doctor CreateRandomDoctors(Doctor doctors)
|
|
||||||
{
|
{
|
||||||
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
1, 2, 3, 4, 5
|
||||||
{
|
});
|
||||||
|
|
||||||
Random d = new Random();
|
|
||||||
for (int i = 0; i < 50; i++)
|
|
||||||
{
|
|
||||||
Doctor doctor = new Doctor
|
|
||||||
{
|
|
||||||
DoctorUid = Guid.NewGuid().ToString(),
|
|
||||||
FirstName = FirstNames[d.Next(0, 5)].ToString(),
|
|
||||||
LastName = LastNames[d.Next(0, 7)].ToString(),
|
|
||||||
DoctorOrigin = DoctorOrigins[d.Next(0, 4)].ToString(),
|
|
||||||
Region = Regions[d.Next(0, 6)].ToString()
|
|
||||||
};
|
|
||||||
//Global.GlobalInstance.DbAccess.Doctors.Add(doctor);
|
|
||||||
ctx.Doctors.Add(doctor);
|
|
||||||
ctx.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return doctors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Origin CreateRandomOrigins(Origin origins)
|
|
||||||
{
|
|
||||||
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
|
||||||
{
|
|
||||||
Random o = new Random();
|
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
Origin origin = new Origin
|
|
||||||
{
|
|
||||||
OriginUid = Guid.NewGuid().ToString(),
|
|
||||||
Name = Names[o.Next(0, 5)].ToString(),
|
|
||||||
Food = Foods[o.Next(0, 5)].ToString(),
|
|
||||||
Street = Streets[o.Next(0, 5)].ToString(),
|
|
||||||
City = Cities[o.Next(0, 5)].ToString(),
|
|
||||||
|
|
||||||
};
|
|
||||||
ctx.Origins.Add(origin);
|
|
||||||
ctx.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return origins;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Result CreateRandomResults(Result results)
|
|
||||||
{
|
|
||||||
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
|
||||||
{
|
|
||||||
Random r = new Random();
|
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
Result result = new Result
|
|
||||||
{
|
|
||||||
ResultUid = Guid.NewGuid().ToString(),
|
|
||||||
Name = Names[r.Next(0, 5)].ToString()
|
|
||||||
|
|
||||||
};
|
|
||||||
ctx.Results.Add(result);
|
|
||||||
ctx.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Exam CreateRandomExams(Exam exams)
|
public static Exam CreateRandomExams(Exam exams)
|
||||||
{
|
{
|
||||||
|
@ -179,25 +99,105 @@ namespace EHEC_Server
|
||||||
//int PatientAmount = Patient.Count();
|
//int PatientAmount = Patient.Count();
|
||||||
//int ResultAmount = Result.Count();
|
//int ResultAmount = Result.Count();
|
||||||
|
|
||||||
Random e = new Random();
|
Random r = new Random();
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
Exam exam = new Exam
|
foreach (var p in FirstNames)
|
||||||
{
|
{
|
||||||
ExamUid = Guid.NewGuid().ToString(),
|
Patient patient = new Patient
|
||||||
DoctorId = DoctorId[e.Next(0, 5)],
|
{
|
||||||
PatientId = PatientId[e.Next(0, 5)],
|
PatientUid = Guid.NewGuid().ToString(),
|
||||||
ResultId = ResultId[e.Next(0, 5)]
|
FirstName = FirstNames[r.Next(0, 5)].ToString(),
|
||||||
};
|
LastName = LastNames[r.Next(0, 7)].ToString(),
|
||||||
ctx.Exams.Add(exam);
|
BirthDate = Convert.ToDateTime(BirthDates[r.Next(0, 3)].ToString()),
|
||||||
ctx.SaveChanges();
|
Street = Streets[r.Next(0, 7)].ToString(),
|
||||||
|
City = Cities[r.Next(0, 7)].ToString(),
|
||||||
|
Region = Regions[r.Next(0, 6)].ToString()
|
||||||
|
};
|
||||||
|
//Global.GlobalInstance.DbAccess.Patients.Add(patient);
|
||||||
|
ctx.Patients.Add(patient);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
foreach (var d in FirstNames)
|
||||||
|
{
|
||||||
|
Doctor doctor = new Doctor
|
||||||
|
{
|
||||||
|
DoctorUid = Guid.NewGuid().ToString(),
|
||||||
|
FirstName = FirstNames[r.Next(0, 5)].ToString(),
|
||||||
|
LastName = LastNames[r.Next(0, 7)].ToString(),
|
||||||
|
DoctorOrigin = DoctorOrigins[r.Next(0, 4)].ToString(),
|
||||||
|
Region = Regions[r.Next(0, 6)].ToString()
|
||||||
|
};
|
||||||
|
//Global.GlobalInstance.DbAccess.Doctors.Add(doctor);
|
||||||
|
ctx.Doctors.Add(doctor);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var o in FirstNames)
|
||||||
|
{
|
||||||
|
Origin origin = new Origin
|
||||||
|
{
|
||||||
|
OriginUid = Guid.NewGuid().ToString(),
|
||||||
|
Name = Names[r.Next(0, 5)].ToString(),
|
||||||
|
Food = Foods[r.Next(0, 5)].ToString(),
|
||||||
|
Street = Streets[r.Next(0, 7)].ToString(),
|
||||||
|
City = Cities[r.Next(0, 7)].ToString(),
|
||||||
|
};
|
||||||
|
ctx.Origins.Add(origin);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var t in FirstNames)
|
||||||
|
{
|
||||||
|
Result result = new Result
|
||||||
|
{
|
||||||
|
ResultUid = Guid.NewGuid().ToString(),
|
||||||
|
Name = Names[r.Next(0, 5)].ToString()
|
||||||
|
|
||||||
|
};
|
||||||
|
ctx.Results.Add(result);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i > 5)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 5; y++)
|
||||||
|
{
|
||||||
|
|
||||||
|
Exam exam = new Exam
|
||||||
|
{
|
||||||
|
ExamUid = Guid.NewGuid().ToString(),
|
||||||
|
DoctorId = DoctorId[r.Next(0, 5)],
|
||||||
|
PatientId = PatientId[r.Next(0, 5)],
|
||||||
|
ResultId = ResultId[r.Next(0, 5)]
|
||||||
|
};
|
||||||
|
ctx.Exams.Add(exam);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if (i > 10)
|
||||||
|
{
|
||||||
|
for (int o = 0; o < 5; o++)
|
||||||
|
{
|
||||||
|
Origin_Exam origin_exam = new Origin_Exam
|
||||||
|
{
|
||||||
|
Origin_ExamUid = Guid.NewGuid().ToString(),
|
||||||
|
ExamId = DoctorId[r.Next(0, 5)],
|
||||||
|
OriginId = PatientId[r.Next(0, 5)],
|
||||||
|
};
|
||||||
|
ctx.Origin_Exam.Add(origin_exam);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return exams;
|
return exams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,16 +33,6 @@ namespace EHEC_Server
|
||||||
[OperationContract]
|
[OperationContract]
|
||||||
List<Result> GetResults();
|
List<Result> GetResults();
|
||||||
|
|
||||||
[OperationContract]
|
|
||||||
Patient CreateRandomPatient(Patient patient);
|
|
||||||
|
|
||||||
[OperationContract]
|
|
||||||
Doctor CreateRandomDoctor(Doctor doctor);
|
|
||||||
|
|
||||||
[OperationContract]
|
|
||||||
Origin CreateRandomOrigin(Origin origin);
|
|
||||||
[OperationContract]
|
|
||||||
Result CreateRandomResult(Result result);
|
|
||||||
[OperationContract]
|
[OperationContract]
|
||||||
Exam CreateRandomExam(Exam exam);
|
Exam CreateRandomExam(Exam exam);
|
||||||
|
|
||||||
|
|
|
@ -66,24 +66,10 @@ namespace EHEC_Server
|
||||||
{
|
{
|
||||||
return dataaccess_result.CreateResult(result);
|
return dataaccess_result.CreateResult(result);
|
||||||
}
|
}
|
||||||
public Doctor CreateRandomDoctor(Doctor doctors)
|
|
||||||
{
|
|
||||||
return GenerateDataBuilder.CreateRandomDoctors(doctors);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Patient CreateRandomPatient(Patient patients)
|
|
||||||
{
|
|
||||||
return GenerateDataBuilder.CreateRandomPatients(patients);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Origin CreateRandomOrigin(Origin origins)
|
|
||||||
{
|
|
||||||
return GenerateDataBuilder.CreateRandomOrigins(origins);
|
|
||||||
}
|
|
||||||
public Result CreateRandomResult(Result results)
|
|
||||||
{
|
|
||||||
return GenerateDataBuilder.CreateRandomResults(results);
|
|
||||||
}
|
|
||||||
public Exam CreateRandomExam(Exam exams)
|
public Exam CreateRandomExam(Exam exams)
|
||||||
{
|
{
|
||||||
return GenerateDataBuilder.CreateRandomExams(exams);
|
return GenerateDataBuilder.CreateRandomExams(exams);
|
||||||
|
|
Loading…
Reference in New Issue