Esempio n. 1
0
        /// <summary>
        /// Initializes static members of the <see cref="MovieSetManager"/> class.
        /// </summary>
        static MovieSetManager()
        {
            database = new BindingList<MovieSetModel>();
            currentSet = new MovieSetModel();

            database.ListChanged += Database_ListChanged;
        }
Esempio n. 2
0
        /// <summary>
        /// The set all movies changed in set.
        /// </summary>
        /// <param name="set">The set to alter.</param>
        private static void SetAllMoviesChangedInSet(MovieSetModel set)
        {
            var movies = GetMoviesInSets(set);

            foreach (var movie in movies)
            {
                movie.ChangedText = true;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Sets the current set.
 /// </summary>
 /// <param name="movieSetModel">The movie set model.</param>
 public static void SetCurrentSet(MovieSetModel movieSetModel)
 {
     currentSet = movieSetModel;
     InvokeCurrentSetChanged(new EventArgs());
 }
Esempio n. 4
0
 /// <summary>
 /// Returns the movies in sets.
 /// </summary>
 /// <param name="movieSetModel">The movie set model.</param>
 /// <returns>Collection of movies in a set</returns>
 public static List<MovieModel> GetMoviesInSets(MovieSetModel movieSetModel)
 {
     return movieSetModel.Movies.Select(movieSetObect => MovieDBFactory.GetMovie(movieSetObect.MovieUniqueId)).Where(movie => movie != null).ToList();
 }
Esempio n. 5
0
 /// <summary>
 /// Add new set.
 /// </summary>
 /// <param name="response">The response.</param>
 public static void AddNewSet(string response)
 {
     var newSetModel = new MovieSetModel { SetName = response };
     CurrentDatabase.Add(newSetModel);
     SetCurrentSet(newSetModel);
 }
Esempio n. 6
0
        /// <summary>
        /// The add movie to set.
        /// </summary>
        /// <param name="movie">The movie.</param>
        /// <param name="setName">The set name.</param>
        /// <param name="order">The order.</param>
        public static void AddMovieToSet(MovieModel movie, string setName, int? order = null)
        {
            MovieSetModel check = (from m in database where m.SetName == setName select m).SingleOrDefault();

            var movieSetObjectModel = new MovieSetObjectModel { MovieUniqueId = movie.MovieUniqueId };

            if (order != null)
            {
                movieSetObjectModel.Order = (int)order;
            }

            if (check == null)
            {
                var movieSetModel = new MovieSetModel();

                movieSetModel.Movies.Add(movieSetObjectModel);
                movieSetModel.SetName = setName;

                database.Add(movieSetModel);
            }
            else
            {
                check.AddMovie(movie, order);
            }

            movie.ChangedText = true;

            SetAllMoviesChangedInCurrentSet();
        }