public async Task <IViewComponentResult> InvokeAsync() { var roles = ((ClaimsPrincipal)User).GetSpecificClaim("Roles"); List <FunctionViewModel> functions; if (roles.Split(";").Contains(CommonConstants.AppRole.AdminRole)) { functions = await _functionService.GetAllAsync(string.Empty); } else { //TODO get function by permission functions = new List <FunctionViewModel>(); } return(View(functions)); }
public async Task <IActionResult> ManageRoleAction(string roleId) { try { var lstFuncAction = await _functionService.GetAllFunctionAction(); var functions = await _functionService.GetAllAsync(""); foreach (var function in functions) { function.ListActions = lstFuncAction.Where(m => m.FunctionViewModel.Id == function.Id).Select(m => m.ActionViewModel).ToList(); } var role = await _roleService.GetById(roleId); var model = new PageFunctionViewModel { ListFunctionViewModels = functions, AppRoleViewModel = role }; var content = await _viewRenderService.RenderToStringAsync("Role/_ManageRoleAction", model); return(Json(new JsonResponse() { Success = true, StatusCode = Utilities.Constants.StatusCode.GetDataSuccess, Message = Constants.GetDataSuccess, Data = content })); } catch (Exception e) { return(Json(new JsonResponse() { Success = false, StatusCode = Utilities.Constants.StatusCode.GetDataFailed, Message = e.Message })); } }
public IActionResult GetAllFillter(string filter) { var model = _functionService.GetAllAsync(filter); return(new ObjectResult(model)); }
public async Task <IActionResult> GetAllFilter(string filter) { var model = await _functionService.GetAllAsync(filter); return(new OkObjectResult(_mapper.Map <IReadOnlyList <Function>, IReadOnlyList <FunctionViewModel> >(model))); }
public async Task <IViewComponentResult> InvokeAsync() { var roles = ((ClaimsPrincipal)User).GetSpecificClaim("Roles"); List <FunctionViewModel> functions; if (roles.Split(";").Contains("Admin")) { functions = _mapper.Map <IReadOnlyList <Function>, List <FunctionViewModel> >(await _functionService.GetAllAsync(String.Empty)); } else { // To do: get by permission functions = _mapper.Map <IReadOnlyList <Function>, List <FunctionViewModel> >(await _functionService.GetAllAsync(String.Empty)); } return(View(functions)); }