//Details for movie details. public ActionResult MovieDetails(long id) { ActionResult response; //Anyone with an account can see movie details. if (Session["Role"] != null) { if (id > 0) { try { //Map for one single movie for details. MovieDO movieDO = movieDataAccess.ViewMovie(id); MoviePO moviePO = mapper.MapDoToPo(movieDO); response = View(moviePO); } 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); }
public ActionResult AddMovie(MoviePO form) { ActionResult response; //Anyone with an account can add a movie. if (Session["Role"] != null) { if (ModelState.IsValid) { try { MovieDO newMovie = mapper.MapPoToDo(form); movieDataAccess.AddMovie(newMovie); response = RedirectToAction("Index", "Movie"); } catch (Exception ex) { logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); response = RedirectToAction("Index", "Movie"); } } else { response = View(form); } } else { response = RedirectToAction("Register", "Account"); } return(response); }
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); }
public ActionResult UpdateMovie(long id) { ActionResult response; //Mods and Admins can update movies. if (Session["Role"] != null) { if ((int)Session["Role"] != 1 && id > 0) { try { MovieDO movieDO = movieDataAccess.ViewMovie(id); MoviePO moviePO = mapper.MapDoToPo(movieDO); response = View(moviePO); } 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); }
public ActionResult AddMovie(MoviePO form) { //Starting response is null ActionResult response = null; if (ModelState.IsValid) { try { //Using the addmovie method, we pass in the object form to be filled out _movieDAO.AddNewMovie(Mapping.Mapper.MoviePOtoDO(form)); //After it's filled out, it goes to viewing all movies response = RedirectToAction("ViewAllMovies", "Movie"); } catch (Exception exception) { //If there's an error, it's logged _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace); //Making sure there's a fallback location in case something goes bad response = RedirectToAction("ViewAllMovies", "Movie"); } finally { } } else { //If the modelstate isn't good, it goes back to the form to be filled response = View(form); } //Show whichever response happened return(response); }
public ActionResult UpdateMovie(int Id) { //Setting response to null ActionResult response = null; try { //Getting specific movie, by passing in the ID MovieDO movieDO = _movieDAO.ViewMovieByMovieId(Id); //MApping the movieDO to PO MoviePO moviePO = Mapping.Mapper.MovieDOtoPO(movieDO); //Setting response to the view to see the called upon movie response = View(moviePO); } catch (Exception exception) { //Logs if there's an issue _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace); //Setting response to see the movie details regardless response = RedirectToAction("MovieDetails", "Movie"); } finally { } //Show whichever response happened return(response); }
public MoviePO MapDoToPo(MovieDO from) { MoviePO to = new MoviePO(); to.MovieId = from.MovieId; to.Title = from.Title; to.Director = from.Director; to.OpeningWeekend = from.OpeningWeekend; to.YearReleased = from.YearReleased; return(to); }
public static MovieDO MoviePOtoDO(MoviePO from) { MovieDO to = new MovieDO(); to.MovieID = from.MovieID; to.Title = from.Title; to.Rating = from.Rating; to.Runtime = from.Runtime; to.Director = from.Director; to.Synopsis = from.Synopsis; return(to); }
//Index of movie theories connected to movies. public ActionResult MovieTheoryIndex(long id) { ActionResult response; //Anyone with an account can see the theories specifically connected to movies. if (Session["Role"] != null) { //Check id if (id > 0) { try { //Accessing the movie theories sharing the same movie id. List <MovieTheoryDO> allMovieTheories = movieTheoryDataAccess.ViewAllMovieTheories(id); List <MovieTheoryPO> mappedMovieTheories = new List <MovieTheoryPO>(); foreach (MovieTheoryDO dataObject in allMovieTheories) { mappedMovieTheories.Add(mapper.MapDoToPo(dataObject)); } //Getting Movie ID. MoviePO moviePO = new MoviePO(); moviePO.MovieTheories = mappedMovieTheories; moviePO.MovieId = id; response = View(moviePO); } catch (Exception ex) { logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); response = RedirectToAction("Index", "Home"); } } else { response = RedirectToAction("Index", "Home"); } } else { response = RedirectToAction("Register", "Account"); } return(response); }
public ActionResult UpdateMovie(MoviePO form) { ActionResult response; //Admins and Mods can update movies. if (Session["Role"] != null) { if ((int)Session["Role"] != 1) { if (ModelState.IsValid) { try { MovieDO movieDO = mapper.MapPoToDo(form); movieDataAccess.UpdateMovie(movieDO); response = RedirectToAction("Index", "Movie"); } catch (Exception ex) { logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); response = RedirectToAction("Index", "Movie"); } } else { response = View(form); } } else { response = RedirectToAction("Index", "Movie"); } } else { response = RedirectToAction("Register", "Account"); } return(response); }
public ActionResult UpdateMovie(MoviePO form) { //Setting response to null ActionResult response = null; if (ModelState.IsValid) { try { //Passing in the form to be updated to the DO MovieDO movieDO = Mapping.Mapper.MoviePOtoDO(form); //Passing in the movie to be updated via the update movie method _movieDAO.UpdateMovieById(movieDO); //Setting response to view the updated movie response = RedirectToAction("MovieDetails", "Movie", new { Id = form.MovieID }); } catch (Exception exception) { //Logs if there's an exception _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace); //Setting response to view all movies if there's a problem response = RedirectToAction("ViewAllMovies", "Movie"); } finally { } } else { //If modelstate is a no go, take them back to the form to try again response = View(form); } //Show whichever response happened return(response); }