public ActionResult EditReceptionists(int id) { var collection = new ReceptionistCollection { Receptionist = db.Receptionists.Single(c => c.Id == id) }; return(View(collection)); }
public ActionResult AddReceptionist() { var collection = new ReceptionistCollection { ApplicationUser = new RegisterViewModel(), Receptionist = new Receptionist() }; return(View(collection)); }
public ActionResult EditReceptionists(int id, ReceptionistCollection model) { var receptionist = db.Receptionists.Single(c => c.Id == id); receptionist.FirstName = model.Receptionist.FirstName; receptionist.LastName = model.Receptionist.LastName; receptionist.FullName = model.Receptionist.FirstName + " " + model.Receptionist.LastName; //receptionist.ContactNo = model.Receptionist.ContactNo; receptionist.PhoneNo = model.Receptionist.PhoneNo; receptionist.Gender = model.Receptionist.Gender; receptionist.BloodGroup = model.Receptionist.BloodGroup; receptionist.DateOfBirth = model.Receptionist.DateOfBirth; receptionist.Address = model.Receptionist.Address; receptionist.Status = model.Receptionist.Status; db.SaveChanges(); return(RedirectToAction("ListOfReceptionists")); }
public async Task <ActionResult> AddReceptionist(ReceptionistCollection model) { var user = new ApplicationUser { UserName = model.ApplicationUser.UserName, Email = model.ApplicationUser.Email, UserRole = "Receptionist", RegisteredDate = DateTime.Now.Date }; var result = await UserManager.CreateAsync(user, model.ApplicationUser.Password); if (result.Succeeded) { await UserManager.AddToRoleAsync(user.Id, "Receptionist"); var nurse = new Receptionist { FirstName = model.Receptionist.FirstName, LastName = model.Receptionist.LastName, FullName = model.Receptionist.FirstName + " " + model.Receptionist.LastName, EmailAddress = model.ApplicationUser.Email, //ContactNo = model.Receptionist.ContactNo, PhoneNo = model.Receptionist.PhoneNo, Gender = model.Receptionist.Gender, BloodGroup = model.Receptionist.BloodGroup, ApplicationUserId = user.Id, DateOfBirth = model.Receptionist.DateOfBirth, Address = model.Receptionist.Address, Status = model.Receptionist.Status }; db.Receptionists.Add(nurse); db.SaveChanges(); return(RedirectToAction("ListOfReceptionists")); } return(HttpNotFound()); }