Beispiel #1
0
 public ActionResult EditMovie(vidlyDbContext.Entities.Movie movie)
 {
     if (GetSessionId() != 0)
     {
         AddOrUpdateMovie(movie);
         return(View(movie));
     }
     else
     {
         return(RedirectToAction(logInUrl));
     }
 }
Beispiel #2
0
        public bool AddOrUpdateMovie(vidlyDbContext.Entities.Movie movie)
        {
            var flag = false;

            try
            {
                if (movie.Id == 0)
                {
                    movie.BorrowCount = 0;
                }
                context.Movies.AddOrUpdate(m => m.Id, movie);
                context.SaveChanges();
                flag = true;
            }
            catch (Exception exception)
            {
                flag = false;
            }
            return(flag);
        }
Beispiel #3
0
        public ActionResult DeleteMovie(vidlyDbContext.Entities.Movie movie)
        {
            if (GetSessionId() != 0)
            {
                var movieFromDb = context.Movies.FirstOrDefault(x => x.Id == movie.Id);

                if (movieFromDb != null)
                {
                    context.Movies.Remove(movieFromDb);
                    context.SaveChanges();
                    return(RedirectToAction("BrowseMovies"));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction(logInUrl));
            }
        }