// GET: Permissions/AddToRoles/5 public ActionResult LinkRoles(int appId) { if (appId == 0) { return(NotFound()); } //Get all permissions and roles for application + all the currently selected permissions in roles PermissionsToRolesViewModel permsRolesVM = new PermissionsToRolesViewModel(); permsRolesVM.ApplicationId = appId; permsRolesVM.PossiblePermissions = _context.Permission.Where(s => s.ApplicationId == appId && s.Deleted != true).ToList(); permsRolesVM.PossibleRoles = _context.Role.Where(s => s.ApplicationId == appId && s.Deleted != true).ToList(); permsRolesVM.ExistingRolePermission = _context.RolePermission.Where(s => s.ApplicationId == appId).ToList(); return(View(permsRolesVM)); }
public async Task <IActionResult> LinkRoles([Bind("ApplicationId,CurrentPermissionId,CurrentRoleIds")] PermissionsToRolesViewModel permsRolesvm) { try { //TODO - should I wipe these out or figure out if the relationship exists then delete the ones not there? RUN It by Doug // - NEEDs to be async call to SAVE // - ASYNC reader on DDL change to show which ones were selected already // - REUSABLE pattern for thigns down the line //TODO - this should ONLY be an ASYNC call and therefore not need a redicrect in it's final version return(Ok("Saved successfully!")); } catch (Exception ex) { return(Ok(ex.Message)); } }