public void DeleteL(Location l)
        {
            LocationDB db = new LocationDB();

            db.Delete(l);
            db.SaveChanges();
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "lname")] Location location)
        {
            if (ModelState.IsValid)
            {
                if (location.lname.Equals("Leamington"))
                {
                    db.Locations.Add(location);
                    db.SaveChanges();
                    return(RedirectToAction("../Home/Map1"));
                }
                if (location.lname.Equals("Elizabeth"))
                {
                    db.Locations.Add(location);
                    db.SaveChanges();
                    return(RedirectToAction("../Home/Map2"));
                }
                db.Locations.Add(location);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.lname = new SelectList(db.Choices, "cname", "cname", location.lname);
            return(View(location));
        }
        public int Create_Location(Location loc)
        {
            LocationDB db = new LocationDB();

            db.Insert(loc);
            int x = db.SaveChanges();

            if (x > 0)
            {
                return(loc.ID);
            }
            else
            {
                return(-1);
            }
        }