示例#1
0
        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));
        }
示例#2
0
        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
                }));
            }
        }
示例#3
0
        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)));
        }
示例#5
0
        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));
        }