public IActionResult AddWeather(AddWeatherViewModel model) { AddWeatherViewModel Model = model; if (ModelState.IsValid) { Model.User = dbContext.GetUserFromIdentity(userManager.GetUserId(HttpContext.User)); dbContext.AddWeatherToUser(model); TempData["Success"] = "Din Väderobservation har registrerats"; return(RedirectToAction("UserHome")); } TempData["errorMessage"] = "Något gick fel, använde du kartan?"; return(RedirectToAction("AddAnimal")); }
public IActionResult AddWeather() { AddWeatherViewModel model = new AddWeatherViewModel(); model.Weather = new Weather(); model.WeatherTypes = Helper.getWeatherTypes(); var t = TempData["errorMessage"]; if (t != null) { ViewData["errorMessage"] = t; } Helper.setCurrentTimeWeather(model.Weather); return(View(model)); }
public void AddWeatherToUser(AddWeatherViewModel model) { context.Weathers.Add(new Weather() { Carbon = model.Weather.Carbon, Datetime = model.Weather.Datetime, Humidity = model.Weather.Humidity, Latitude = model.Weather.Latitude, Longitude = model.Weather.Longitude, PH = model.Weather.PH, Temperature = model.Weather.Temperature, Type = model.Weather.Type, User = model.User, UserId = model.Weather.UserId }); context.SaveChanges(); }
public void AddWeatherToUser(AddWeatherViewModel model) { throw new NotImplementedException(); }