Exemplo n.º 1
0
        public ActionResult Edit(Location location)
        {
            if (ModelState.IsValid)
            {
                // compute Woeid & GMT offset
                location.Woeid = GetDefaultWoeid(location.Latitude, location.Longitude);
                if (location.TimeZone == null)
                    location.TimeZone = TimeZoneInfo.Local.Id; // GetDefaultTimeZone(location.Latitude, location.Longitude);

                db.Entry(location).State = EntityState.Modified;
                db.Entry(location).Property(l => l.LevelId).IsModified = false;
                db.Entry(location).Property(l => l.AreaId).IsModified = false;
                db.SaveChanges();

                return this.RestoreReferrer() ?? RedirectToAction("Index");
            }
            //FillLevelsSelectList(location.LevelId);
            FillTemperatureUnitSelectList(location.TemperatureUnit);
            //FillAreaSelectList(location.LocationId, location.AreaId);
            FillCulturesSelectList(location.Culture);
            this.FillSystemTimeZoneSelectList(location.TimeZone);

            return View(location);
        }
Exemplo n.º 2
0
        public ActionResult Create(Location location)
        {
            if (ModelState.IsValid)
            {
                // compute Woeid & GMT offset
                location.Woeid = GetDefaultWoeid(location.Latitude, location.Longitude);
                if (location.TimeZone == null)
                    location.TimeZone = TimeZoneInfo.Local.Id; // GetDefaultTimeZone(location.Latitude, location.Longitude);
                
                db.Locations.Add(location);
                db.SaveChanges();

                return this.RestoreReferrer() ?? RedirectToAction("Index");
            }

            FillLevelsSelectList(location.LevelId);
            FillTemperatureUnitSelectList(location.TemperatureUnit);
            FillAreaSelectList(location.LocationId, location.AreaId);
            FillCulturesSelectList(location.Culture);
            this.FillSystemTimeZoneSelectList(location.TimeZone);

            return View(location);
        }