public ActionResult DeleteConfirmed(int id)
        {
            MapDefault mapDefault = db.MapDefaults.Find(id);

            db.MapDefaults.Remove(mapDefault);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Width,Height,CenterOnLat,CenterOnLong,ZoomLevel,DisplayZoomControl,DisplayMapTypeControl,DisplayScaleControl,DisplayStreetViewControl,DisplayPanControl")] MapDefault mapDefault)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mapDefault).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "Settings"));
     }
     return(View(mapDefault));
 }
        public ActionResult Create([Bind(Include = "ID,Width,Height,CenterOnLat,CenterOnLong,ZoomLevel,DisplayZoomControl,DisplayMapTypeControl,DisplayScaleControl,DisplayStreetViewControl,DisplayPanControl")] MapDefault mapDefault)
        {
            if (ModelState.IsValid)
            {
                db.MapDefaults.Add(mapDefault);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mapDefault));
        }
        // GET: /MapDefaults/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MapDefault mapDefault = db.MapDefaults.Find(id);

            if (mapDefault == null)
            {
                return(HttpNotFound());
            }
            return(View(mapDefault));
        }
Esempio n. 5
0
        // GET: /Maps/
        public ActionResult Index(string searchString)
        {
            // Send the default map values
            MapDefault mapDefaults = db.MapDefaults.Find(1);

            ViewBag.DefaultWidth                    = mapDefaults.Width;
            ViewBag.DefaultHeight                   = mapDefaults.Height;
            ViewBag.DefaultCenterOnLat              = mapDefaults.CenterOnLat;
            ViewBag.DefaultCenterOnLong             = mapDefaults.CenterOnLong;
            ViewBag.DefaultZoomLevel                = mapDefaults.ZoomLevel;
            ViewBag.DefaultDisplayZoomControl       = mapDefaults.DisplayZoomControl.ToString();
            ViewBag.DefaultDisplayMapTypeControl    = mapDefaults.DisplayMapTypeControl.ToString();
            ViewBag.DefaultDisplayScaleControl      = mapDefaults.DisplayScaleControl.ToString();
            ViewBag.DefaultDisplayStreetViewControl = mapDefaults.DisplayStreetViewControl.ToString();
            ViewBag.DefaultDisplayPanControl        = mapDefaults.DisplayPanControl.ToString();

            // Create a list of Maps to filter against
            var maps = from a in db.Maps
                       select a;

            // Check for a previous search for this user
            UserSearch userSearch = db.UserSearches.SingleOrDefault(s => s.Username == User.Identity.Name);

            // Save the current search in the database
            // If an existing search record exists, then update it with the new search text
            if (!String.IsNullOrEmpty(searchString) && userSearch != null)
            {
                userSearch.MapsSearchString = searchString;
                db.Entry(userSearch).State  = EntityState.Modified;
                db.SaveChanges();
            }

            // If the user has no existing searches, then add a new record with the search text
            if (!String.IsNullOrEmpty(searchString) && userSearch == null)
            {
                var newUserSearch = new Models.UserSearch();
                newUserSearch.Username         = User.Identity.Name;
                newUserSearch.MapsSearchString = searchString;
                db.UserSearches.Add(newUserSearch);
                db.SaveChanges();
            }


            // If this is a fresh page load, get the saved search if there is one
            if (userSearch != null && !String.IsNullOrEmpty(userSearch.MapsSearchString))
            {
                searchString             = userSearch.MapsSearchString;
                ViewBag.MapsSearchString = searchString;
            }


            // Set the search results to nothing by default
            if (String.IsNullOrEmpty(searchString))
            {
                maps = maps.Where(s => s.Title.Contains("fkwlenbisengoapengies"));
            }


            // Filter by text, if there is any
            if (!String.IsNullOrEmpty(searchString))
            {
                maps = maps.Where(s => s.Title.Contains(searchString) || s.Description.Contains(searchString) || s.Tags.Contains(searchString));
            }


            // If the user searches for *, show all records
            if (searchString == "*")
            {
                maps = from a in db.Maps
                       select a;
            }


            // Return the filtered list in alphabetical order
            return(View(maps.OrderBy(s => s.Title)));
        }