public ActionResult Save(WeatherViewModel input) { var weather = input.Weather.EntityId > 0 ? _repository.Find<Weather>(input.Weather.EntityId) : new Weather(); var newTask = mapToDomain(input, weather); var crudManager = _saveEntityService.ProcessSave(newTask); var notification = crudManager.Finish(); return Json(notification, JsonRequestBehavior.AllowGet); }
public ActionResult AddEdit(ViewModel input) { var weather = input.EntityId > 0 ? _repository.Find<Weather>(input.EntityId) : new Weather(); var model = new WeatherViewModel { Weather = weather, }; return PartialView("WeatherAddUpdate", model); }
public ActionResult Display(ViewModel input) { var weather = _repository.Find<Weather>(input.EntityId); var model = new WeatherViewModel { Weather = weather, AddEditUrl = UrlContext.GetUrlForAction<WeatherController>(x => x.AddEdit(null)) + "/" + weather.EntityId }; return PartialView("WeatherView", model); }
private Weather mapToDomain(WeatherViewModel input, Weather weather) { var weatherModel = input.Weather; weather.DewPoint = weatherModel.DewPoint; weather.EvaporationRate = weatherModel.EvaporationRate; weather.HighTemperature = weatherModel.HighTemperature; weather.Humidity = weatherModel.Humidity; weather.LowTemperature = weatherModel.LowTemperature; weather.RainPrecipitation = weatherModel.RainPrecipitation; weather.WindSpeed = weatherModel.WindSpeed; return weather; }