您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TechnologyService.cs 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }
  36. }