コード例 #1
0
        public static List <Rating> Ratings()
        {
            var randomDateTime = new RandomDateTime();
            var list           = new List <Rating>();

            string[] ratings       = File.ReadAllLines(@"C:\seed\myratings.txt", Encoding.Default);
            string[] myratingDates = File.ReadAllLines(@"C:\seed\movie_rate_date.txt");

            var id = 1;

            foreach (string rating in ratings)
            {
                list.Add(new Rating()
                {
                    Id        = id,
                    DateRated = ReturnProperDate(myratingDates[id - 1]),
                    UserId    = 1,
                    MovieId   = id,
                    Rate      = int.Parse(rating)
                });
                id++;
            }

            return(list);
        }
コード例 #2
0
        public static List <Director> Directors()
        {
            var directors = File.ReadAllLines(@"C:\seed\directors.txt", Encoding.Default);

            string[] myratingDates = File.ReadAllLines(@"C:\seed\movie_rate_date.txt");

            var rnd            = new Random();
            var randomDateTime = new RandomDateTime();

            var directorsList = new List <string>();

            foreach (var director in directors)
            {
                string found = directorsList.Find(t => t == director);

                if (found == null)
                {
                    if (director.Contains(","))
                    {
                        directorsList.Add(director.Split(',')[0]);
                    }
                    else
                    {
                        directorsList.Add(director);
                    }
                }
            }

            var firstLastNamesSeperated = new List <FirstLastName>();

            foreach (var actorFullName in directorsList.Distinct())
            {
                var splitted = actorFullName.Split(' ');
                switch (splitted.Count())
                {
                case 2:
                    firstLastNamesSeperated.Add(new FirstLastName()
                    {
                        First = splitted[0], Last = splitted[1]
                    });
                    break;

                case 3:
                    firstLastNamesSeperated.Add(new FirstLastName()
                    {
                        First = splitted[0], Last = splitted[1] + " " + splitted[2]
                    });
                    break;

                case 4:
                    firstLastNamesSeperated.Add(new FirstLastName()
                    {
                        First = splitted[0], Last = splitted[1] + " " + splitted[2] + " " + splitted[3]
                    });
                    break;
                }
            }

            var finalList = new List <Director>();
            int id        = 1;

            foreach (var dir in firstLastNamesSeperated)
            {
                finalList.Add(new Director()
                {
                    Id = id,
                    //Name = dir.First + " " + dir.Last,
                    FirstName = dir.First,
                    LastName  = dir.Last,
                    BirthDate = null,
                    DeathDate = null,
                    FullName  = dir.First + " " + dir.Last,
                    Biography = null,                                    // LoremText[(rnd.Next(0, LoremCount))],
                    CreatedAt = ReturnProperDate(myratingDates[id - 1]), // randomDateTime.Next(),
                    ImdbLink  = null,
                    CountryId = 1,
                    StateId   = 1,
                    CountyId  = 1,
                    Gender    = true
                });
                id++;
            }
            return(finalList);
        }
コード例 #3
0
        public static List <Actor> Actors()
        {
            var actors = new List <Actor>();

            string[] yearsListNoTextRaw = File.ReadAllLines(@"C:\seed\actors_years_notext.txt", Encoding.Default);
            string[] actorsConsts       = File.ReadAllLines(@"C:\seed\actors_nmconst.txt", Encoding.Default);
            string[] actors500          = File.ReadAllLines(@"C:\seed\actors.txt", Encoding.Default);

            var firstLastNameSeperated = new List <FirstLastName>();

            foreach (var actorFullName in actors500)
            {
                var splitted = actorFullName.Split(' ');
                switch (splitted.Count())
                {
                case 1:
                    break;

                case 2:
                    firstLastNameSeperated.Add(new FirstLastName()
                    {
                        First = splitted[0], Last = splitted[1]
                    });
                    break;

                case 3:
                    firstLastNameSeperated.Add(new FirstLastName()
                    {
                        First = splitted[0], Last = splitted[1] + " " + splitted[2]
                    });
                    break;

                case 4:
                    firstLastNameSeperated.Add(new FirstLastName()
                    {
                        First = splitted[0], Last = splitted[1] + " " + splitted[2] + " " + splitted[3]
                    });
                    break;
                }
            }

            var dateFinalList = new List <DateTime>();

            foreach (var year in yearsListNoTextRaw)
            {
                DateTime dateOut;
                DateTime.TryParse(year, out dateOut);
                var dateFinal = dateOut.ToShortDateString();

                dateFinalList.Add(dateOut);
            }

            var randomDateTime = new RandomDateTime();

            for (int i = 0; i < actors500.Count(); i++)
            {
                actors.Add(new Actor()
                {
                    FullName  = actors500[i],
                    BirthDate = dateFinalList[i],
                    DeathDate = null,
                    Biography = null,
                    CreatedAt = randomDateTime.Next(),
                    FirstName = firstLastNameSeperated[i].First,
                    LastName  = firstLastNameSeperated[i].Last,
                    ImdbLink  = actorsConsts[i],
                    Gender    = true,
                    CountryId = 1,
                    StateId   = 1,
                    CountyId  = 1
                });
            }

            return(actors.ToList());
        }