public ActionResult PersonAdd() { PersonModel personModel = new PersonModel(); MasterHelper masterHelper = new MasterHelper(); MasterResponse masterResponse = new MasterResponse(); masterResponse = masterHelper.GetAllRoles(); personModel.Roles = masterResponse.Roles; List <SelectListItem> roleListItems = new List <SelectListItem>(); roleListItems.Add(new SelectListItem { Text = "-Select Sub Category-", Value = string.Empty }); if (personModel.Roles != null) { foreach (EH_Role role in personModel.Roles) { SelectListItem selectListItem = new SelectListItem { Text = role.RoleName, Value = Convert.ToString(role.RoleId) }; roleListItems.Add(selectListItem); } } personModel.RoleListItems = roleListItems; return(View(personModel)); }
public ActionResult PersonEdit(string id) { PersonModel personModel = new PersonModel(); PersonHelper personHelper = new PersonHelper(); MasterHelper masterHelper = new MasterHelper(); PersonResponse personResponse = new PersonResponse(); MasterResponse masterResponse = new MasterResponse(); masterResponse = masterHelper.GetAllRoles(); personModel.Roles = masterResponse.Roles; List <SelectListItem> roleListItems = new List <SelectListItem>(); roleListItems.Add(new SelectListItem { Text = "-Select Role-", Value = string.Empty }); if (personModel.Roles != null) { foreach (EH_Role role in personModel.Roles) { SelectListItem selectListItem = new SelectListItem { Text = role.RoleName, Value = Convert.ToString(role.RoleId) }; roleListItems.Add(selectListItem); } } personModel.RoleListItems = roleListItems; personResponse = personHelper.GetPersonDetails(Convert.ToDecimal(id)); if (personResponse.Person != null) { personModel.PersonId = personResponse.Person.PersonId; personModel.PersonName = personResponse.Person.PersonName; personModel.PersonMailID = personResponse.Person.PersonMailID; personModel.UserName = personResponse.Person.UserName; personModel.Password = personResponse.Person.Password; personModel.RoleId = personResponse.Person.RoleId; personModel.Enabled = personResponse.Person.Enabled ?? true; } return(View(personModel)); }