public ActionResult Create(TouristAttraction touristattraction)
        {
            if (ModelState.IsValid)
            {
                db.TouristAttractions.Add(touristattraction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(touristattraction));
        }
        public ActionResult Create(Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TouristAttractionId = new SelectList(db.TouristAttractions, "TouristAttractionId", "Name", review.TouristAttractionId);
            return(View(review));
        }
示例#3
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void attractionsForm_DeleteItem([RouteData] int?id)
        {
            TouristAttraction touristattraction = db.TouristAttractions.Find(id);

            db.TouristAttractions.Remove(touristattraction);
            db.SaveChanges();
        }
示例#4
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void attractionsForm_DeleteItem(
            [FriendlyUrlSegments] int?id)
        {
            TouristAttraction touristattraction = db.TouristAttractions.Find(id);

            db.TouristAttractions.Remove(touristattraction);
            db.SaveChanges();
        }
        public void attractionsForm_InsertItem()
        {
            var item = new MvcApplication2.Models.TouristAttraction();

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                // Save changes here
                db.TouristAttractions.Add(item);
                db.SaveChanges();
            }
        }
 // The id parameter name should match the DataKeyNames value set on the control
 public void attractionsForm_UpdateItem([RouteData] int?id)
 {
     MvcApplication2.Models.TouristAttraction item = db.TouristAttractions.Find(id);
     // Load the item here, e.g. item = MyDataLayer.Find(id);
     if (item == null)
     {
         // The item wasn't found
         ModelState.AddModelError("", String.Format("Item with id {0} was not found", id));
         return;
     }
     TryUpdateModel(item);
     if (ModelState.IsValid)
     {
         // Save changes here, e.g. MyDataLayer.SaveChanges();
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void AddAttraction(Attractions attraction)
 {
     attractionContext.Attractions.Add(attraction);
     attractionContext.SaveChanges();
 }