Revert "move the data generation into its own class"
This reverts commit b4635fe0fd
.
This commit is contained in:
parent
b4635fe0fd
commit
2d1173eb28
|
@ -12,25 +12,35 @@ namespace Server.Helper
|
|||
{
|
||||
protected override void Seed(Context context)
|
||||
{
|
||||
List<string> salutationList = new List<string>(new string[]
|
||||
{
|
||||
"Dr.", "Frau", "Herr"
|
||||
});
|
||||
List<string> genderList = new List<string>(new string[]
|
||||
{
|
||||
"Männlich", "Weiblich"
|
||||
});
|
||||
|
||||
var salutations = GenerateData.CreateSalutations();
|
||||
var genders = GenerateData.CreateGenders();
|
||||
var doctors = GenerateData.CreateDoctors();
|
||||
|
||||
foreach (var s in salutations)
|
||||
foreach (var s in salutationList)
|
||||
{
|
||||
context.Salutations.Add(s);
|
||||
Salutation newSalutation = new Salutation(s);
|
||||
context.Salutations.Add(newSalutation);
|
||||
}
|
||||
foreach (var g in genders)
|
||||
foreach (var g in genderList)
|
||||
{
|
||||
context.Genders.Add(g);
|
||||
}
|
||||
foreach (var d in doctors)
|
||||
{
|
||||
context.Doctors.Add(d);
|
||||
Gender newGender = new Gender(g);
|
||||
context.Genders.Add(newGender);
|
||||
}
|
||||
context.SaveChanges();
|
||||
|
||||
Gender gender = context.Genders.FirstOrDefault();
|
||||
Salutation salutation = context.Salutations.FirstOrDefault();
|
||||
Country country = new Country("Schweiz");
|
||||
City city = new City("Herzogenbuchsee", 3360, country);
|
||||
Status status = new Status("Regionalarzt");
|
||||
Doctor doctor = new Doctor("Max", "Ötker", gender,
|
||||
salutation, "Musterstrasse 12", city, status);
|
||||
context.Doctors.Add(doctor);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Server.Models;
|
||||
|
||||
namespace Server.Helper
|
||||
{
|
||||
public static class GenerateData
|
||||
{
|
||||
private static List<Salutation> salutations = new List<Salutation>();
|
||||
private static List<Gender> genders = new List<Gender>();
|
||||
private static List<Doctor> doctors = new List<Doctor>();
|
||||
|
||||
private static List<string> salutationList = new List<string>(new string[]
|
||||
{
|
||||
"Dr.", "Frau", "Herr"
|
||||
});
|
||||
private static List<string> genderList = new List<string>(new string[]
|
||||
{
|
||||
"Männlich", "Weiblich"
|
||||
});
|
||||
public static List<Salutation> CreateSalutations()
|
||||
{
|
||||
foreach (var s in salutationList)
|
||||
{
|
||||
salutations.Add(new Salutation(s));
|
||||
}
|
||||
return salutations;
|
||||
}
|
||||
public static List<Gender> CreateGenders()
|
||||
{
|
||||
foreach (var s in salutationList)
|
||||
{
|
||||
genders.Add(new Gender(s));
|
||||
}
|
||||
return genders;
|
||||
}
|
||||
public static List<Doctor> CreateDoctors()
|
||||
{
|
||||
Country country = new Country("Schweiz");
|
||||
City city = new City("Herzogenbuchsee", 3360, country);
|
||||
Status status = new Status("Regionalarzt");
|
||||
Doctor doctor = new Doctor("Max", "Ötker", genders[0],
|
||||
salutations[0], "Musterstrasse 12", city, status);
|
||||
doctors.Add(doctor);
|
||||
return doctors;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -105,7 +105,6 @@
|
|||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Helper\GenerateData.cs" />
|
||||
<Compile Include="home.aspx.cs">
|
||||
<DependentUpon>home.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
|
Loading…
Reference in New Issue