public static MovieDetailDO GetMovieWithDetails(int id, int currentUserID) { MovieDetailDO movieDetail = new MovieDetailDO( ); //movie itself MOV_M_Movie movie = GetAll( ).Single(m => m.ID == id); movieDetail.Movie = Mapper.Map <MOV_M_Movie, MovieDO>(movie); //names movieDetail.Names = MovieNameBL.GetAllDOByMovieID(id); //archives movieDetail.Archives = MovieUserArchiveBL.GetAllDOByMovieIDAndUserID(id, currentUserID); //languages movieDetail.Languages = MovieLanguageBL.GetAllDOByMovieID(id); //types movieDetail.Types = MovieTypeBL.GetAllDOByMovieID(id); //directors movieDetail.Directors = MovieDirectorBL.GetAllDOByMovieID(id); //writers movieDetail.Writers = MovieWriterBL.GetAllDOByMovieID(id); //actors movieDetail.Actors = MovieActorBL.GetAllDOByMovieID(id); //userRatings movieDetail.UserRatings = MovieUserRatingBL.GetAllDOByMovieID(id); //average user rating movieDetail.AverageUserRating = MovieUserRatingBL.GetAverageUserRatingForMovie(id); //current user's rating movieDetail.CurrentUserRating = MovieUserRatingBL.GetUsersUserRatingForMovie(id, currentUserID); //lists movieDetail.UserListsIncludingThisMovie = UserListBL.GetAllViewForUserThatIncludeCurrentMovie(id, currentUserID); var listIdsThatContainThisMovie = movieDetail.UserListsIncludingThisMovie.Select(q => q.ListID).ToList(); movieDetail.UserLists = UserListBL.GetAllForUser(currentUserID); movieDetail.UserLists.RemoveAll(q => listIdsThatContainThisMovie.Contains(q.ID)); return(movieDetail); }
public static int Save(MovieDO movieDO, int userID) { Repository <MOV_M_Movie> rep = new Repository <MOV_M_Movie>(MArchiveDataContextProvider.Instance); MOV_M_Movie movieToAdd = null; if (movieDO.ID == 0) { movieToAdd = new MOV_M_Movie( ); ObjectMapper.MapObjects(movieDO, movieToAdd, AuditInfo.Fields); rep.InsertOnSubmit(movieToAdd); } else { movieToAdd = rep.GetAll( ).Single(x => x.ID == movieDO.ID); ObjectMapper.MapObjects(movieDO, movieToAdd, AuditInfo.Fields); } rep.DCP.CommitChanges(userID); InvalidateCache(CacheAreaKey); ObjectMapper.MapObjects(movieToAdd, movieDO); return(movieDO.ID); }