namespace Diligent.WebAPI.Business.Services { public class TechnologyService : ITechnologyService { private readonly DatabaseContext _context; private readonly ILogger _logger; private readonly IMapper _mapper; public TechnologyService(IMapper mapper, DatabaseContext context, ILogger logger) { _mapper = mapper; _context = context; _logger = logger; } public async Task> GetAllAsync() { return _mapper.Map>(await _context.Technologies.ToListAsync()); } public async Task GetByIdAsync(int id) { _logger.LogInformation($"Start searching Techology with id = {id}"); var technology = await _context.Technologies.FindAsync(id); if (technology is null) { _logger.LogError($"Technology with id = {id} not found"); throw new EntityNotFoundException("Technology not found"); } _logger.LogInformation($"Mapping Technology with id = {id}"); var result = _mapper.Map(technology); _logger.LogInformation($"Technology with id = {id} mapped successfully"); return result; } public async Task GetEntityByIdAsync(int id) { _logger.LogInformation($"Start searching Ad with id = {id}"); var technology = await _context.Technologies.FindAsync(id); if (technology is null) { _logger.LogError($"Technology with id = {id} not found"); throw new EntityNotFoundException("Technology not found"); } _logger.LogInformation($"Technology with id = {id} found successfully"); return technology; } } }