Ejemplo n.º 1
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
                }));
            }
        }