Пример #1
0
        public async Task <ApiListResponse <ProviderRoleDisplayModel> > GetProviderRoles(string slug)
        {
            if (string.IsNullOrWhiteSpace(slug))
            {
                throw new ModelDamagedException("slug is null");
            }

            slug = slug.ToLower();

            if (!await _providerRepository.ExistsWithOwnerSlug(slug, (await GetCurrentUser())?.Id))
            {
                throw new AccessDeniedException(slug, typeof(Provider));
            }

            var result = (await _providerRepository.GetRolesBySlug(slug))?.Select(x => _mapper.Map <ProviderRoleDisplayModel>(x)).ToList() ?? new List <ProviderRoleDisplayModel>();

            return(new ApiListResponse <ProviderRoleDisplayModel>(result, 0, 0, result.Count));
        }