My favorites | Sign in
Logo
rmh
             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
using System;
using System.Web.Security;
using NHibernate;
using NHibernate.Tool.hbm2ddl;
using NUnit.Framework;
using RMH.DataAccess;
using RMH.DataAccess.AdoNet;
using RMH.Entities;
using RMH.Services;
using RMH.Web;

namespace RMH.IntegrationTests.Repository
{
[TestFixture, Explicit]
public class CreateSchema
{


[Test]
public void LoadData()
{
create_schema();
load_counties();
load_rooms();
load_diagnosis();
load_fake_patients();
load_fake_support_person();
load_fake_patients_into_rooms();
load_relationships_for_chuck_norris();
load_staff_members();
create_schema_ado();
}

public void create_schema()
{
var factory = new SessionFactoryFactory();
factory.OnFactoryCreation = configuration =>
{
var exporter = new SchemaExport(configuration);
exporter.Create(true, true);
exporter.Execute(false, true, false, true);
Console.WriteLine("done");
};
ISessionFactory sessionFactory = factory.GetSessionFactory();
}


public void create_schema_ado()
{
// TODO: fix this.
//AdoDataHelper.ExecuteScript("ReportEntities.sql");
//AdoDataHelper.ExecuteScript("ReportEntities.sql");
//AdoDataHelper.ExecuteScript("DDL-Update.sql");
}

private void load_relationships_for_chuck_norris()
{
var patientService = Container.Resolve<IPatientService>();
var personService = Container.Resolve<ISupportPersonService>();
var diagnosisService = Container.Resolve<IDiagnosisService>();

var chucks = patientService.Search("Chuck", "Nor");
foreach (var chuck in chucks)
{


chuck.Diagnoses.Add(diagnosisService.Get(1));
chuck.Diagnoses.Add(diagnosisService.Get(2));
chuck.Diagnoses.Add(diagnosisService.Get(3));

patientService.Save(chuck);
}
}

private void load_fake_support_person()
{
var repository = Container.Resolve<ISupportPersonRepository>();
repository.Save(new SupportPerson { FirstName = "Aunt", LastName = "May", PhoneNumber = "(555) 555-5309" });
repository.Save(new SupportPerson { FirstName = "Archie", LastName = "Bunker", PhoneNumber = "(555) 555-3423" });
repository.Save(new SupportPerson { FirstName = "Cindy", LastName = "Norris", PhoneNumber = "(212) 867-5309" });
}

private void load_diagnosis()
{
var repository = Container.Resolve<DiagnosisRepository>();
repository.Save(new Diagnosis { Name = "Anemia" });
repository.Save(new Diagnosis { Name = "Autism" });
repository.Save(new Diagnosis { Name = "Cancer" });
repository.Save(new Diagnosis { Name = "Celiac Disease" });
repository.Save(new Diagnosis { Name = "Crohns Disease" });
repository.Save(new Diagnosis { Name = "Cystic Fibrosis" });
repository.Save(new Diagnosis { Name = "Diabetes" });
repository.Save(new Diagnosis { Name = "Lukemia" });
}

private void load_staff_members()
{
if (Membership.GetUser("givecamp") == null)
Membership.CreateUser("givecamp", "lansing09", "info@lansinggivecamp.org");
if (Membership.GetUser("givecampvol") == null) Membership.CreateUser("givecampvol", "lansing09", "infovol@lansinggivecamp.org");
if (!Roles.RoleExists("Administrator")) Roles.CreateRole("Administrator");
if (!Roles.RoleExists("Volunteer")) Roles.CreateRole("Volunteer");
if (!Roles.IsUserInRole("givecamp", "Administrator")) Roles.AddUserToRole("givecamp", "Administrator");
if (!Roles.IsUserInRole("givecampvol", "Volunteer")) Roles.AddUserToRole("givecampvol", "Volunteer");
}

private void load_rooms()
{
var repository = Container.Resolve<RoomRepository>();
repository.Save(new Room {RoomNumber = 1});
repository.Save(new Room {RoomNumber = 2});
repository.Save(new Room {RoomNumber = 3});
repository.Save(new Room {RoomNumber = 4});
repository.Save(new Room {RoomNumber = 5});
repository.Save(new Room {RoomNumber = 6});
repository.Save(new Room {RoomNumber = 7});
repository.Save(new Room {RoomNumber = 8});
repository.Flush();
}


public void load_fake_patients()
{
var patient = new Patient {FirstName = "Carlos", MiddleName = "Ray", LastName = "Norris", EmailAddress = "chuck@hello.com", DateOfBirth = new DateTime(1940, 3, 10)};
var patient2 = new Patient { FirstName = "Job", MiddleName = "A", LastName = "Bluth", EmailAddress = "job@email.com", DateOfBirth = new DateTime(1975, 2, 11) };
var patient3 = new Patient { FirstName = "Michael", MiddleName = "B", LastName = "Bluth", EmailAddress = "micahel@email.com", DateOfBirth = new DateTime(1978, 1, 14) };
var patient4 = new Patient { FirstName = "Homer", MiddleName = "J", LastName = "Simpson", EmailAddress = "homer@email.com", DateOfBirth = new DateTime(1985, 7, 23) };
var patient5 = new Patient { FirstName = "Tom", MiddleName = "J", LastName = "Izzo", EmailAddress = "izzo@email.com", DateOfBirth = new DateTime(1955, 8, 4) };
var patient6 = new Patient { FirstName = "Chuck", MiddleName = "I", LastName = "Norris", EmailAddress = "billy@email.com", DateOfBirth = new DateTime(1955, 4, 8), DateOfDeath = new DateTime(2009, 3, 20) };
var patient7 = new Patient { FirstName = "Chuck", MiddleName = "Doe",
LastName = "Norris", EmailAddress = "chuck@heeeeeeeel.com",
DateOfBirth = new DateTime(1930, 1, 9),
DateOfDeath = new DateTime(2009, 4, 21),
Address = new Address
{
City = "Hunlock Creek",
PostalCode = "19103",
State = "PA",
Street1 = "Box 448",
Street2 = "SorbertownHill"
}, PhoneNumber = "232-232-2323",
VehicleMake = "Ford",
VehicleModel = "Temp",
VehiclePlateNumber = "ILOVETOFU",
VehiclePlateState = "MI"};
var patient8 = new Patient { FirstName = "Carl", MiddleName = "Woooooo",
LastName = "Deceased", EmailAddress = "billy@email.com", DateOfBirth = new DateTime(1922, 5, 10), DateOfDeath = new DateTime(2009, 4, 18) };

var patientRepository = Container.Resolve<PatientRepository>();

patientRepository.Save(patient);
patientRepository.Save(patient2);
patientRepository.Save(patient3);
patientRepository.Save(patient4);
patientRepository.Save(patient5);
patientRepository.Save(patient6);
patientRepository.Save(patient7);
patientRepository.Save(patient8);
}

private void load_fake_patients_into_rooms()
{
// AdoDataHelper.ExecuteScript("FakeStayData.sql");
}

public void load_counties()
{
var countyRepository = Container.Resolve<CountyRepository>();

countyRepository.Save(new County {Name = "-Out of State-"});
countyRepository.Save(new County {Name = "Alcona"});
countyRepository.Save(new County {Name = "Alger"});
countyRepository.Save(new County {Name = "Allegan"});
countyRepository.Save(new County {Name = "Alpena"});
countyRepository.Save(new County {Name = "Antrim"});
countyRepository.Save(new County {Name = "Arenac"});
countyRepository.Save(new County {Name = "Baraga"});
countyRepository.Save(new County {Name = "Barry"});
countyRepository.Save(new County {Name = "Bay"});
countyRepository.Save(new County {Name = "Benzie"});
countyRepository.Save(new County {Name = "Berrien"});
countyRepository.Save(new County {Name = "Branch"});
countyRepository.Save(new County {Name = "Calhoun"});
countyRepository.Save(new County {Name = "Cass"});
countyRepository.Save(new County {Name = "Charlevoix"});
countyRepository.Save(new County {Name = "Cheboygan"});
countyRepository.Save(new County {Name = "Chippewa"});
countyRepository.Save(new County {Name = "Clare"});
countyRepository.Save(new County {Name = "Clinton"});
countyRepository.Save(new County {Name = "Crawford"});
countyRepository.Save(new County {Name = "Delta"});
countyRepository.Save(new County {Name = "Dickinson"});
countyRepository.Save(new County {Name = "Eaton"});
countyRepository.Save(new County {Name = "Emmet"});
countyRepository.Save(new County {Name = "Genesee"});
countyRepository.Save(new County {Name = "Gladwin"});
countyRepository.Save(new County {Name = "Gogebic"});
countyRepository.Save(new County {Name = "Grand Traverse"});
countyRepository.Save(new County {Name = "Gratiot"});
countyRepository.Save(new County {Name = "Hillsdale"});
countyRepository.Save(new County {Name = "Houghton"});
countyRepository.Save(new County {Name = "Huron"});
countyRepository.Save(new County {Name = "Ingham"});
countyRepository.Save(new County {Name = "Ionia"});
countyRepository.Save(new County {Name = "Iosco"});
countyRepository.Save(new County {Name = "Iron"});
countyRepository.Save(new County {Name = "Isabella"});
countyRepository.Save(new County {Name = "Jackson"});
countyRepository.Save(new County {Name = "Kalamazoo"});
countyRepository.Save(new County {Name = "Kalkaska"});
countyRepository.Save(new County {Name = "Kent"});
countyRepository.Save(new County {Name = "Keweenaw"});
countyRepository.Save(new County {Name = "Lake"});
countyRepository.Save(new County {Name = "Lapeer"});
countyRepository.Save(new County {Name = "Leelanau"});
countyRepository.Save(new County {Name = "Lenawee"});
countyRepository.Save(new County {Name = "Livingston"});
countyRepository.Save(new County {Name = "Luce"});
countyRepository.Save(new County {Name = "Mackinac"});
countyRepository.Save(new County {Name = "Macomb"});
countyRepository.Save(new County {Name = "Manistee"});
countyRepository.Save(new County {Name = "Marquette"});
countyRepository.Save(new County {Name = "Mason"});
countyRepository.Save(new County {Name = "Mecosta"});
countyRepository.Save(new County {Name = "Menominee"});
countyRepository.Save(new County {Name = "Midland"});
countyRepository.Save(new County {Name = "Missaukee"});
countyRepository.Save(new County {Name = "Monroe"});
countyRepository.Save(new County {Name = "Montcalm"});
countyRepository.Save(new County {Name = "Montmorency"});
countyRepository.Save(new County {Name = "Muskegon"});
countyRepository.Save(new County {Name = "Newaygo"});
countyRepository.Save(new County {Name = "Oakland"});
countyRepository.Save(new County {Name = "Oceana"});
countyRepository.Save(new County {Name = "Ogemaw"});
countyRepository.Save(new County {Name = "Ontonagon"});
countyRepository.Save(new County {Name = "Osceola"});
countyRepository.Save(new County {Name = "Oscoda"});
countyRepository.Save(new County {Name = "Otsego"});
countyRepository.Save(new County {Name = "Ottawa"});
countyRepository.Save(new County {Name = "Presque Isle"});
countyRepository.Save(new County {Name = "Roscommon"});
countyRepository.Save(new County {Name = "Saginaw"});
countyRepository.Save(new County {Name = "Sanilac"});
countyRepository.Save(new County {Name = "Schoolcraft"});
countyRepository.Save(new County {Name = "Shiawassee"});
countyRepository.Save(new County {Name = "St. Clair"});
countyRepository.Save(new County {Name = "St. Joseph"});
countyRepository.Save(new County {Name = "Tuscola"});
countyRepository.Save(new County {Name = "Van Buren"});
countyRepository.Save(new County {Name = "Washtenaw"});
countyRepository.Save(new County {Name = "Wayne"});
countyRepository.Save(new County {Name = "Wexford"});
countyRepository.Flush();
}
}
}
Show details Hide details

Change log

r18 by ignu.smith on May 03, 2009   Diff
SQL Membership Provider replaced with
custom one.
Go to: 
Sign in to write a code review

Older revisions

r17 by ignu.smith on May 02, 2009   Diff
replaced sql provider
r5 by ignu.smith on Apr 27, 2009   Diff
 Issue #1 : schema updates
r2 by ignu.smith on Apr 26, 2009   Diff
Initial Commit after Lansing Give Camp
All revisions of this file

File info

Size: 13694 bytes, 257 lines
Hosted by Google Code