Exemple #1
0
        private bool ManageRoundRemoval(RoundBase round)
        {
            bool containsSoughtRound = Rounds.Contains(round);

            if (containsSoughtRound)
            {
                bool removalSuccessful = Rounds.Remove(round);

                if (removalSuccessful)
                {
                    round.MarkForDeletion();

                    bool stillContainsRounds = Rounds.Count > 0;
                    if (stillContainsRounds)
                    {
                        GetFirstRound().Construct();
                    }

                    FindIssues();
                    return(true);
                }
            }

            return(false);
        }
        public async Task <IActionResult> OnGetAsync([Range(0, 1000)] int round = 0)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            var now  = DateTime.UtcNow;
            var date = new DateTime(2020, 1, 1);

            int offset = now.Month - date.Month + (now.Year - date.Year) * 12;

            Rounds = await _context.Challenges.Where(x => x.State == 3).Select(x => (x.ReleaseDate.Month - date.Month) + (x.ReleaseDate.Year - date.Year) * 12).Distinct().OrderBy(x => x).ToListAsync();

            round--;

            if (!Rounds.Contains(round))
            {
                if (Rounds.Any())
                {
                    round = Rounds.Last();
                }
                else
                {
                    round = offset;
                }
            }

            Index = round;

            int pageMonthOffset = round % 12;
            int pageYearOffset  = round / 12;

            int month = date.Month + pageMonthOffset;
            int year  = date.Year + pageYearOffset;

            if (month < 1)
            {
                month += 12;
                year  -= 1;
            }

            Round = $"{new DateTime(2020, month, 1).ToString("MMMM", CultureInfo.InvariantCulture)} {year}";

            Challenges = await _context.Challenges.Where(x => x.State == 3 && x.ReleaseDate.Month == month && x.ReleaseDate.Year == year).OrderBy(x => x.ReleaseDate).ToListAsync();

            Categories = Challenges.Select(x => x.Category).Distinct().ToList();

            return(Page());
        }