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)); }
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(); }