public int ChangePassword(Doctor doctor, string oldPassword, string newPassword, string newPasswordRepeat) { if (!string.IsNullOrEmpty(oldPassword) && !string.IsNullOrWhiteSpace(oldPassword) && !string.IsNullOrEmpty(newPassword) && !string.IsNullOrWhiteSpace(newPassword) && !string.IsNullOrEmpty(newPasswordRepeat) && !string.IsNullOrWhiteSpace(newPasswordRepeat) && doctor != null) { if (doctor.Password == PasswordCrypto.EncryptToSha512(oldPassword)) { if (newPassword == newPasswordRepeat) { using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor()) { doctor.Password = PasswordCrypto.EncryptToSha512(newPassword); repositoryDoctor.CUDOperation(doctor, EntityState.Modified); return(repositoryDoctor.SaveChanges()); } } else { return(-4); } } else { return(-3); } } else { return(-1); } }
public Doctor DoctorLogIn(string userName, string password) { using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor()) { string encryptedPassword = PasswordCrypto.EncryptToSha512(password); return(repositoryDoctor.FirstWithExplicitLoad(I => I.Ssn == userName && I.Password == encryptedPassword && I.IsActive == true)); } }
public Admin AdminLogIn(string userName, string password) { using (RepositoryAdmin repositoryAdmin = new RepositoryAdmin()) { string encryptedPassword = PasswordCrypto.EncryptToSha512(password); return(repositoryAdmin.FirstWithExplicitLoad(I => I.UserName == userName && I.Password == encryptedPassword)); } }
public int ForgotPassword(string ssn, string name, string surname, string phone, string mail, DateTime birthday, string newPassword, string newPasswordRepeat) { if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && !string.IsNullOrEmpty(newPassword) && !string.IsNullOrWhiteSpace(newPassword) && !string.IsNullOrEmpty(newPasswordRepeat) && !string.IsNullOrWhiteSpace(newPasswordRepeat) && birthday != null) { string tempPhone; string tempMail; if (string.IsNullOrEmpty(phone.Trim())) { tempPhone = null; } else { tempPhone = phone; } if (string.IsNullOrEmpty(mail.Trim())) { tempMail = null; } else { tempMail = mail; } using (RepositoryMember repositoryMember = new RepositoryMember()) { Member member = repositoryMember.FirstWithExplicitLoad(I => I.Ssn == ssn); if (member != null) { if (member.Name == BLLHelper.TrimName(name) && member.Surname == BLLHelper.TrimSurname(surname) && member.Phone == tempPhone && member.Mail == tempMail && member.Birthday.ToString("dd.MM.yyyy") == birthday.ToString("dd.MM.yyyy")) { if (newPassword == newPasswordRepeat) { member.Password = PasswordCrypto.EncryptToSha512(newPassword); repositoryMember.CUDOperation(member, EntityState.Modified); return(repositoryMember.SaveChanges()); } else { return(-4); } } else { return(-6); } } else { return(-5); } } } else { return(-1); } }
public int AdminNewRecord(string userName) { using (RepositoryAdmin repositoryAdmin = new RepositoryAdmin()) { repositoryAdmin.CUDOperation(new Admin() { Id = Guid.NewGuid(), UserName = userName, Password = PasswordCrypto.EncryptToSha512("demo") }, EntityState.Added); return(repositoryAdmin.SaveChanges()); } }
public int ResetAdminPassword(Admin admin, string password) { if (admin != null && !string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password)) { using (RepositoryAdmin repositoryAdmin = new RepositoryAdmin()) { admin.Password = PasswordCrypto.EncryptToSha512(password); repositoryAdmin.CUDOperation(admin, EntityState.Modified); return(repositoryAdmin.SaveChanges()); } } else { return(-1); } }
public int ResetDoctorPassword(Doctor doctor, string password) { if (doctor != null && !string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password)) { using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor()) { doctor.Password = PasswordCrypto.EncryptToSha512(password); repositoryDoctor.CUDOperation(doctor, EntityState.Modified); return(repositoryDoctor.SaveChanges()); } } else { return(-1); } }
public int DoctorNewRecord(Hospital hospital, string ssn, string appellation, string expertise, string ageRange, string name, string surname, DateTime birthday, string phone, string mail, string city, string county) { if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && ssn.Length == 11 && !string.IsNullOrEmpty(appellation) && !string.IsNullOrWhiteSpace(appellation) && !string.IsNullOrEmpty(expertise) && !string.IsNullOrWhiteSpace(expertise) && !string.IsNullOrEmpty(ageRange) && !string.IsNullOrWhiteSpace(ageRange) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && birthday != null && hospital != null) { string tempPhone; string tempMail; string tempCity; string tempCounty; if (string.IsNullOrEmpty(phone.Trim())) { tempPhone = null; } else { tempPhone = phone; } if (string.IsNullOrEmpty(mail.Trim())) { tempMail = null; } else { tempMail = mail; } if (string.IsNullOrEmpty(city.Trim())) { tempCity = null; } else { tempCity = city; } if (string.IsNullOrEmpty(county.Trim())) { tempCounty = null; } else { tempCounty = county; } using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor()) { if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Ssn == ssn)) { if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Phone == phone)) { if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Mail == mail)) { Doctor doctor = new Doctor() { Id = Guid.NewGuid(), Ssn = ssn, Appellation = BLLHelper.GetEnumValueFromDescription <DoctorEnumAppellation>(appellation), Expertise = BLLHelper.GetEnumValueFromDescription <DoctorEnumExpertise>(expertise), AgeRange = BLLHelper.GetEnumValueFromDescription <DoctorEnumAgeRange>(ageRange), Name = BLLHelper.TrimName(name), Surname = BLLHelper.TrimSurname(surname), Birthday = birthday, Phone = tempPhone, Mail = tempMail, City = tempCity, County = tempCounty, Picture = BLLHelper.DefaultDoctorPic(), Password = PasswordCrypto.EncryptToSha512(ssn), UpdateTime = DateTime.Now, HospitalId = hospital.Id }; repositoryDoctor.CUDOperation(doctor, EntityState.Added); return(repositoryDoctor.SaveChanges()); } else { return(-112); } } else { return(-111); } } else { return(-110); } } } else { return(-1); } }
public int MemberRegister(MemberEnumGender gender, string ssn, string password, string name, string surname, string phone, string mail, DateTime birthday) { int returnValueInt = 0; if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && !string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && ssn.Length == 11 && birthday != null) { string tempPhone; string tempMail; if (string.IsNullOrEmpty(phone.Trim())) { tempPhone = null; } else { tempPhone = phone; } if (string.IsNullOrEmpty(mail.Trim())) { tempMail = null; } else { tempMail = mail; } using (RepositoryMember repositoryMember = new RepositoryMember()) { if (!repositoryMember.AnyWithExplicitLoad(I => I.Ssn == ssn)) { if (!repositoryMember.AnyWithExplicitLoad(I => I.Phone == phone)) { if (!repositoryMember.AnyWithExplicitLoad(I => I.Mail == mail)) { repositoryMember.CUDOperation(new Member() { Id = Guid.NewGuid(), Ssn = ssn, Name = BLLHelper.TrimName(name), Surname = BLLHelper.TrimSurname(surname), Gender = gender, Birthday = birthday, Phone = tempPhone, Mail = tempMail, Password = PasswordCrypto.EncryptToSha512(password), Picture = BLLHelper.DefaultUserPic() }, EntityState.Added); returnValueInt = repositoryMember.SaveChanges(); } else { returnValueInt = -102; } } else { returnValueInt = -101; } } else { returnValueInt = -100; } } } else { returnValueInt = -1; } return(returnValueInt); }