Example #1
0
        public IActionResult Persistir([FromBody] ForecastVM forecastVM)
        {
            try
            {
                var forecast = Mapper.Map <ForecastET>(forecastVM);
                forecast.ValorForecast.Usuario = _variables.UsuarioToken;

                if (forecastVM.Id == 0)
                {
                    _forecastService.Adicionar(forecast);
                }
                else if (forecastVM.Id == 1)
                {
                    _forecastService.Atualizar(forecast);
                }

                return(Ok(true));
            }
            catch (ArgumentException ex)
            {
                return(StatusCode(409, ex.Message));
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
        public void InvalidLocation()
        {
            var vm = new ForecastVM();

            vm.GetForecast("No where", 0);

            Assert.IsTrue(vm.Forecast.Consolidated_Weather != null);
            Assert.IsTrue(vm.Forecast.Consolidated_Weather.Count == 1);
            Assert.IsTrue(vm.Forecast.Consolidated_Weather[0].Weather_State_Abbr == "err");
        }
        public void ValidLocation()
        {
            var vm = new ForecastVM();

            vm.GetForecast("London", 44418);

            Assert.IsTrue(vm.Forecast.Consolidated_Weather != null);
            Assert.IsTrue(vm.Forecast.Consolidated_Weather.Count > 0);
            Assert.IsTrue(vm.Forecast.Consolidated_Weather[0].Location == "London");
        }
        public IActionResult ParkForecast(string parkCode)
        {
            string s = HttpContext.Session.GetString(tempChoice);

            ViewData["TempPref"] = s;
            ForecastVM forecastVM = new ForecastVM();

            forecastVM.ParkCode  = parkCode;
            forecastVM.Forecasts = weatherDAO.Get5DayForecast(parkCode);
            return(View(forecastVM));
        }
Example #5
0
 public IActionResult VerificarSeRegistroForecastExiste([FromBody] ForecastVM forecastVM)
 {
     try
     {
         var forecast = Mapper.Map <ForecastET>(forecastVM);
         forecast.ValorForecast.Usuario = _variables.UsuarioToken;
         var resultStfCorp = _forecastService.VerificarSeRegistroExiste(forecast);
         return(Ok(resultStfCorp));
     }
     catch (Exception ex)
     {
         return(BadRequest());
     }
 }