Пример #1
0
        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);
        }
Пример #2
0
        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. ");
        }
Пример #3
0
        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));
        }
Пример #4
0
        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);
        }
Пример #5
0
 // PUT: api/SurfSpots/5
 public void Put(int id, [FromBody] SurfSpot spot)
 {
     var surfSpotRepository = new SurfSpotRepository();
     var updatedSpot        = surfSpotRepository.Save(id, spot);
 }
Пример #6
0
 // POST: api/SurfSpots
 public void Post([FromBody] SurfSpot spot)
 {
     var surfSpotRepository = new SurfSpotRepository();
     var newSpot            = surfSpotRepository.Save(spot);
 }