public async Task <List <SurfMoment> > GetSurfForecastFromApi(SurfSpot surfSpot) { var url = HttpHelpers.BuildUrl("www-2019-2133843493.us-east-1.elb.amazonaws.com", $"/api/spot/forecast/{Convert.ToInt32(surfSpot)}", useHttps: false); var result = await _httpClientFactory.CreateClient().SendAndReceiveAs <List <SurfMoment> >(HttpMethod.Get, url); return(result); }
public async Task <string> GetCurrentSurfMessage(SurfSpot surfSpot) { var currentSurf = await this.GetCurrentSurf(surfSpot); var shape = currentSurf.shape_full.Replace("-", " to "); return($"The surf at {currentSurf.spot_name} is rated {shape} with a height of {Math.Round(currentSurf.size_ft, 1)} feet. "); }
public async Task <SurfMoment> GetCurrentSurf(SurfSpot surfSpot) { var surfForecast = await this.GetSurfForecast(surfSpot); var utcNow = DateTime.UtcNow; var gmt = $"{utcNow.Year}-{utcNow.Month}-{utcNow.Day} {utcNow.Hour}"; return(surfForecast.FirstOrDefault(s => s.gmt == gmt)); }
public async Task <List <SurfMoment> > GetSurfForecast(SurfSpot surfSpot) { var key = surfSpot.ToString(); var result = await _surfForecastCache.Get(key); if (result == null) { result = await this.GetSurfForecastFromApi(surfSpot); await _surfForecastCache.Set(result, key); } return(result); }
// PUT: api/SurfSpots/5 public void Put(int id, [FromBody] SurfSpot spot) { var surfSpotRepository = new SurfSpotRepository(); var updatedSpot = surfSpotRepository.Save(id, spot); }
// POST: api/SurfSpots public void Post([FromBody] SurfSpot spot) { var surfSpotRepository = new SurfSpotRepository(); var newSpot = surfSpotRepository.Save(spot); }