public ActionResult Index() { AccessRolesViewModel model = new AccessRolesViewModel(); string roleId = null; if (Request["RoleId"] != null) { roleId = Request["RoleId"]; } try { model.AllRoles = new RoleRepository(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString).GetAll().OrderBy(m => m.Name).ToList(); model.AllOperations = _identityStore.GetAllOperations(); if (!string.IsNullOrEmpty(roleId)) { //List access by role //model.AccessList = _identityStore.GetAccessByRoleId(roleId); //model.AccessList = _identityStore.GetAccessByRoleId(roleId); //if (model.AccessList != null && model.AccessList.Count > 0) //{ // foreach (var acc in model.AccessList) // { // acc.OperationsList = _identityStore.GetOperationsByAccessId(acc.AccessId).ToList(); // } //} model.RoleId = roleId; model.PermissionsList = _identityStore.GetPermissionByRoleId(roleId); //All access model.AllAccess = _identityStore.GetAllAccess(); if (model.AllAccess != null && model.AllAccess.Count > 0) { foreach (var acc in model.AllAccess) { acc.OperationsList = _identityStore.GetOperationsByAccessId(acc.Id).ToList(); } } } } catch (Exception ex) { this.AddNotification("Failed to get data: " + ex.ToString(), NotificationType.ERROR); return(View(model)); } return(View(model)); }
public ActionResult Index(FunctionViewModel model) { ModelState.Clear(); var strError = string.Empty; try { model.AllAccesses = _identityStore.GetAllAccess(); model.AllOperations = _identityStore.GetAllOperations(); } catch (Exception ex) { strError = string.Format("Could not GetAllAccess because: {0}", ex.ToString()); logger.Error(strError); this.AddNotification(strError, NotificationType.ERROR); } return(View(model)); }