コード例 #1
0
        public async Task <LicenseDto> GetAsync(Guid id)
        {
            var license = await _licenseRepository.GetAsync(id);

            if (license == null)
            {
                throw new ServiceException("license_not_found",
                                           $"License: '{id}' was not found. ");
            }
            return(_mapper.Map <License, LicenseDto>(license));
        }
コード例 #2
0
        public async Task <SofaLicense> GetLicense(int licenseId, long userId)
        {
            var license = await _licenseRepo.GetAsync(licenseId);

            if (license == null)
            {
                throw new System.UnauthorizedAccessException("Unable process request");
            }

            if (!await IsUserReadAuthorized(license, userId))
            {
                throw new System.UnauthorizedAccessException("Unauthorized");
            }

            return(license);
        }
コード例 #3
0
 public async Task <IEnumerable <SofaLicense> > GetLicenses()
 {
     return(await _licenseRepo.GetAsync());
 }