public ActionResult EditPharmacist(int PharmacistCode, int PharmacyCode, string FirstName, string LastName, string Email, string Phone, bool IsAdmin = false, bool IsActive = false) { Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", ""); if (Phone.Length == 10) { Phone = "1" + Phone; } using (var service = new PharmacistService()) { Pharmacist p = service.Get(PharmacistCode); if (p != null) { p.FirstName = FirstName; p.LastName = LastName; p.Phone = Phone; p.Email = Email; var temp1 = p.AllJobs.Where(x => x.Pharmacy.Code == PharmacyCode).FirstOrDefault(); using (var serviceJob = new JobService()) { var j = serviceJob.GetWhere(JobService.CodeCol == temp1.Code).FirstOrDefault(); j.IsActive = IsActive; j.IsAdmin = IsAdmin; serviceJob.Update(j); } service.Update(p); } return(RedirectToAction("SinglePharmacy", new RouteValueDictionary( new { controller = "SystemAdmin", action = "SinglePharmacy", Id = PharmacyCode }))); } }
public ActionResult EditPharmacist(int Code, int PharmacyCode, string FirstName, string LastName, string Email, string Phone, bool IsActive = false, bool IsAdmin = false) { Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", ""); if (Phone.Length == 10) { Phone = "1" + Phone; } using (var service = new PharmacistService()) { Pharmacist p = service.Get(Code); if (p != null) { p.FirstName = FirstName; p.LastName = LastName; p.Phone = Phone; p.Email = Email; service.Update(p); using (var jobservice = new JobService()) { //these get the value, not the checked value var job = jobservice.GetWhere(JobService.PharmacistCodeCol == p.Code & JobService.PharmacyCodeCol == PharmacyCode).FirstOrDefault(); job.IsActive = IsActive; job.IsAdmin = IsAdmin; jobservice.Update(job); } } return(RedirectToAction("Pharmacy", new RouteValueDictionary( new { controller = "ManagePharmacist", action = "Pharmacy" }))); } }
public static byte[] HashPassword(Pharmacist pharmacist, string password) { using (var service = new PharmacistService()) { var salt = CreateSalt(32); pharmacist.PasswordSalt = salt; pharmacist.PasswordHash = GenerateSaltedHash(Encoding.ASCII.GetBytes(password), pharmacist.PasswordSalt); service.Update(pharmacist); return(pharmacist.PasswordHash); } }
public static bool ResetPharmacistPassword(string token, Pharmacist pharmacist, byte[] newPasswordHash) { using (var service = new PharmacistTokenService()) { var pharmacistToken = service.GetWhere(PharmacistTokenService.TokenCol == token).FirstOrDefault(); if (pharmacistToken != null && pharmacist != null && pharmacistToken.Expires > DateTime.Now.ToUniversalTime() && pharmacistToken.Pharmacist.Code == pharmacist.Code) { service.Delete(pharmacistToken.Code); using (var pharmacistService = new PharmacistService()) { pharmacist.PasswordHash = newPasswordHash; pharmacistService.Update(pharmacist); } return(true); } return(false); } }
public ActionResult EditPharmacist(int Code, int PharmacyCode, string FirstName, string LastName, string Email, string Phone) { Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", ""); if (Phone.Length == 10) { Phone = "1" + Phone; } using (var service = new PharmacistService()) { Pharmacist p = service.Get(Code); if (p != null) { p.FirstName = FirstName; p.LastName = LastName; p.Phone = Phone; p.Email = Email; service.Update(p); } return(RedirectToAction("SinglePharmacy", new RouteValueDictionary( new { controller = "SystemAdmin", action = "SinglePharmacy", Id = PharmacyCode }))); } }