public static string AddAdderss(AddressModel address) { if (AddressDAL.InsertAddress(address) == 0) { return("操作失败"); } else { return("操作成功"); } }
/// <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); }