added seeding function on application start, to add 10 patients and doctors
random from a array
This commit is contained in:
parent
ffafd3cae2
commit
3191732420
|
@ -7,6 +7,8 @@ namespace EHEC_Server.DataBuilder
|
||||||
{
|
{
|
||||||
public class GenerateDataBuilder
|
public class GenerateDataBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//dieses file wird im moment nicht benötigt, da alles im global benutzt wird, bitte so belassen für den moment
|
||||||
private static List<Doctor> Doctors = new List<Doctor>();
|
private static List<Doctor> Doctors = new List<Doctor>();
|
||||||
private static List<Patient> Patients = new List<Patient>();
|
private static List<Patient> Patients = new List<Patient>();
|
||||||
private static List<Origin> Origins = new List<Origin>();
|
private static List<Origin> Origins = new List<Origin>();
|
||||||
|
@ -26,7 +28,7 @@ namespace EHEC_Server.DataBuilder
|
||||||
|
|
||||||
private static List<string> DoctorOrigins = new List<string>(new string[]
|
private static List<string> DoctorOrigins = new List<string>(new string[]
|
||||||
{
|
{
|
||||||
"SanktMonika", "DisneyWorld", "Hell", "Heaven"
|
"SanktMonika", "DisneyWorld", "Kantonsspital Baden", "Online Schulung"
|
||||||
});
|
});
|
||||||
|
|
||||||
private static List<string> Street = new List<string>(new string[]
|
private static List<string> Street = new List<string>(new string[]
|
||||||
|
@ -44,44 +46,5 @@ namespace EHEC_Server.DataBuilder
|
||||||
"Meister", "Schär", "Eberhard", "Zingg", "Howald", "Aebi", "Feldmann"
|
"Meister", "Schär", "Eberhard", "Zingg", "Howald", "Aebi", "Feldmann"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public static List<Patient> CreatePatients()
|
|
||||||
// {
|
|
||||||
//int Counter = Patients.Count();
|
|
||||||
//for (int i = 0; i < Counter; i++)
|
|
||||||
// foreach (var c in FirstNames)
|
|
||||||
// {
|
|
||||||
// for (int j = 0; j < 10; j++)
|
|
||||||
// {
|
|
||||||
// Patient patient = new Patient(
|
|
||||||
// FirstNames[Rnd.Next(1, FirstNames.Count())],
|
|
||||||
// LastNames[Rnd.Next(1, LastNames.Count())],
|
|
||||||
// BirthDate[Rnd.Next(1, BirthDate.Count())],
|
|
||||||
// Street[Rnd.Next(1, Street.Count())],
|
|
||||||
// City[Rnd.Next(1, City.Count())]);
|
|
||||||
// Patients.Add(patient);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return Patients;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static List<Doctor> CreateDoctors()
|
|
||||||
//{
|
|
||||||
//int Counter = Patients.Count();
|
|
||||||
//for (int i = 0; i < Counter; i++)
|
|
||||||
// foreach (var c in FirstNames)
|
|
||||||
//{
|
|
||||||
// for (int j = 0; j < 10; j++)
|
|
||||||
//{
|
|
||||||
// Doctor doctor = new Doctor(
|
|
||||||
// FirstNames[Rnd.Next(1, FirstNames.Count())],
|
|
||||||
// LastNames[Rnd.Next(1, LastNames.Count())],
|
|
||||||
//DoctorOrigins[Rnd.Next(1, DoctorOrigins.Count())]);
|
|
||||||
//Doctors.Add(doctor);
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
//return Doctors;
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -80,6 +80,7 @@
|
||||||
<Generator>EntityModelCodeGenerator</Generator>
|
<Generator>EntityModelCodeGenerator</Generator>
|
||||||
<LastGenOutput>Model.Designer.cs</LastGenOutput>
|
<LastGenOutput>Model.Designer.cs</LastGenOutput>
|
||||||
</EntityDeploy>
|
</EntityDeploy>
|
||||||
|
<Content Include="Global.asax" />
|
||||||
<Content Include="Model.edmx.diagram">
|
<Content Include="Model.edmx.diagram">
|
||||||
<DependentUpon>Model.edmx</DependentUpon>
|
<DependentUpon>Model.edmx</DependentUpon>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -120,6 +121,9 @@
|
||||||
<Compile Include="Exam.cs">
|
<Compile Include="Exam.cs">
|
||||||
<DependentUpon>Model.tt</DependentUpon>
|
<DependentUpon>Model.tt</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Global.asax.cs">
|
||||||
|
<DependentUpon>Global.asax</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="IService.cs" />
|
<Compile Include="IService.cs" />
|
||||||
<Compile Include="Model.Context.cs">
|
<Compile Include="Model.Context.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<%@ Application Codebehind="Global.asax.cs" Inherits="EHEC_Server.Global" Language="C#" %>
|
|
@ -0,0 +1,123 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Security;
|
||||||
|
using System.Web.SessionState;
|
||||||
|
using EHEC_Server.DataBuilder;
|
||||||
|
|
||||||
|
namespace EHEC_Server
|
||||||
|
{
|
||||||
|
public class Global : System.Web.HttpApplication
|
||||||
|
{
|
||||||
|
private static List<string> FirstNames = new List<string>(new string[]
|
||||||
|
{
|
||||||
|
"Michael", "Andreas", "Stefan", "Ivan","Adrien"
|
||||||
|
});
|
||||||
|
|
||||||
|
private static List<string> LastNames = new List<string>(new string[]
|
||||||
|
{
|
||||||
|
"Meister", "Schär", "Eberhard", "Zingg", "Howald", "Aebi", "Feldmann"
|
||||||
|
});
|
||||||
|
|
||||||
|
private static List<string> Streets = new List<string>(new string[]
|
||||||
|
{
|
||||||
|
"Rosenauweg", "Schessstrasse", "Hardstrasse", "Gehweg", "Bananastreet", "Moosweg", "Feldstrasse"
|
||||||
|
});
|
||||||
|
|
||||||
|
private static List<string> Cities = new List<string>(new string[]
|
||||||
|
{
|
||||||
|
"Meister", "Schär", "Eberhard", "Zingg", "Howald", "Aebi", "Feldmann"
|
||||||
|
});
|
||||||
|
|
||||||
|
private static List<string> Regions = new List<string>(new string[]
|
||||||
|
{
|
||||||
|
"Aargau", "Zurich", "Graubünden","Vallhalla", "Hell", "Heaven"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
private static List<string> BirthDates = new List<string>(new string[]
|
||||||
|
{
|
||||||
|
"2001-07-11 20:18:00.000", "1999-03-12 10:18:00.000","1980-01-21 00:18:00.000",
|
||||||
|
});
|
||||||
|
|
||||||
|
private static List<string> DoctorOrigins = new List<string>(new string[]
|
||||||
|
{
|
||||||
|
"SanktMonika", "DisneyWorld", "Kantonsspital Baden", "Online Schulung"
|
||||||
|
});
|
||||||
|
|
||||||
|
protected void Application_Start(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//add patients
|
||||||
|
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
||||||
|
{
|
||||||
|
|
||||||
|
Random p = new Random();
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
Patient patient = new Patient
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
};
|
||||||
|
ctx.Patients.Add(patient);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//add doctors
|
||||||
|
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
||||||
|
{
|
||||||
|
|
||||||
|
Random p = new Random();
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
Doctor doctor = new Doctor
|
||||||
|
{
|
||||||
|
FirstName = FirstNames[p.Next(0, 5)].ToString(),
|
||||||
|
LastName = LastNames[p.Next(0, 7)].ToString(),
|
||||||
|
DoctorOrigin = DoctorOrigins[p.Next(0, 4)].ToString(),
|
||||||
|
Region = Regions[p.Next(0, 6)].ToString()
|
||||||
|
};
|
||||||
|
ctx.Doctors.Add(doctor);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//all the following code was auto-generated by createing the global file and will be deleted later
|
||||||
|
protected void Session_Start(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Application_BeginRequest(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Application_AuthenticateRequest(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Application_Error(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Session_End(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Application_End(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,8 +30,8 @@
|
||||||
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
|
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
|
||||||
</system.serviceModel>
|
</system.serviceModel>
|
||||||
<connectionStrings>
|
<connectionStrings>
|
||||||
<!--<add name="EHEC_DBEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="data source=LAPTOP-S6N189QG;initial catalog=EHEC_DB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />-->
|
<add name="EHEC_DBEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="data source=LAPTOP-S6N189QG;initial catalog=EHEC_DB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||||
<add name="EHEC_DBEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=EHEC_DB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
<!--<add name="EHEC_DBEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=EHEC_DB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />-->
|
||||||
</connectionStrings>
|
</connectionStrings>
|
||||||
<entityFramework>
|
<entityFramework>
|
||||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||||
|
|
Loading…
Reference in New Issue