| 123456789101112131415161718192021222324252627282930313233343536373839 |
- using Azure.Core;
- using Diligent.WebAPI.Contracts.DTOs.File;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Diligent.WebAPI.Business.Services
- {
- public class FileEntityService : IFileEntityService
- {
- private readonly ILogger<FileEntityService> _logger;
- private readonly DatabaseContext _context;
- private readonly IMapper _mapper;
-
- public FileEntityService(DatabaseContext context, ILogger<FileEntityService> logger, IMapper mapper)
- {
- _context = context;
- _logger = logger;
- _mapper = mapper;
- }
-
- public async Task<List<FileEntityResponse>> GetAllAsync() =>
- _mapper.Map<List<FileEntityResponse>>(await _context.Files.Include(x => x.Tags).ToListAsync());
-
- public async Task UploadPdfAsync(FileEntity file)
- {
- await _context.Files.AddAsync(file);
-
- await _context.SaveChangesAsync();
- }
-
- public async Task<IEnumerable<FileEntity>> GetAll()
- {
- return await _context.Files.ToListAsync();
- }
- }
- }
|