public ActionResult Edit(WeatherViewModel viewModel) { var request = viewModel.MapTo<SaveWeatherRequest>(); _weatherService.SaveWeather(request); return RedirectToAction("Index"); }
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); } }