static void addPatients(DbContext db) { var patient = new Patient () { FirstName = "Bubba", LastName = "Ho-Tep", Age = 1234, PersonalNumber = "1111111231234" }; db.Patients.Add (patient); db.SaveChanges (); var incident = new Incident() { InjuryDate = "2010-03-04", InjuryHour = 9, PersonalNumber = patient.PersonalNumber }; db.Incidents.Add(incident); var frac1 = new Fracture() { AOCode = "33C2", IncidentID = incident.ID }; db.Fractures.Add(frac1); var frac2 = new Fracture() { AOCode = "22B1", IncidentID = incident.ID }; db.Fractures.Add(frac2); var consultation = new Consultation(); db.Consultations.Add(consultation); var procedure = new Procedure() { // ConsultationID = consultation.ID, FractureID = frac1.ID }; db.Procedures.Add(procedure); procedure = new Procedure() { // ConsultationID = consultation.ID, FractureID = frac2.ID }; db.Procedures.Add(procedure); //patient = new Patient () { // FirstName = "Joe", LastName = "Schmoe", Age = 35 //}; //db.Patients.Add (patient); //db.SaveChanges (); //injury = new Injury () { // AOCode = "31B2", // InjuryDate = new DateTime (2002, 8, 5), // InjuryHour = 23, // PatientID=patient.ID //}; //db.Injuries.Add (injury); }
public ActionResult Create(string parentID, FormCollection collection) { try { if (ModelState.IsValid) { var injury = new Incident() { PersonalNumber = parentID, InjuryDate = collection["InjuryDate"], InjuryHour = int.Parse(collection["InjuryHour"]) }; db.Incidents.Add(injury); db.SaveChanges(); return RedirectToAction("Details", "Patients", new { id = parentID } ); } } catch {} return View(); }