Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Map_Boards map_Boards = db.Map_Boards.Find(id);

            db.Map_Boards.Remove(map_Boards);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
        // POST: /Map_Boards/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        public ActionResult AddToMap([Bind(Include = "ID,MapID,BoardID")] Map_Boards map_Boards)
        {
            var redirectURL = "../Map_Boards?mapId=" + map_Boards.MapID;

            // Set a default pin
            map_Boards.PinTypeID = 1;

            db.Map_Boards.Add(map_Boards);
            db.SaveChanges();

            return(Redirect(redirectURL));
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "ID,MapID,BoardID")] Map_Boards map_Boards)
 {
     if (ModelState.IsValid)
     {
         db.Entry(map_Boards).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BoardID = new SelectList(db.Boards, "ID", "BoardNumber", map_Boards.BoardID);
     ViewBag.MapID   = new SelectList(db.Maps, "ID", "Title", map_Boards.MapID);
     return(View(map_Boards));
 }
Пример #4
0
        // GET: /Map_Boards/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Map_Boards map_Boards = db.Map_Boards.Find(id);

            if (map_Boards == null)
            {
                return(HttpNotFound());
            }
            return(View(map_Boards));
        }
Пример #5
0
        public ActionResult SelectPinType([Bind(Include = "ID,MapID,BoardID,PinTypeID")] Map_Boards map_Boards)
        {
            var redirectURL = "../../Maps/Edit/" + map_Boards.MapID + "#boards";

            if (ModelState.IsValid)
            {
                db.Entry(map_Boards).State = EntityState.Modified;
                db.SaveChanges();
                return(Redirect(redirectURL));
            }

            ViewBag.PinTypeID = new SelectList(db.PinTypes, "ID", "Title", map_Boards.PinTypeID);

            return(Redirect(redirectURL));
        }
Пример #6
0
        // GET: /Map_Boards/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Map_Boards map_Boards = db.Map_Boards.Find(id);

            if (map_Boards == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BoardID = new SelectList(db.Boards, "ID", "BoardNumber", map_Boards.BoardID);
            ViewBag.MapID   = new SelectList(db.Maps, "ID", "Title", map_Boards.MapID);
            return(View(map_Boards));
        }
Пример #7
0
        // GET: /Map_Boards/Edit/5
        public ActionResult SelectPinType(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Map_Boards map_Boards = db.Map_Boards.Find(id);

            if (map_Boards == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PinTypeID = new SelectList(db.PinTypes, "ID", "Title", map_Boards.PinTypeID);

            return(View(map_Boards));
        }
Пример #8
0
        // POST: /Map_Boards/Delete/5
        public ActionResult RemoveFromMap(int id, string redirectTo)
        {
            Map_Boards map_Boards = db.Map_Boards.Find(id);
            var        mapId      = map_Boards.MapID;

            db.Map_Boards.Remove(map_Boards);
            db.SaveChanges();

            if (redirectTo == "Map")
            {
                var redirectURL = "../../Maps/Edit/" + mapId + "#boards";
                return(Redirect(redirectURL));
            }

            else
            {
                var redirectURL = "../../Map_Boards?mapId=" + mapId;
                return(Redirect(redirectURL));
            }
        }
Пример #9
0
        public ActionResult Copy([Bind(Include = "ID,Title")] Map map)
        {
            var newMap = db.Maps.Find(map.ID);

            // Stamp the Map with CreatedBy and DateCreated
            newMap.Title       = map.Title;
            newMap.CreatedBy   = User.Identity.Name;
            newMap.DateCreated = DateTime.Now;

            // Add the map
            var thisID = db.Maps.Add(newMap);


            // Copy the styles from the source map to this new map
            var sourceMapStyles = from a in db.MapStyles
                                  where a.MapID == map.ID
                                  select a;

            foreach (var mapStyle in sourceMapStyles)
            {
                var thisMapStyle = new MapStyle();
                thisMapStyle.MapID         = thisID.ID;
                thisMapStyle.FeatureTypeID = mapStyle.FeatureTypeID;
                thisMapStyle.Hue           = mapStyle.Hue;
                thisMapStyle.Saturation    = mapStyle.Saturation;
                thisMapStyle.Lightness     = mapStyle.Lightness;
                thisMapStyle.Gamma         = mapStyle.Gamma;

                db.Entry(thisMapStyle).State = EntityState.Added;
            }



            // Copy the boards from the source map to this new map
            var sourceMapBoards = (from a in db.Map_Boards
                                   where a.MapID == map.ID
                                   select a);

            foreach (var mapBoard in sourceMapBoards)
            {
                var thisBoard = new Map_Boards();
                thisBoard.MapID     = thisID.ID;
                thisBoard.BoardID   = mapBoard.BoardID;
                thisBoard.PinTypeID = mapBoard.PinTypeID;

                db.Entry(thisBoard).State = EntityState.Added;
            }



            // Copy the pins from the source map to this new map
            var sourceMapPins = (from a in db.Pins
                                 where a.MapID == map.ID
                                 select a);

            foreach (var mapPin in sourceMapPins)
            {
                var thisPin = new Pin();
                thisPin.MapID     = thisID.ID;
                thisPin.Title     = mapPin.Title;
                thisPin.Latitude  = mapPin.Latitude;
                thisPin.Longitude = mapPin.Longitude;
                thisPin.PinTypeID = mapPin.PinTypeID;

                db.Entry(thisPin).State = EntityState.Added;
            }


            db.SaveChanges();
            return(RedirectToAction("Edit", thisID));
        }