Beispiel #1
0
        /*
         * @param sort_by_year => LINQ sort by movie year
         */
        public static IEnumerable <Movie> GetMovies(bool sort_by_year)
        {
            List <Movie> list = new List <Movie>();

            using (var c = AdoDB.Provider.CreateConnection())
            {
                c.ConnectionString = AdoDB.CS;
                using (DbCommand cmd = c.CreateCommand())
                {
                    cmd.CommandText = AdoDB.MOVIES;
                    c.Open();
                    using (var r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            Movie    movie    = GetMovie(r);
                            Entry    entry    = GetEntry(r);
                            Category category = GetCategory(r);
                            entry.category = category;
                            int film_id = Convert.ToInt32(r["id"]);
                            foreach (Screening screening in GetScreenings(film_id))
                            {
                                entry.AddScreening(screening);
                            }
                            movie.entry = entry;
                            foreach (Director director in GetDirectors(film_id))
                            {
                                movie.AddDirector(director);
                            }
                            foreach (Country country in GetCountries(film_id))
                            {
                                movie.AddCountry(country);
                            }
                            list.Add(movie);
                        }
                    }
                }
            }
            if (!sort_by_year)
            {
                return(list);
            }
            else
            {
                return(from m in list orderby m.Year, m.Title select m);
            }
        }
Beispiel #2
0
        // ---------------------------------------------------------------------------

        /**
         * Returns a list with Screening objects, if you pass
         * a stringified date.
         * @param day stringified date "yyyy-MM-dd"
         * @return a List of Screening POJOs
         */
        public static List <Screening> GetScreenings(string day)
        {
            List <Screening> list = new List <Screening>();

            using (var c = AdoDB.Provider.CreateConnection())
            {
                c.ConnectionString = AdoDB.CS;
                using (DbCommand cmd = c.CreateCommand())
                {
                    cmd.CommandText = AdoDB.SCREENINGS;
                    cmd.Parameters.Add(cmd.CreateParameter());
                    cmd.Parameters[0].ParameterName = "@day";
                    cmd.Parameters[0].Value         = day;
                    c.Open();
                    using (var r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            Screening screening = GetScreening(r);
                            Movie     movie     = GetMovie(r);
                            foreach (var d in GetDirectors(Convert.ToInt32(r["id"])))
                            {
                                movie.AddDirector(d);
                            }
                            foreach (var cn in GetCountries(Convert.ToInt32(r["id"])))
                            {
                                movie.AddCountry(cn);
                            }
                            Entry    entry    = GetEntry(r);
                            Category category = GetCategory(r);
                            entry.category  = category;
                            entry.movie     = movie;
                            movie.entry     = entry;
                            screening.movie = movie;
                            list.Add(screening);
                        }
                    }
                }
            }
            return(list);
        }
Beispiel #3
0
        // ---------------------------------------------------------------------------

        /**
         * Returns a list with Screening objects
         * @return a List of Screening POJOs
         */
        public static List <Screening> GetPressPreviews()
        {
            List <Screening> list = new List <Screening>();

            using (var c = AdoDB.Provider.CreateConnection())
            {
                c.ConnectionString = AdoDB.CS;
                using (DbCommand cmd = c.CreateCommand())
                {
                    cmd.CommandText = AdoDB.PRESS;
                    c.Open();
                    using (var r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            Screening screening = GetScreening(r);
                            Movie     movie     = GetMovie(r);
                            int       film_id   = Convert.ToInt32(r["id"]);
                            foreach (Director d in GetDirectors(film_id))
                            {
                                movie.AddDirector(d);
                            }
                            foreach (Country country in GetCountries(film_id))
                            {
                                movie.AddCountry(country);
                            }
                            Entry    entry    = GetEntry(r);
                            Category category = GetCategory(r);
                            entry.category  = category;
                            entry.movie     = movie;
                            movie.entry     = entry;
                            screening.movie = movie;
                            list.Add(screening);
                        }
                    }
                }
            }
            return(list);
        }