Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

TechnologyService.cs 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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<List<TechnologyApplicantViewDto>> GetAllAsync2() =>
  20. _mapper.Map<List<TechnologyApplicantViewDto>>(await _context.Technologies.ToListAsync());
  21. public async Task<TechnologyResponseDto> GetByIdAsync(int id)
  22. {
  23. var technology = await _context.Technologies.FindAsync(id);
  24. if (technology is null)
  25. throw new EntityNotFoundException("Technology not found");
  26. return _mapper.Map<TechnologyResponseDto>(technology);
  27. }
  28. public async Task<TechnologyApplicantViewDto> GetByIdAsync2(int id)
  29. {
  30. var technology = await _context.Technologies.FindAsync(id);
  31. if (technology is null)
  32. throw new EntityNotFoundException("Technology not found");
  33. return _mapper.Map<TechnologyApplicantViewDto>(technology);
  34. }
  35. public async Task<Technology> GetEntityByIdAsync(int id)
  36. {
  37. var technology = await _context.Technologies.FindAsync(id);
  38. if (technology is null)
  39. throw new EntityNotFoundException("Technology not found");
  40. return technology;
  41. }
  42. }
  43. }