public async Task <IActionResult> Get( [FromRoute] string location, [FromRoute] DawnDuskType dawnduskType, [FromRoute] string dateInput) { if (dawnduskType == DawnDuskType.Unknown) { return(BadRequest("Invalid Dawn/Dusk request type, accepted values: sunrise|sunset|zenith|dayDuration|all")); } if (string.IsNullOrWhiteSpace(location)) { return(BadRequest("Location must be provided")); } DateTimeOffset?date = GetDateFromInput(dateInput); if (date.HasValue) { var coordinates = await _geolocationHelper.GetLocationAsync(location); if (coordinates == null) { return(BadRequest($"Location {location} not found")); } var utcOffset = await _geolocationHelper.GetUtcOffsetAsync(coordinates, date.Value); return(Ok(new DawnDusk(date.Value, coordinates, dawnduskType, utcOffset))); } return(BadRequest("Invalid date, accepted values: now|tomorrow|yesterday|date(YYYY-MM-DD)")); }
public async Task <IActionResult> Get([FromRoute] string location) { if (!string.IsNullOrWhiteSpace(location)) { var response = await _geolocationHelper.GetLocationAsync(location); if (response != null) { return(Ok((GeoCoordinatesResponse)response)); } return(BadRequest($"Location {location} not found")); } return(BadRequest("location must be provided")); }