Example #1
0
        private static List <Movies> AddToDatabase(CinemaDBContext context, List <Movies> listOfMovies)
        {
            foreach (var s in listOfMovies)
            {
                context.Movie.Add(s);
            }
            context.SaveChanges();

            return(listOfMovies);
        }
Example #2
0
        public static List <Movies> Initialize(CinemaDBContext context)
        {
            if (!(context.Movie.Count() >= MaxAmmountOfMovies))
            {
                listOfMovies = CreateMovieList();
                listOfMovies = AddAmountsOfSeats(listOfMovies);
                listOfMovies = AddMovieDuration(listOfMovies);
                listOfMovies = AddQueueTimes(listOfMovies);

                if (!AddToDatabase(context, listOfMovies).Count().Equals(MaxAmmountOfMovies))
                {
                    Initialize(context);
                }
                else//database already have content just return
                {
                    return(listOfMovies);
                }
            }//database already have content just return
            return(listOfMovies);
        }