Ejemplo n.º 1
0
        protected virtual void PopulateProjects(int count)
        {
            Shuffle(ProjectNames);

            var names = ProjectNames.Take(count).Distinct();

            //var conflicts = _context.Set<Project>().Join(names, p => p.Name, n => n, (p, n) => n).ToArray();

            //names = names.Except(conflicts);

            var proj = new Project[names.Count()];

            int i = 0;

            foreach (var x in names)
            {
                var dates = GetDates();
                proj[i] = new Project
                {
                    Name        = x,
                    Description = Faker.Lorem.Paragraph(),
                    StartDate   = dates.Item1,
                    EndDate     = dates.Item2,
                    Status      = GetStatus(dates)
                };
                i++;
            }

            _context.AddRange(proj);

            this._context.SaveChanges();

            Console.WriteLine("Added {0} randomly generated projects", proj.Length);
        }