| 12345678910111213141516171819202122232425262728293031 |
- using Diligent.WebAPI.Contracts.DTOs.SelectionLevel;
- using Diligent.WebAPI.Contracts.DTOs.SelectionProcess;
-
- 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);
-
- }
- }
- }
|