public ActionResult AddActor(ActorPO form) { ActionResult response = null; if (ModelState.IsValid) { try { _actorDAO.AddNewActor(Mapping.Mapper.ActorPOtoDO(form)); response = RedirectToAction("ViewAllActors", "Actor"); } catch (Exception exception) { _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace); if (exception.Data.Contains("Message")) { ModelState.AddModelError("FirstName", exception.Data["Message"].ToString()); } response = View(form); } finally { } } else { response = View(form); } return(response); }
public ActionResult UpdateActor(ActorPO form) { ActionResult response = null; if (ModelState.IsValid) { try { ActorDO actorDO = Mapping.Mapper.ActorPOtoDO(form); _actorDAO.UpdateActorById(actorDO); response = RedirectToAction("ActorDetails", "Actor", new { Id = form.ActorID }); } catch (Exception exception) { _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace); response = RedirectToAction("ViewAllActors", "Actor"); } finally { } } else { response = View(form); } return(response); }
public static ActorBO ActorPOtoBO(ActorPO from) { ActorBO to = new ActorBO(); to.ActorID = from.ActorID; to.FirstName = from.FirstName; to.LastName = from.LastName; to.BirthDate = from.BirthDate; to.Bio = from.Bio; to.Trivia = from.Trivia; to.Quotes = from.Quotes; return(to); }
public ActionResult AddActorToMovie(int movieID) { //Setting response to null ActionResult response = null; try { //Instantiating my movie/actor object MovieActorCombo movieWith = new MovieActorCombo(); //Setting an actor list, for my dropdown, that only shows those that are NOT in said movie...after passing in the movieID List <ActorDO> ActorList = _actorDAO.ActorsNotInMovie(movieID); foreach (ActorDO actorDO in ActorList) { //Mapping the actorDO to PO ActorPO actorPO = Mapping.Mapper.ActorDOtoPO(actorDO); //Dropdown SelectListItem ActorName = new SelectListItem { //Shows the actor's first and last name Text = actorPO.FullName, Value = actorPO.ActorID.ToString() }; //End result of the dropdown, showing all the necessary actors movieWith.ActorDropDown.Add(ActorName); } //Setting the movieID of a blank movie, to a movie including actors movieWith.MovieId = movieID; //Return view, to go to the actual view that ties an actor to a movie. response = View(movieWith); } catch (Exception exception) { //Logs if there's an issue _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("MovieDetails", "Movie"); } finally { } //Show whichever response happened return(response); }
public ActionResult DeleteActor(ActorPO form) { ActionResult response = null; try { _actorDAO.DeleteActorById(Mapping.Mapper.ActorPOtoDO(form).ActorID); response = RedirectToAction("ViewAllActors", "Actor"); } catch (Exception exception) { _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace); response = RedirectToAction("ViewAllActors", "Actor"); } finally { } return(response); }
public ActionResult UpdateActor(int Id) { ActionResult response = null; try { ActorDO actorDO = _actorDAO.ViewActorByActorId(Id); ActorPO actorPO = Mapping.Mapper.ActorDOtoPO(actorDO); response = View(actorPO); } catch (Exception exception) { _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace); response = RedirectToAction("ActorDetails", "Actor"); } finally { } return(response); }