Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

TechnologyService.cs 999B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Diligent.WebAPI.Business.Services
  7. {
  8. public class TechnologyService : ITechnologyService
  9. {
  10. private readonly DatabaseContext _context;
  11. private readonly IMapper _mapper;
  12. public TechnologyService(IMapper mapper, DatabaseContext context)
  13. {
  14. _mapper = mapper;
  15. _context = context;
  16. }
  17. public async Task<List<TechnologyResponseDto>> GetAllAsync() =>
  18. _mapper.Map<List<TechnologyResponseDto>>(await _context.Technologies.ToListAsync());
  19. public async Task<TechnologyResponseDto> GetByIdAsync(int id)
  20. {
  21. var technology = await _context.Technologies.FindAsync(id);
  22. if (technology is null)
  23. throw new EntityNotFoundException("Technology not found");
  24. return _mapper.Map<TechnologyResponseDto>(technology);
  25. }
  26. }
  27. }