public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { RegisterManager registerManager = new RegisterManager(); if (!registerManager.IsUserLoginIDExist(model.username)) { Roles.AddUserToRole(model.username, model.accessLevel); registerManager.Add(model); FormsAuthentication.SetAuthCookie(model.username, false); AM.auditUserID = LM.GetSurgeonID(model.username); AM.auditUserName = model.username; AM.auditDate = DateTime.Now; AM.auditAttribute = "All"; AM.auditTable = "Surgeon"; AM.access = "I"; audit.Add(AM); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", "LogID already taken"); } } model.InstitutionList = new SelectList(ICon.GetInstitutionList(), "institutionId", "institutionNameAndLocation"); model.accessLevelList = new SelectList( new List<SelectListItem> { new SelectListItem {Selected = false, Text = "Surgeon", Value = "surgeon"}, new SelectListItem {Selected = false, Text = "Customer Service", Value = "customer service"}, new SelectListItem {Selected = false, Text = "Auditor", Value = "auditor"}, }, "Value", "Text", 1); return View(model); }
public ActionResult Register() { RegisterModel IData = new RegisterModel(); IData.InstitutionList = new SelectList(ICon.GetInstitutionList(), "institutionId", "institutionNameAndLocation"); IData.accessLevelList = new SelectList( new List<SelectListItem> { new SelectListItem {Selected = false, Text = "Surgeon", Value = "surgeon"}, new SelectListItem {Selected = false, Text = "Customer Service", Value = "customer service"}, new SelectListItem {Selected = false, Text = "Auditor", Value = "auditor"}, }, "Value", "Text", 1); return View(IData); }
public void Add(RegisterModel user) { Database.Surgeon surgeon = new Database.Surgeon(); surgeon.institutionID = user.institutionId; surgeon.firstName = user.firstName; surgeon.lastName = user.lastName; surgeon.email = user.email; surgeon.username = user.username; surgeon.password = user.Password; surgeon.accessLevel = user.accessLevel; surgeon.active = true; dre.AddToSurgeons(surgeon); dre.SaveChanges(); }