public ActionResult CreatePatient(Patient patient) { try { var userId = Request.IsAuthenticated ? UserId : Guid.Empty; var roles = new string[] { HospitalManagementSystem.Models.Constants.Roles.PATIENT }; var registerHelper = new RegisterHelper(userId, patient.Person, roles); registerHelper.Register(); if (!registerHelper.Response.Item1) { patient.Person.Error = registerHelper.Response.Item2; return(View(patient)); } //PatientRegistration.Register(new Patient() { PersonId = patient.Person.Id });int personId = porter.Person.Id; int personId = patient.Person.Id; patient.PersonId = personId; patient.Person = null; PatientRegistration.Register(patient); return(RedirectToAction("RegisterSuccess", "Account", new { statusMessage = registerHelper.Response.Item2 })); } catch { return(View()); } }
public void GivenPatientWhenRegisteringThenPersistToDb() { HospitalManagementSystemContext HospitalManagementSystemContext = EntityFrameworkMock.Create <HospitalManagementSystemContext>(); TypeFactory.RegisterInstance(HospitalManagementSystemContext); Patient patient = new Patient(); patient.PersonId = 1; patient.Person.Id = 1; patient.Person.FirstName = "Vusi"; patient.Person.Surname = "Khoza"; patient.Person.IdNumber = "1234"; IPatientRepository patientRepository = new PatientRepository(); IPatientRegistration patientRegistration = new PatientRegistration(patientRepository); patientRegistration.Register(patient); IPatientRetriever patientRetriever = new PatientRetriever(patientRepository); patientRetriever.Retrieve(patient.Person.IdNumber); Assert.IsNotNull(patientRetriever.Patient); Assert.AreEqual(patient.Person.Id, patientRetriever.Patient.Person.Id); Assert.AreEqual(patient.Person.FirstName, patientRetriever.Patient.Person.FirstName); Assert.AreEqual(patient.Person.Surname, patientRetriever.Patient.Person.Surname); }