選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

SelectionLevelService.cs 1.0KB

12345678910111213141516171819202122232425262728293031
  1. using Diligent.WebAPI.Contracts.DTOs.SelectionLevel;
  2. using Diligent.WebAPI.Contracts.DTOs.SelectionProcess;
  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).ToListAsync());
  16. public async Task<SelectionProcessResposneDto> 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<SelectionProcessResposneDto>(sl);
  22. }
  23. }
  24. }