Esempio n. 1
0
        public async Task <IActionResult> GetPermissionsByGroupIdAsync([FromRoute] int groupId, [FromQuery] PermissionGetModel model)
        {
            var currentFunctionCodes = GetCurrentAccountFunctionCodes();

            if (!currentFunctionCodes.Contains("Group_Full") && !currentFunctionCodes.Contains("Group_Read_All"))
            {
                var currentAccount = await _accountRepository.GetAccountByIdAsync(CurrentAccountId);

                if (currentAccount.GroupId != groupId)
                {
                    throw new ForbiddenException();
                }
            }

            model.Validate();

            var permissions = await _groupRepository.GetPermissionsByGroupIdAsync(groupId, model.Page, model.PageSize);

            var functions = await _functionRepository.GetFunctionsAsync(null, null, 1, int.MaxValue);

            if (permissions.Items.Count == 0)
            {
                throw new NotFound404Exception("page");
            }

            return(Ok(PermissionList.GetFrom(permissions, functions.Items)));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetFunctionsAsync([FromQuery] FunctionGetModel model)
        {
            model.Validate();

            var list = await _functionRepository.GetFunctionsAsync(model.Keyword, model.IsActive, model.Page, model.PageSize);

            if (list.Items.Count == 0)
            {
                throw new NotFound404Exception("page");
            }

            return(Ok(FunctionList.GetFrom(list)));
        }