| 123456789101112131415161718192021222324252627282930313233 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Diligent.WebAPI.Business.Services
- {
- public class TechnologyService : ITechnologyService
- {
- private readonly DatabaseContext _context;
- private readonly IMapper _mapper;
-
- public TechnologyService(IMapper mapper, DatabaseContext context)
- {
- _mapper = mapper;
- _context = context;
- }
-
- public async Task<List<TechnologyResponseDto>> GetAllAsync() =>
- _mapper.Map<List<TechnologyResponseDto>>(await _context.Technologies.ToListAsync());
-
- public async Task<TechnologyResponseDto> GetByIdAsync(int id)
- {
- var technology = await _context.Technologies.FindAsync(id);
-
- if (technology is null)
- throw new EntityNotFoundException("Technology not found");
-
- return _mapper.Map<TechnologyResponseDto>(technology);
- }
- }
- }
|