예제 #1
0
 // GET: Video/Delete/5
 public ActionResult Delete(int id)
 {
     using (mvcEntities1 dbModel = new mvcEntities1())
     {
         return(View(dbModel.Movies.Where(x => x.Id == id).FirstOrDefault()));//this selets the movie to be deleted
     }
 }
예제 #2
0
 // GET: Video/Edit/5
 public ActionResult Edit(int id)
 {
     using (mvcEntities1 dbModel = new mvcEntities1())
     {
         return(View(dbModel.Movies.Where(x => x.Id == id).FirstOrDefault()));//this selects the id of the movie
     }
 }
예제 #3
0
 // GET: Video
 public ActionResult Index()
 {
     using (mvcEntities1 dbModel = new mvcEntities1())
     {
         return(View(dbModel.Movies.ToList()));//this list all the movies the are in the database
     }
 }
예제 #4
0
 public ActionResult Edit(int id, Movy movies)
 {
     try
     {
         using (mvcEntities1 dbModel = new mvcEntities1())
         {
             dbModel.Entry(movies).State = EntityState.Modified;//this edits the movie
             dbModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
예제 #5
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (mvcEntities1 dbModel = new mvcEntities1())
                {
                    Movy movies = dbModel.Movies.Where(x => x.Id == id).FirstOrDefault();//this delets the movie
                    dbModel.Movies.Remove(movies);
                    dbModel.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #6
0
        public ActionResult Create(Movy movie)
        {
            try
            {
                using (mvcEntities1 dbModel = new mvcEntities1())//this add the movie to the databse
                {
                    dbModel.Movies.Add(movie);
                    dbModel.SaveChanges();
                }

                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }