Ejemplo n.º 1
0
        public async Task Run(StepContext db)
        {
            // TODO setting default settings here but if none exist, user should enter them on creating a new challenge. Only create defaults for development
            if (!db.ChallengeSettings.Any())
            {
                var settings = new ChallengeSettings
                {
                    Name                        = "Step Challenge 2019",
                    StartDate                   = new DateTime(2019, 09, 16, 0, 0, 0),
                    EndDate                     = new DateTime(2019, 12, 02, 0, 0, 0),
                    DurationInWeeks             = 10,
                    ShowLeaderBoard             = false,
                    ShowLeaderBoardStepCounts   = false,
                    NumberOfParticipants        = 48,
                    NumberOfParticipantsInATeam = 6,
                };

                db.ChallengeSettings.Add(settings);
                db.SaveChanges();
            }
            if (!db.Team.Any())
            {
                var teams = new List <Team>
                {
                    new Team
                    {
                        TeamId       = 1,
                        TeamName     = "Team_1",
                        Participants = new[]
                        {
                            new Participant
                            {
                                ParticipantId   = 1,
                                ParticipantName = "Alice",
                                IsAdmin         = true,
                                IdentityUser    = await GetIdentityUser("alice"),
                                Steps           = GetSteps()
                            },
                            new Participant
                            {
                                ParticipantId   = 2,
                                ParticipantName = "Bob",
                                IdentityUser    = await GetIdentityUser("bob"),
                                Steps           = GetSteps()
                            }
                        }
                    },
                    new Team
                    {
                        TeamId       = 2,
                        TeamName     = "Team_2",
                        Participants = new[]
                        {
                            new Participant
                            {
                                ParticipantId   = 3,
                                ParticipantName = "Susan",
                                IdentityUser    = await GetIdentityUser("susan"),
                                Steps           = GetSteps()
                            },
                            new Participant
                            {
                                ParticipantId   = 4,
                                ParticipantName = "Helga",
                                IdentityUser    = await GetIdentityUser("helga"),
                                Steps           = GetSteps()
                            }
                        }
                    }
                };

                teams.AddRange(GetTeams());
                db.Team.AddRange(teams);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public async Task Run(StepContext db)
        {
            if (!db.Team.Any())
            {
                var teams = new List <Team>
                {
                    new Team
                    {
                        TeamId   = 1,
                        TeamName = "Team_1",

                        /*
                         * Participants = new[]
                         * {
                         *
                         *  new Participant
                         *  {
                         *      ParticipantId = 1,
                         *      ParticipantName = "Alice",
                         *      IsAdmin = true,
                         *      IdentityUser = await GetIdentityUser("alice"),
                         *      Steps = GetSteps()
                         *  },
                         *  new Participant
                         *  {
                         *      ParticipantId = 2,
                         *      ParticipantName = "Bob",
                         *      IdentityUser = await GetIdentityUser("bob"),
                         *      Steps = GetSteps()
                         *  }
                         * }
                         */
                    },
                    new Team
                    {
                        TeamId   = 2,
                        TeamName = "Team_2",

                        /*
                         * Participants = new[]
                         * {
                         *  new Participant
                         *  {
                         *      ParticipantId = 3,
                         *      ParticipantName = "Susan",
                         *      IdentityUser = await GetIdentityUser("susan"),
                         *      Steps = GetSteps()
                         *  },
                         *  new Participant
                         *  {
                         *      ParticipantId = 4,
                         *      ParticipantName = "Helga",
                         *      IdentityUser = await GetIdentityUser("helga"),
                         *      Steps = GetSteps()
                         *  }
                         * }
                         */
                    }
                };

                teams.AddRange(GetTeams());
                db.Team.AddRange(teams);
                db.SaveChanges();
            }
        }