public ActionResult DeleteMovieTheory(long id) { ActionResult response; //Only for admins. if (Session["Role"] != null) { if ((int)Session["Role"] == 3 && id > 0) { try { //Map the theory in order to delete from the database and the presentation layer. MovieTheoryDO movieTheory = movieTheoryDataAccess.ViewMovieTheory(id); MovieTheoryPO deletedMovieTheory = mapper.MapDoToPo(movieTheory); movieTheoryDataAccess.DeleteMovieTheory(deletedMovieTheory.MovieTheoryID); response = RedirectToAction("Index", "Home"); } 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); }
//Details that everyone to see. public ActionResult DetailsForAllTheories(long id) { ActionResult response; if (id > 0) { try { //Shows specific movie theory details. MovieTheoryDO movieTheoryDO = movieTheoryDataAccess.ViewMovieTheory(id); MovieTheoryPO movieTheoryPO = mapper.MapDoToPo(movieTheoryDO); response = View(movieTheoryPO); } catch (Exception ex) { logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); response = RedirectToAction("Index", "Home"); } } else { response = RedirectToAction("Index", "Home"); } return(response); }
public ActionResult AddMovieTheory(MovieTheoryPO form) { ActionResult response; //Anyone with an account can add a movie theory. if (Session["Role"] != null) { if (ModelState.IsValid) { try { //Keeping the dropdown list, just in case. ViewBag.StatusDropDown = new List <SelectListItem>(); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Tinfoilly", Value = "Tinfoilly" }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Perchance", Value = "Perchance" }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Believable", Value = "Believable" }); MovieTheoryDO newMovieTheory = mapper.MapPoToDo(form); movieTheoryDataAccess.AddMovieTheory(newMovieTheory); response = RedirectToAction("MovieTheoryIndex", "MovieTheory", new { id = form.MovieId }); } catch (Exception ex) { logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); response = RedirectToAction("Index", "Home"); } } else { //Keeping the dropdown list, just in case. ViewBag.StatusDropDown = new List <SelectListItem>(); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Tinfoilly", Value = "Tinfoilly" }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Perchance", Value = "Perchance" }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Believable", Value = "Believable" }); response = View(form); } } else { response = RedirectToAction("Register", "Account"); } return(response); }
public ActionResult UpdateMovieTheory(MovieTheoryPO form) { ActionResult response; //Mods and Admins can update movie theories. if (Session["Role"] != null) { if ((int)Session["Role"] != 1) { //Making sure there are no null in required fields. if (ModelState.IsValid) { try { MovieTheoryDO movieTheoryDO = mapper.MapPoToDo(form); movieTheoryDataAccess.UpdateMovieTheory(movieTheoryDO); //Keeping the dropdown list in case something goes wrong. ViewBag.StatusDropDown = new List <SelectListItem>(); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Tinfoilly", Value = "Tinfoilly" }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Perchance", Value = "Perchance" }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Believable", Value = "Believable" }); //Id of movie needed to make sure the correct theory was updated on the correct movie. response = RedirectToAction("MovieTheoryIndex", "MovieTheory", new { id = form.MovieId }); } catch (Exception ex) { logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); response = RedirectToAction("Index", "Home"); } } else { response = View(form); } } else { response = RedirectToAction("Index", "Home"); } } else { response = RedirectToAction("Register", "Account"); } return(response); }
public MovieTheoryPO MapDoToPo(MovieTheoryDO from) { MovieTheoryPO to = new MovieTheoryPO(); to.MovieTheoryID = from.MovieTheoryID; to.TitleOfTheory = from.TitleOfTheory; to.Theory = from.Theory; to.Status = from.Status; to.MovieId = from.MovieId; return(to); }
public ActionResult UpdateMovieTheory(long id) { ActionResult response; if (Session["Role"] != null) { //Admins and Mods can update theories. if ((int)Session["Role"] != 1 && id > 0) { try { MovieTheoryDO movieTheoryDO = movieTheoryDataAccess.ViewMovieTheory(id); MovieTheoryPO movieTheoryPO = mapper.MapDoToPo(movieTheoryDO); //ViewBag drop down list for status. ViewBag.StatusDropDown = new List <SelectListItem>(); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Tinfoilly", Value = "Tinfoilly" }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Perchance", Value = "Perchance" }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Believable", Value = "Believable" }); response = View(movieTheoryPO); } 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 AddMovieTheory(long movieId) { ActionResult response; //Anyone with an account can add a movie theory. if (Session["Role"] != null) { try { //So the movie id is properly taken for the movie theory to be directly connected to it. MovieTheoryPO po = new MovieTheoryPO(); po.MovieId = movieId; //Same dropdown list for status. ViewBag.StatusDropDown = new List <SelectListItem>(); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Tinfoilly", Value = po.Status }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Perchance", Value = po.Status }); ViewBag.StatusDropDown.Add(new SelectListItem { Text = "Believable", Value = po.Status }); response = View(po); } catch (Exception ex) { logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); response = RedirectToAction("Index", "Home"); } } else { response = RedirectToAction("Register", "Account"); } return(response); }