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 int DoctorInfoUpdate(Doctor doctor, string picture) { using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor()) { Image image = Image.FromFile(picture); MemoryStream mem = new MemoryStream(); image.Save(mem, ImageFormat.Png); doctor.Picture = mem.ToArray(); repositoryDoctor.CUDOperation(doctor, EntityState.Modified); return(repositoryDoctor.SaveChanges()); } }
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 DoctorDeleteRecord(Doctor doctor) { if (doctor != null) { using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor()) { doctor.DeleteTime = DateTime.Now; doctor.IsActive = false; repositoryDoctor.CUDOperation(doctor, EntityState.Modified); return(repositoryDoctor.SaveChanges()); } } else { return(-1); } }
public int ReactivateData <Entity>(Entity entity) { if (entity is Hospital) { using (RepositoryHospital repositoryHospital = new RepositoryHospital()) { (entity as Hospital).IsActive = true; repositoryHospital.CUDOperation(entity as Hospital, EntityState.Modified); return(repositoryHospital.SaveChanges()); } } else if (entity is Doctor) { using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor()) { (entity as Doctor).IsActive = true; repositoryDoctor.CUDOperation(entity as Doctor, EntityState.Modified); return(repositoryDoctor.SaveChanges()); } } else if (entity is Member) { using (RepositoryMember repositoryMember = new RepositoryMember()) { (entity as Member).IsActive = true; repositoryMember.CUDOperation(entity as Member, EntityState.Modified); return(repositoryMember.SaveChanges()); } } else if (entity is Medicine) { using (RepositoryMedicine repositoryMedicine = new RepositoryMedicine()) { (entity as Medicine).IsActive = true; repositoryMedicine.CUDOperation(entity as Medicine, EntityState.Modified); return(repositoryMedicine.SaveChanges()); } } else { return(-1); } }
public int DoctorInfoUpdate(Doctor doctor, string phone, string mail, string city, string county) { 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.Id != doctor.Id && I.Phone == phone)) { if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Mail == mail)) { doctor.Phone = tempPhone; doctor.Mail = tempMail; doctor.City = tempCity; doctor.County = tempCounty; repositoryDoctor.CUDOperation(doctor, EntityState.Modified); return(repositoryDoctor.SaveChanges()); } else { return(-112); } } else { return(-111); } } }
public int DoctorUpdateRecord(Doctor doctor, 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 && doctor != 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.Id != doctor.Id && I.Ssn == ssn)) { if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Phone == phone)) { if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Mail == mail)) { doctor.Ssn = ssn; doctor.Appellation = BLLHelper.GetEnumValueFromDescription <DoctorEnumAppellation>(appellation); doctor.Expertise = BLLHelper.GetEnumValueFromDescription <DoctorEnumExpertise>(expertise); doctor.AgeRange = BLLHelper.GetEnumValueFromDescription <DoctorEnumAgeRange>(ageRange); doctor.Name = BLLHelper.TrimName(name); doctor.Surname = BLLHelper.TrimSurname(surname); doctor.Birthday = birthday; doctor.Phone = tempPhone; doctor.Mail = tempMail; doctor.City = tempCity; doctor.County = tempCounty; doctor.UpdateTime = DateTime.Now; doctor.HospitalId = hospital.Id; repositoryDoctor.CUDOperation(doctor, EntityState.Modified); return(repositoryDoctor.SaveChanges()); } else { return(-112); } } else { return(-111); } } else { return(-110); } } } 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); } }