Пример #1
0
        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"));
        }
Пример #2
0
        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));
        }
Пример #3
0
 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();
 }
Пример #4
0
 public void AddWeatherToUser(AddWeatherViewModel model)
 {
     throw new NotImplementedException();
 }