Exemplo n.º 1
0
 private void OnCreateNewLeague(object sender, EventArgs e)
 {
     using (SaveFileDialog dlg = new SaveFileDialog())
     {
         dlg.AddExtension    = true;
         dlg.CheckFileExists = false;
         dlg.CheckPathExists = true;
         dlg.CreatePrompt    = false;
         dlg.DefaultExt      = "json";
         dlg.OverwritePrompt = true;
         dlg.Title           = "Select New League Filename";
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             PromptFromList prompt = new PromptFromList("Select Fantasy League", Enum.GetNames(typeof(Leagues)));
             if (prompt.ShowDialog() == DialogResult.OK)
             {
                 Leagues fantasyLeague;
                 if (Enum.TryParse(prompt.SelectedItem, out fantasyLeague))
                 {
                     League league = League.Create(fantasyLeague);
                     league.Save(dlg.FileName);
                     this.LoadPlayers(dlg.FileName);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        public async Task HandleAsync(CreateLeague command, ICorrelationContext context)
        {
            var league = League.Create(
                command.Name,
                command.Description,
                Enumeration.FromDisplayName <LeagueType>(command.LeagueType.Name));

            var repo = _uow.GetRepositoryAsync <League>();

            var entity = (await repo.AddAsync(league)).Entity;

            _uow.SaveChanges();



            await _busPublisher.PublishAsync(new LeagueCreated(entity.Id), context);
        }
 public static League GetEntity(int apiId, string shortName, string fullName, string flagURL,
                                Region region)
 {
     return(League.Create(apiId, shortName, fullName, flagURL, region));
 }
 private League Convert(JLeague model)
 {
     return(League.Create(model.DbId, model.ShortName, model.FullName, model.FlagUrl, model.Region.DbId));
 }
Exemplo n.º 5
0
        public LeaguesContext GetInitiatedLeaguesContext()
        {
            LeaguesContext context = CreateContextAndMigrateDb();

            var leagueForDelete = League.Create("for delete", "descr", LeagueType.Football);
            var leagueForUpdate = League.Create("for update", "descr", LeagueType.Football);
            var leagueForJoin1  = League.Create("for join 1", "descr", LeagueType.Football);
            var leagueForJoin2  = League.Create("for join 2", "descr", LeagueType.Hockey);
            var leagueForJoin3  = League.Create("for join 3", "descr", LeagueType.Hockey);

            var entityForDelete = context.Leagues.Add(leagueForDelete);
            var entityForUpdate = context.Leagues.Add(leagueForUpdate);
            var entityForJoin1  = context.Leagues.Add(leagueForJoin1);
            var entityForJoin2  = context.Leagues.Add(leagueForJoin2);
            var entityForJoin3  = context.Leagues.Add(leagueForJoin3);

            context.SaveChanges();
            MockedDataInstance = new MockedData
            {
                LeagueForDeleteId = entityForDelete.Entity.Id,
                LeagueForUpdateId = entityForUpdate.Entity.Id,
                LeagueForJoinId1  = entityForJoin1.Entity.Id,
                LeagueForJoinId2  = entityForJoin2.Entity.Id,
                LeagueForJoinId3  = entityForJoin3.Entity.Id,
                PlayersInTeam     = 10,
                TeamsInTour       = 50,
                Player1           = 100,
                Player2           = 101,
                Player3           = 102,
                Player4           = 103,
                Player5           = 104
            };

            IEnumerable <LeaguePlayerLink> links = new[]
            {
                // 1 league
                LeaguePlayerLink.CreateJoinedLink(MockedDataInstance.LeagueForJoinId1, MockedDataInstance.Player1),
                LeaguePlayerLink.CreateJoinedLink(MockedDataInstance.LeagueForJoinId1, MockedDataInstance.Player2),
                LeaguePlayerLink.CreateWaitingLink(MockedDataInstance.LeagueForJoinId1, MockedDataInstance.Player3),
                // 2 league
                LeaguePlayerLink.CreateJoinedLink(MockedDataInstance.LeagueForJoinId2, MockedDataInstance.Player2),
                LeaguePlayerLink.CreateWaitingLink(MockedDataInstance.LeagueForJoinId2, MockedDataInstance.Player3),
                LeaguePlayerLink.CreateWaitingLink(MockedDataInstance.LeagueForJoinId2, MockedDataInstance.Player4),
                LeaguePlayerLink.CreateWaitingLink(MockedDataInstance.LeagueForJoinId2, MockedDataInstance.Player5),
                // 3 league
                LeaguePlayerLink.CreateJoinedLink(MockedDataInstance.LeagueForJoinId3, MockedDataInstance.Player1),
                LeaguePlayerLink.CreateJoinedLink(MockedDataInstance.LeagueForJoinId3, MockedDataInstance.Player2),
                LeaguePlayerLink.CreateJoinedLink(MockedDataInstance.LeagueForJoinId3, MockedDataInstance.Player3),
                LeaguePlayerLink.CreateJoinedLink(MockedDataInstance.LeagueForJoinId3, MockedDataInstance.Player4),
                LeaguePlayerLink.CreateJoinedLink(MockedDataInstance.LeagueForJoinId3, MockedDataInstance.Player5)
            };

            MockedDataInstance.League1JoinedPlayersCount = 2;
            MockedDataInstance.League2JoinedPlayersCount = 1;
            MockedDataInstance.League3JoinedPlayersCount = 5;

            MockedDataInstance.League1WaitingPlayersCount = 1;
            MockedDataInstance.League1WaitingPlayersCount = 3;
            MockedDataInstance.League1WaitingPlayersCount = 0;

            context.LeaguePlayerLinks.AddRange(links);

            var leagueSettingsForUpdate = LeagueSettings.Create(
                false,
                false,
                leagueId: entityForUpdate.Entity.Id,
                MockedDataInstance.PlayersInTeam,
                MockedDataInstance.TeamsInTour);

            context.LeagueSettings.Add(leagueSettingsForUpdate);
            context.SaveChanges();
            return(context);
        }