public ActionResult AddMovieOnList(int movieid) { //Finds ProfileId for the logged on user var user = System.Threading.Thread.CurrentPrincipal; var userName = user.Identity.Name; var profile = facade.GetProfileGateWayService().GetByUserName(userName); // Checks if movie is already in users movie journal var moviesonlist = facade.GetMovieOnListRepository().GetByProfileId(profile.Id); Boolean movieExists = false; if(moviesonlist!=null) foreach(var item in moviesonlist) { if (item.MovieId == movieid) { movieExists = true; break; } } if (!movieExists) { var addmovie = new MovieOnList() { MovieId = movieid, Rating = 0,Review="", ProfileId=profile.Id, Watched=false}; facade.GetMovieOnListRepository().Add(addmovie); } return RedirectToAction("Index"); }
public void Change_Watched_To_Opposite_test() { var movfalsetotrue = new MovieOnList() { Id = 1, MovieId = 5, Watched=false }; var movtruetofalse = new MovieOnList() { Id = 2, MovieId = 10, Watched = true }; movbll.ChangeWatched(movfalsetotrue); movbll.ChangeWatched(movtruetofalse); Assert.AreEqual(movfalsetotrue.Watched, true); Assert.AreEqual(movtruetofalse.Watched, false); }
public void Change_Review_test() { string reviewtoedit = "This review should be edited"; string edittothis = "This is the new review"; var mov = new MovieOnList() { Id = 1, MovieId = 5, Review = reviewtoedit }; movbll.ChangeReview(mov,edittothis); Assert.AreEqual(mov.Review, edittothis); }
public void Change_Rating_Test() { int ratingtoedit = 4; int edittothis = 9; var mov = new MovieOnList() { Id = 1, MovieId = 5, Rating = ratingtoedit}; movbll.ChangeRating(mov, edittothis); Assert.AreEqual(mov.Rating, edittothis); }
public MovieOnList ChangeWatched(MovieOnList mov) { mov.Watched = !mov.Watched; return mov; }
public MovieOnList ChangeReview(MovieOnList mov, string newreview) { mov.Review = newreview; return mov; }
public MovieOnList ChangeRating(MovieOnList mov, int newrating) { mov.Rating = newrating; return mov; }