Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

SelectionLevelService.cs 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Diligent.WebAPI.Business.Extensions;
  2. using Diligent.WebAPI.Contracts.DTOs.SelectionLevel;
  3. namespace Diligent.WebAPI.Business.Services
  4. {
  5. public class SelectionLevelService : ISelectionLevelService
  6. {
  7. private readonly DatabaseContext _context;
  8. private readonly IMapper _mapper;
  9. public SelectionLevelService(DatabaseContext context, IMapper mapper)
  10. {
  11. _context = context;
  12. _mapper = mapper;
  13. }
  14. public async Task<List<SelectionLevelResponseWithDataDto>> GetAllAsync() =>
  15. _mapper.Map<List<SelectionLevelResponseWithDataDto>>(await _context.SelectionLevels.Include(sl => sl.SelectionProcesses).ThenInclude(sp => sp.Applicant).ToListAsync());
  16. public async Task<SelectionLevelResposneDto> GetByIdAsync(int id)
  17. {
  18. var sl = await _context.SelectionLevels.FindAsync(id);
  19. if (sl is null)
  20. throw new EntityNotFoundException("Selection level not found");
  21. return _mapper.Map<SelectionLevelResposneDto>(sl);
  22. }
  23. public List<SelectionLevelResponseWithDataDto> GetFilteredLevelsAsync(SelectionProcessFilterDto filters)
  24. {
  25. var filteredLevels = _context.SelectionLevels.Include(x => x.SelectionProcesses).ThenInclude(sp => sp.Applicant).ToList().FilterLevels(filters);
  26. return _mapper.Map<List<SelectionLevelResponseWithDataDto>>(filteredLevels);
  27. }
  28. }
  29. }