| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using Diligent.WebAPI.Business.Extensions;
- using Diligent.WebAPI.Contracts.DTOs.SelectionLevel;
-
- namespace Diligent.WebAPI.Business.Services
- {
- public class SelectionLevelService : ISelectionLevelService
- {
- private readonly DatabaseContext _context;
- private readonly IMapper _mapper;
-
- public SelectionLevelService(DatabaseContext context, IMapper mapper)
- {
- _context = context;
- _mapper = mapper;
- }
-
- public async Task<List<SelectionLevelResponseWithDataDto>> GetAllAsync() =>
- _mapper.Map<List<SelectionLevelResponseWithDataDto>>(await _context.SelectionLevels.Include(sl => sl.SelectionProcesses).ThenInclude(sp => sp.Applicant).ToListAsync());
-
- public async Task<SelectionLevelResposneDto> GetByIdAsync(int id)
- {
- var sl = await _context.SelectionLevels.FindAsync(id);
-
- if (sl is null)
- throw new EntityNotFoundException("Selection level not found");
-
- return _mapper.Map<SelectionLevelResposneDto>(sl);
-
- }
-
- public List<SelectionLevelResponseWithDataDto> GetFilteredLevelsAsync(SelectionProcessFilterDto filters)
- {
- var filteredLevels = _context.SelectionLevels.Include(x => x.SelectionProcesses).ThenInclude(sp => sp.Applicant).ToList().FilterLevels(filters);
-
- return _mapper.Map<List<SelectionLevelResponseWithDataDto>>(filteredLevels);
- }
- }
- }
|