public bool InsertAdmin(ref AdminBDO adminBDO, ref string massage) { massage = "Admin inserted successfully"; var ret = true; Password passObj = new Password(); string[] passAndSalt = passObj.getFullyHash(adminBDO.pass); using (var PHEntities = new PublicHospitalEntities()) { PHEntities.Admin.Add(new Admin { id = GetNextID(), firstName = adminBDO.firstName, lastName = adminBDO.lastName, city = adminBDO.city, street = adminBDO.street, streetNr = adminBDO.streetNr, phoneNr = adminBDO.phoneNr, zip = adminBDO.zip, login = adminBDO.login, pass = passAndSalt[0], salt = passAndSalt[1] }); var num = PHEntities.SaveChanges(); if (num != 1) { ret = false; massage = "Admin was not inserted"; } } return ret; }
public bool InsertPatient(ref PatientBDO patientBDO, ref string massage) { massage = "Patient inserted successfully"; var ret = true; Password passObj = new Password(); string[] passAndSalt = passObj.getFullyHash(patientBDO.pass); using (var PHEntities = new PublicHospitalEntities()) { PHEntities.Patient.Add(new Patient { id = GetNextID(), firstName = patientBDO.firstName, lastName = patientBDO.lastName, city = patientBDO.city, street = patientBDO.street, streetNr = patientBDO.streetNr, phoneNr = patientBDO.phoneNr, zip = patientBDO.zip, login = patientBDO.login, dateOfBirth = patientBDO.dateOfBirth, rowVersion = patientBDO.RowVersion, pass = passAndSalt[0], salt = passAndSalt[1] }); var num = PHEntities.SaveChanges(); if (num != 1) { ret = false; massage = "Patient was not inserted"; } } return ret; }
public void authenticatePersonTest() { Password pass = new Password(); if(pass.authenticatePerson("aaaa", "aaaa") == null) { Assert.Fail(); } }
public void compareSessionIDTest() { AdminBDO p = new AdminBDO(); p.sessionID = "0C4J8DlS7AHFQa8j4U1Ap39gFDDOeNBJ/N1B2eXw"; p.id = 11; Password pass = new Password(); if (!pass.compareSessionID(p)) Assert.Fail(); }