Example #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string      movieID = txtMovieID.Text;
            ScheduleDAO scheDao = new ScheduleDAO();

            scheDao.AdminScheduleDelete(movieID);
            if (MovieDao.DeleteMovie(movieID))
            {
                List <MovieDTO> list = (List <MovieDTO>)Session["AdminMovieSearch"];
                foreach (MovieDTO item in list)
                {
                    if (item.MovieID.Equals(movieID))
                    {
                        list.Remove(item);
                    }
                }
                gvStaffList.DataSource = list;
                gvStaffList.DataBind();
                SetMessageTextAndColor("Successfully deleted", Color.Green);
                Clear();
            }
            else
            {
                SetMessageTextAndColor("Failed to delete", Color.Red);
            }
        }
        public ActionResult DeleteMovie(int id)
        {
            ActionResult response;

            //Only Admins can delete movies.
            if (Session["Role"] != null)
            {
                if ((int)Session["Role"] == 3 && id > 0)
                {
                    try
                    {
                        MovieDO movie        = movieDataAccess.ViewMovie(id);
                        MoviePO deletedMovie = mapper.MapDoToPo(movie);
                        movieDataAccess.DeleteMovie(deletedMovie.MovieId);

                        response = RedirectToAction("Index", "Movie");
                    }
                    catch (Exception ex)
                    {
                        logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex);
                        response = RedirectToAction("Index", "Movie");
                    }
                }
                else
                {
                    response = RedirectToAction("Index", "Movie");
                }
            }
            else
            {
                response = RedirectToAction("Register", "Account");
            }
            return(response);
        }
Example #3
0
 void DeleteMovie(string id)
 {
     if (MovieDAO.DeleteMovie(id))
     {
         MessageBox.Show("Xóa phim thành công");
     }
     else
     {
         MessageBox.Show("Xóa phim thất bại");
     }
 }
Example #4
0
        public void DeleteMovieTest()
        {
            Movie movie = new Movie();

            movie.Name     = "Harry Potter and the Philosopher's Stone";
            movie.Date     = new DateTime(2001, 11, 4);
            movie.Producer = "Chris Columbus";
            movie.Actors   = "Daniel Radcliffe, Rupert Grint, Emma Watson";
            movie.Genre    = "fantasy";
            movie.Duration = 152;
            MovieDAO movieDAO = new MovieDAO();

            movieDAO.AddMovie(movie);

            List <Movie> list = movieDAO.GetMoviesByName(movie.Name);

            movie = list[list.Count - 1];
            movieDAO.DeleteMovie(movie.Id);

            list = movieDAO.GetMoviesByName(movie.Name);

            Assert.IsFalse(list.Exists(l => l.Id == movie.Id));
        }