public ActionResult DeleteConfirmed(int id)
        {
            tourCategory tourCategory = db.tourCategories.Find(id);

            db.tourCategories.Remove(tourCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "CategoryName,CategoryDescription,CategoryPhotoLink")] tourCategory tourCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tourCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tourCategory));
 }
        public ActionResult Create([Bind(Include = "CategoryId,CategoryName,CategoryDescription,CategoryPhotoLink")] tourCategory tourCategory)
        {
            if (ModelState.IsValid)
            {
                db.tourCategories.Add(tourCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tourCategory));
        }
Ejemplo n.º 4
0
        private static TourCategoryModel ConvetDbTourCategoryToTourCategoryModel(tourCategory dbTourCategory)
        {
            var tourCategory = new TourCategoryModel
            {
                CategoryId          = dbTourCategory.CategoryId,
                CategoryName        = dbTourCategory.CategoryName,
                CategoryDescription = dbTourCategory.CategoryDescription,
                CategoryPhotoLink   = dbTourCategory.CategoryPhotoLink
            };

            return(tourCategory);
        }
        // GET: TourCategories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tourCategory tourCategory = db.tourCategories.Find(id);

            if (tourCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(tourCategory));
        }