예제 #1
0
 public ActionResult Edit(WeatherViewModel viewModel)
 {
     var request = viewModel.MapTo<SaveWeatherRequest>();
     _weatherService.SaveWeather(request);
     return RedirectToAction("Index");
 }
예제 #2
0
 public ActionResult UpdateWeather(WeatherViewModel viewModel)
 {
     var weather = _weatherService.GetWeather(new GetWeatherRequest
     {
         Date = viewModel.Date,
         ByDate = true
     });
     if (weather.Id == 0)
     {
         var request = viewModel.MapTo<SaveWeatherRequest>();
         var resp = _weatherService.SaveWeather(request);
         return Json(resp);
     }
     else
     {
         var request = viewModel.MapTo<SaveWeatherRequest>();
         request.Id = weather.Id;
         request.Temperature = weather.Temperature;
         request.ValueId = viewModel.ValueId;
         var resp = _weatherService.SaveWeather(request);
         return Json(resp);
     }
 }