Exemple #1
0
        public async Task <bool> CreateFullScheduleAsync()
        {
            try
            {
                var seasonInfo = await _rosterService.GetSeasonInfoView();

                var divisions = seasonInfo.Rosters.GroupBy(x => x.Division.DivisionName)
                                .ToDictionary(x => x.Key, x => x.ToList());
                var scheduleEntities = new List <ScheduleEntity>();
                foreach (var division in divisions)
                {
                    var teamNames = division.Value.OrderBy(x => x.TeamTierScore).Select(x => x.TeamName).ToList();

                    var views = GenerateRoundRobin(teamNames, division.Key);
                    foreach (var view in views)
                    {
                        var homeRosterId = division.Value.FirstOrDefault(x => x.TeamName == view.HomeTeam)?.RosterId;
                        var awayRosterId = division.Value.FirstOrDefault(x => x.TeamName == view.AwayTeam)?.RosterId;


                        var mapped = _scheduleMapper.Map(view, seasonInfo.SeasonInfo.SeasonInfoId, homeRosterId ?? Guid.Empty, awayRosterId ?? Guid.Empty);
                        scheduleEntities.Add(mapped);
                    }
                }
                return(await _scheduleRepository.InsertAsync(scheduleEntities));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error creating schedule");
                return(false);
            }
        }
        public async Task <IActionResult> ViewAllRostersAsync()
        {
            var model = await _rosterService.GetSeasonInfoView();

            model.StatusMessage = StatusMessage;
            return(View(model));
        }
Exemple #3
0
        public async Task <IActionResult> CreatePlayoffSeeds()
        {
            var model = await _rosterService.GetSeasonInfoView();

            var viewModel = new PlayoffInputView
            {
                PlayoffInputForm = new PlayoffInputForm(),
                SeasonInfoView   = model
            };

            viewModel.SeasonInfoView.StatusMessage = StatusMessage;
            return(View(viewModel));
        }