Exemplo n.º 1
0
        public async Task <ApiResponse> GetAllAsync()
        {
            var includeParams = new IncludeStringConstants().RolePermissionIncludeList;

            includeParams.Add("Users.User");
            var role = await _roleService.FindBy(c => c.IsEditable, includeParams.ToArray()).ToListAsync().ConfigureAwait(false);

            var data = _mapper.Map <List <Role>, List <RoleGetData> >(role);

            return(new ApiResponse(data));
        }
Exemplo n.º 2
0
        public async Task <ApiResponse> GetInfoAsync()
        {
            var includeParams = new IncludeStringConstants().UserRolePermissionIncludeArray.ToList();

            includeParams.Add("Detail");
            var item = await _userService.GetUserByNameAsync(User.Identity.Name, includeParams.ToArray()).ConfigureAwait(false);

            if (item != null)
            {
                return(new ApiResponse(_mapper.Map <User, UserGetData>(item), StatusCodes.Status200OK));
            }
            throw new ApiException(MessageBuilder.NotFound, StatusCodes.Status404NotFound);
        }
Exemplo n.º 3
0
        public async Task <ApiResponse> GetAsync(string id)
        {
            var includeParams = new IncludeStringConstants().RolePermissionIncludeList;

            includeParams.Add("Users.User");
            var role = await _roleService.GetRoleByIdAsync(id, includeParams.ToArray()).ConfigureAwait(false);

            if (role != null)
            {
                var data = _mapper.Map <Role, RoleGetData>(role);
                return(new ApiResponse(data));
            }

            throw new ApiException(MessageBuilder.NotFound, StatusCodes.Status404NotFound);
        }