public static MovieActorComboDO ComboPOtoDO(MovieActorCombo from) { MovieActorComboDO to = new MovieActorComboDO(); to.ActorId = from.ActorId; to.MovieId = from.MovieId; 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 AddActorToMovie(MovieActorCombo combo) { //Setting the response to null ActionResult response = null; if (ModelState.IsValid) { try { //Setting the movie/actor combo to DO from PO MovieActorComboDO comboDO = Mapping.Mapper.ComboPOtoDO(combo); //Passing in the DO combo to the add actor to movie method _movieDAO.AddActorToMovie(comboDO); } catch (Exception exception) { //Logs if there's an issue _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace); //Setting view, to go to the actual view that ties an actor to a movie. response = View(combo); } finally { //Setting response to view all the movies response = RedirectToAction("ViewAllMovies", "Movie"); } } else { //Setting response to view the movie you're currently on response = View(combo); } //Show whichever response happened return(response); }