You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FileEntityService.cs 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Azure.Core;
  2. using Diligent.WebAPI.Contracts.DTOs.File;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Diligent.WebAPI.Business.Services
  9. {
  10. public class FileEntityService : IFileEntityService
  11. {
  12. private readonly ILogger<FileEntityService> _logger;
  13. private readonly DatabaseContext _context;
  14. private readonly IMapper _mapper;
  15. public FileEntityService(DatabaseContext context, ILogger<FileEntityService> logger, IMapper mapper)
  16. {
  17. _context = context;
  18. _logger = logger;
  19. _mapper = mapper;
  20. }
  21. public async Task<List<FileEntityResponse>> GetAllAsync() =>
  22. _mapper.Map<List<FileEntityResponse>>(await _context.Files.Include(x => x.Tags).ToListAsync());
  23. public async Task UploadPdfAsync(FileEntity file)
  24. {
  25. await _context.Files.AddAsync(file);
  26. await _context.SaveChangesAsync();
  27. }
  28. public async Task<IEnumerable<FileEntity>> GetAll()
  29. {
  30. return await _context.Files.ToListAsync();
  31. }
  32. }
  33. }