Exemplo n.º 1
0
        public static void PopulateDb(BmtDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.AddRange(Projects);
            context.AddRange(ProjectCategories);
            context.AddRange(QuestionTemplates);
            context.AddRange(Evaluations);
            context.AddRange(Participants);
            context.AddRange(Questions);
            context.AddRange(Answers);
            context.AddRange(Actions);
            context.AddRange(Notes);
            context.AddRange(ClosingRemarks);

            context.SaveChanges();

            var templates  = context.QuestionTemplates.Include(x => x.ProjectCategories);
            var categories = context.ProjectCategories;
            int qCounter   = 0;

            foreach (var template in templates)
            {
                qCounter++;
                foreach (var category in categories)
                {
                    template.ProjectCategories.Add(category);
                    if (qCounter % 2 == 1)
                    {
                        break;
                    }
                }
            }
            context.SaveChanges();
        }
Exemplo n.º 2
0
        public static void PopulateDb(BmtDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.AddRange(Projects);
            context.AddRange(QuestionTemplates);
            context.AddRange(Evaluations);
            context.AddRange(Participants);
            context.AddRange(Questions);
            context.AddRange(Answers);
            context.AddRange(Actions);
            context.AddRange(Notes);

            context.SaveChanges();
        }