示例#1
0
        public async Task <FileModel> GetPhotoByIdAsync(int id)
        {
            var item = await ReadRepository.GetSingleAsync(_photoFiltersProvider.ById(id));

            if (item == null)
            {
                throw new NotFoundException("File was not found!");
            }

            var content = await _fileManager.LoadAsync(item.FileName, FileDestinations.SupplierPhoto);

            return(item.ToFileModel(content));
        }
示例#2
0
        public async Task RemovePhotoAsync(int id)
        {
            var item = await _readRepository.GetSingleAsync(_supplierPhotoFiltersProvider.ById(id));

            if (item == null)
            {
                throw new NotFoundException("File was not found!");
            }

            await WriteRepository.RemoveByIdAsync <SupplierPhoto>(id);

            await _fileManager.DeleteAsync(item.FileName, FileDestinations.SupplierPhoto);

            await UnitOfWork.CommitAsync();
        }