public async Task <IActionResult> Get(int id) { try { var result = await _mediator.Send(new GetTrainingCourseQuery { Id = id }); var model = new GetTrainingCourseResponse { TrainingCourse = result.Course }; return(Ok(model)); } catch (Exception e) { _logger.LogError(e, $"Error attempting to get a training course {id}"); return(BadRequest()); } }
public async Task <IActionResult> Get(int id, [FromQuery] double lat = 0, [FromQuery] double lon = 0, [FromQuery] string location = "", Guid?shortlistUserId = null) { try { var result = await _mediator.Send(new GetTrainingCourseQuery { Id = id, Lat = lat, Lon = lon, LocationName = location, ShortlistUserId = shortlistUserId }); if (result.Course == null) { _logger.LogInformation($"Training course {id} not found"); return(NotFound()); } var model = new GetTrainingCourseResponse { TrainingCourse = result.Course, ProvidersCount = new GetTrainingCourseProviderCountResponse { TotalProviders = result.ProvidersCount, ProvidersAtLocation = result.ProvidersCountAtLocation }, ShortlistItemCount = result.ShortlistItemCount }; return(Ok(model)); } catch (Exception e) { _logger.LogError(e, $"Error attempting to get a training course {id}"); return(BadRequest()); } }