public IActionResult Page2(PersonModel person) { var personDal = new PersonDAL(_configuration); int personId = personDal.InsertPerson(person); HttpContext.Session.SetString(personIdKey, personId.ToString()); HttpContext.Session.SetString(firstNameKey, person.FirstName); InitView(); return(View(person)); }
/// <summary> /// Inserts a new Patient with their data into the db. /// </summary> /// <param name="patient">Person of Patient to insert</param> /// <param name="address">Address of Patient to insert</param> /// <returns>Whether or not the insertion succeeded</returns> public bool RegisterNurse(Person nurse, Address address) { if (nurse == null || address == null) { throw new ArgumentNullException("nurse and address cannot be null"); } using (TransactionScope scope = new TransactionScope()) { int?addressID = AddressDAL.InsertAddress(address); int?personID = PersonDAL.InsertPerson(new Person(null, nurse.Username, nurse.Password, nurse.FirstName, nurse.LastName, nurse.DateOfBirth, nurse.SSN, nurse.Gender, addressID, nurse.ContactPhone)); NurseDAL.InsertNurse(new Nurse(null, personID, true)); scope.Complete(); } return(true); }
/// <summary> /// Inserts a new Patient with their data into the db. /// </summary> /// <param name="patient">Person of Patient to insert</param> /// <param name="address">Address of Patient to insert</param> /// <returns>Whether or not the insertion succeeded</returns> public bool RegisterPatient(Person patient, Address address) { if (patient == null || address == null) { throw new ArgumentNullException("patient and address cannot be null"); } if (patient.Username != null || patient.Password != null) { throw new ArgumentNullException("username and password of a patient should be null"); } using (TransactionScope scope = new TransactionScope()) { int?addressID = AddressDAL.InsertAddress(address); int?personID = PersonDAL.InsertPerson(new Person(null, null, null, patient.FirstName, patient.LastName, patient.DateOfBirth, patient.SSN, patient.Gender, addressID, patient.ContactPhone)); PatientDAL.InsertPatient(new Patient(null, personID, true)); scope.Complete(); } return(true); }
public Message Register([FromBody] JToken value) { int doctypeId = 0; int.TryParse((string)value.SelectToken("doctortypeid"), out doctypeId); string firstname = (string)value.SelectToken("firstname"); string lastname = (string)value.SelectToken("lastname"); string nationalid = (string)value.SelectToken("nationalid"); string gender = (string)value.SelectToken("gender"); string username = (string)value.SelectToken("username"); string password = (string)value.SelectToken("password"); DateTime dob = DateTime.Now; DateTime.TryParse((string)value.SelectToken("dateofbirth"), out dob); if (doctypeId == 0) { return(MessageHandler.Error("Please select doctor type")); } if (firstname == null) { return(MessageHandler.Error("You must enter a first name")); } if (lastname == null) { return(MessageHandler.Error("You must enter a last name")); } if (nationalid == null) { return(MessageHandler.Error("You must enter a valid National Identification number")); } if (username == null) { return(MessageHandler.Error("You must enter a username")); } if (password == null) { return(MessageHandler.Error("You must enter a password")); } int personID = PersonDAL.InsertPerson(firstname, lastname, gender, dob, nationalid, (string)value.SelectToken("mobilenumber"), (string)value.SelectToken("homenumber"), (string)value.SelectToken("worknumber"), (string)value.SelectToken("address1"), (string)value.SelectToken("address2"), (string)value.SelectToken("city"), (string)value.SelectToken("country"), (string)value.SelectToken("email") ); int doctorid = DoctorDAL.InsertDoctor(personID, doctypeId, username, password); // Add user activity UserActivity.AddDoctorActivity((int)ActivityEnum.DoctorRegistration, doctorid, (int)StatusEnum.Success, "Success", value.ToString()); // Email registration MailService.SendRegistrationEmail((string)value.SelectToken("email")); // Return success return(MessageHandler.Success("You have successfully registered on Healthee!")); }
public Message AddRecord([FromBody] JToken value) { int doctorid = 0; int.TryParse((string)value.SelectToken("doctorid"), out doctorid); if (!DoctorDAL.DoctorExists(doctorid)) { return(MessageHandler.Error("Incorrect doctorid. Not authorized to add patients")); } string firstname = (string)value.SelectToken("firstname"); string lastname = (string)value.SelectToken("lastname"); string nationalid = (string)value.SelectToken("nationalid"); string gender = (string)value.SelectToken("gender"); string allergies = (string)value.SelectToken("allergies"); string medication = (string)value.SelectToken("medication"); DateTime dob = DateTime.MinValue; //if (! DateTime.TryParse((string)value.SelectToken("dateofbirth"), out dob)) //{ // dob = DateTime.MinValue; //} if (firstname == null) { return(MessageHandler.Error("You must enter a first name")); } if (lastname == null) { return(MessageHandler.Error("You must enter a last name")); } if (nationalid == null) { return(MessageHandler.Error("You must enter a valid National Identification number")); } // Add person int personID = PersonDAL.InsertPerson(firstname, lastname, gender, dob, nationalid, (string)value.SelectToken("mobilenumber"), (string)value.SelectToken("homenumber"), (string)value.SelectToken("worknumber"), (string)value.SelectToken("address1"), (string)value.SelectToken("address2"), (string)value.SelectToken("city"), (string)value.SelectToken("country"), (string)value.SelectToken("email") ); // Add medical record int medicalRecordId = MedicalDAL.InsertMedicalRecord(allergies, medication, (string)value.SelectToken("notes")); // Add patient mapping PatientDAL.InsertPatient(personID, medicalRecordId); // Add activity UserActivity.AddDoctorActivity((int)ActivityEnum.PatientRegistratoin, doctorid, (int)StatusEnum.Success, "Success", value.ToString()); // Email registration MailService.SendRegistrationEmail((string)value.SelectToken("email")); // return success return(MessageHandler.Success("You have successfully registered a new patient on Healthee!")); }