/// <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 new user in DB /// </summary> private void registerUserButton_Click(object sender, EventArgs e) { try { if (this.areEntryFieldsValid()) { var nurse = this.buildNurse(); NurseDAL.InsertNurse(nurse, Security.HashPassword(nurse.Username, this.passwordTextBox.Text)); this.resetFields(); this.showNurseRegisteredMessage(nurse); } } catch (Exception err) { ExceptionMessage.ShowError(err); } }