/// <summary> /// Load page to Edit user /// </summary> /// <param name="userId"></param> /// <returns></returns> public ActionResult EditUser(int userId) { AccountDbAccess ADA = new AccountDbAccess(); DataTable dtUserDetails = ADA.LoadUserDetails(userId); if (dtUserDetails != null) { var model = new EditUserModel { FirstName = dtUserDetails.Rows[0]["FirstName"].ToString(), LastName = dtUserDetails.Rows[0]["LastName"].ToString(), Email = dtUserDetails.Rows[0]["Email"].ToString(), Phone = dtUserDetails.Rows[0]["Phone"].ToString(), selectedGroupId = dtUserDetails.Rows[0]["GroupID"].ToString(), SeletedStatusId = dtUserDetails.Rows[0]["Active"].ToString(), }; model.UserId = userId; model.groupList = new List <ItemsList>(); model.statusList = new List <ItemsList>() { new ItemsList { Value = "1", Text = "Active" }, new ItemsList { Value = "0", Text = "InActive" } }; DataTable dtGroups = AccountDbAccess.LoadGroupOptions(); foreach (DataRow row in dtGroups.Rows) { model.groupList.Add(new ItemsList { Value = row["GroupID"].ToString(), Text = row["GroupName"].ToString() }); } TempData["groupList"] = model.groupList; TempData["statusList"] = model.statusList; return(PartialView(model)); } else { // show error message here and redirect ToString error page return(null); } }
/// <summary> /// Load page to Add user /// </summary> /// <returns></returns> public ActionResult AddUser() { var model = new AddUserModel(); model.groupList = new List <ItemsList>(); DataTable dtGroups = AccountDbAccess.LoadGroupOptions(); foreach (DataRow row in dtGroups.Rows) { model.groupList.Add(new ItemsList { Value = row["GroupID"].ToString(), Text = row["GroupName"].ToString() }); } model.selectedGroupId = dtGroups.Rows[0]["GroupID"].ToString(); TempData["groupList"] = model.groupList; return(PartialView(model)); }