Example #1
0
        public async Task <DataWithCount <IEnumerable <Mail> > > GetAllPaginatedAsync(int skip,
                                                                                      int take)
        {
            int siteId = GetClaimId(ClaimType.SiteId);

            if (HasPermission(Permission.ReadAllMail))
            {
                return(new DataWithCount <IEnumerable <Mail> >
                {
                    Data = await _mailRepository.PageAllAsync(siteId, skip, take),
                    Count = await _mailRepository.GetAllCountAsync(siteId)
                });
            }
            else
            {
                var userId = GetClaimId(ClaimType.UserId);
                _logger.LogError($"User {userId} doesn't have permission to get all mails.");
                throw new GraException("Permission denied.");
            }
        }