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>();
                request.UserId         = UserProfile().UserId;
                request.ControllerName = "Der Input Form";
                request.ActionName     = "Input Weather";
                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;
                request.UserId         = UserProfile().UserId;
                request.ControllerName = "Der Input Form";
                request.ActionName     = "Update Weather";
                var resp = _weatherService.SaveWeather(request);
                return(Json(resp));
            }
        }
Esempio n. 2
0
        public ActionResult Edit(WeatherViewModel viewModel)
        {
            var request = viewModel.MapTo <SaveWeatherRequest>();

            _weatherService.SaveWeather(request);
            return(RedirectToAction("Index"));
        }