public ActionResult Create(Staff staff) { if (ModelState.IsValid) { string hash = new SecurityHandler().HashPassword(staff.Password); staff.Password = hash; db.Staffs.Add(staff); db.SaveChanges(); return RedirectToAction("Index"); } return View(staff); }
public ActionResult Edit(Staff staff) { if (ModelState.IsValid) { db.Entry(staff).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(staff); }
public ActionResult RegisterClinic(string name, string username, string password, string fullname, string mobile, string email) { try { //var guid = new Guid() string clinicId = username + Guid.NewGuid(); var staff = new Staff { Role = "admin", Username = username.ToLower(), Password = new SecurityHandler().HashPassword(password).ToLower(), EmailAddress = email.ToLower(), ClinicId = clinicId.ToLower(), Fullname = fullname.ToLower(), Phonenumber = mobile.ToLower() }; var clinic = new Clinic {Name = name, UniqueId = clinicId,}; clinic.Staffs = new List<Staff>(){staff}; db.Clinics.Add(clinic); db.SaveChanges(); return Json("200", JsonRequestBehavior.AllowGet); } catch (Exception ex) { Debug.WriteLine(ex.Message); } return Json("error", JsonRequestBehavior.AllowGet); }