public async Task <OfferResponse> GetByIdAsync(int id) { var existingOffer = await _offerRepository.FindById(id); if (existingOffer == null) { return(new OfferResponse("Offer not found")); } return(new OfferResponse(existingOffer)); }
public async Task <IActionResult> GetOffer(int id) { var location = GetControllerActionNames(); try { _logger.LogInfo($"{location}: Attempted Call for id: {id}"); var offer = await _offerRepository.FindById(id); if (offer == null) { _logger.LogWarn($"{location}: Failed to retrieve record with id: {id}"); return(NotFound()); } var response = _mapper.Map <OfferDTO>(offer); _logger.LogInfo($"{location}: Successfully got record with id: {id}"); return(Ok(response)); } catch (Exception e) { return(InternalError($"{location}: {e.Message} - {e.InnerException}")); } }