示例#1
0
        public async Task <ClaimResult> ClaimGame(ClaimGameDomainRequest request, bool managerAction, bool draft, IReadOnlyList <Publisher> publishersForYear)
        {
            Maybe <MasterGameYear> masterGameYear = Maybe <MasterGameYear> .None;

            if (request.MasterGame.HasValue)
            {
                masterGameYear = new MasterGameYear(request.MasterGame.Value, request.Publisher.LeagueYear.Year);
            }

            PublisherGame playerGame = new PublisherGame(request.Publisher.PublisherID, Guid.NewGuid(), request.GameName, _clock.GetCurrentInstant(), request.CounterPick, null, null,
                                                         masterGameYear, request.DraftPosition, request.OverallDraftPosition);

            var supportedYears = await _fantasyCriticRepo.GetSupportedYears();

            LeagueYear leagueYear = request.Publisher.LeagueYear;

            ClaimResult claimResult = CanClaimGame(request, supportedYears, leagueYear, publishersForYear, null, false);

            if (!claimResult.Success)
            {
                return(claimResult);
            }

            LeagueAction leagueAction = new LeagueAction(request, _clock.GetCurrentInstant(), managerAction, draft, request.AutoDraft);
            await _fantasyCriticRepo.AddLeagueAction(leagueAction);

            await _fantasyCriticRepo.AddPublisherGame(playerGame);

            return(claimResult);
        }
    public async Task <ClaimResult> ClaimGame(ClaimGameDomainRequest request, bool managerAction, bool draft, bool drafting)
    {
        MasterGameYear?masterGameYear = null;

        if (request.MasterGame is not null)
        {
            masterGameYear = new MasterGameYear(request.MasterGame, request.LeagueYear.Year);
        }

        ClaimResult claimResult = CanClaimGame(request, null, null, true, drafting);

        if (!claimResult.Success)
        {
            return(claimResult);
        }

        PublisherGame playerGame = new PublisherGame(request.Publisher.PublisherID, Guid.NewGuid(), request.GameName, _clock.GetCurrentInstant(), request.CounterPick, null, false, null,
                                                     masterGameYear, claimResult.BestSlotNumber !.Value, request.DraftPosition, request.OverallDraftPosition, null, null);

        LeagueAction leagueAction = new LeagueAction(request, _clock.GetCurrentInstant(), managerAction, draft, request.AutoDraft);
        await _fantasyCriticRepo.AddLeagueAction(leagueAction);

        await _fantasyCriticRepo.AddPublisherGame(playerGame);

        return(claimResult);
    }
示例#3
0
        public async Task SetEligibilityOverride(LeagueYear leagueYear, MasterGame masterGame, bool?eligible)
        {
            if (!eligible.HasValue)
            {
                await _fantasyCriticRepo.DeleteEligibilityOverride(leagueYear, masterGame);
            }
            else
            {
                await _fantasyCriticRepo.SetEligibilityOverride(leagueYear, masterGame, eligible.Value);
            }

            var allPublishers = await _publisherService.GetPublishersInLeagueForYear(leagueYear);

            var managerPublisher = allPublishers.Single(x => x.User.UserID == leagueYear.League.LeagueManager.UserID);

            string description;

            if (!eligible.HasValue)
            {
                description = $"{masterGame.GameName}'s eligibility setting was reset to normal.";
            }
            else if (eligible.Value)
            {
                description = $"{masterGame.GameName} was manually set to 'Eligible'";
            }
            else
            {
                description = $"{masterGame.GameName} was manually set to 'Ineligible'";
            }

            LeagueAction eligibilityAction = new LeagueAction(managerPublisher, _clock.GetCurrentInstant(), "Eligibility Setting Changed", description, true);
            await _fantasyCriticRepo.AddLeagueAction(eligibilityAction);
        }
示例#4
0
        public async Task <Result> RemovePublisherGame(LeagueYear leagueYear, Publisher publisher, PublisherGame publisherGame)
        {
            IReadOnlyList <Publisher> allPublishers = await _fantasyCriticRepo.GetPublishersInLeagueForYear(leagueYear);

            IReadOnlyList <Publisher>     publishersForYear = allPublishers.Where(x => x.LeagueYear.Year == leagueYear.Year).ToList();
            IReadOnlyList <Publisher>     otherPublishers   = publishersForYear.Where(x => x.User.UserID != publisher.User.UserID).ToList();
            IReadOnlyList <PublisherGame> otherPlayersGames = otherPublishers.SelectMany(x => x.PublisherGames).ToList();

            bool otherPlayerHasCounterPick = otherPlayersGames.Where(x => x.CounterPick).ContainsGame(publisherGame);

            if (otherPlayerHasCounterPick)
            {
                return(Result.Failure("Can't remove a publisher game that another player has as a counterPick."));
            }

            var result = await _fantasyCriticRepo.RemovePublisherGame(publisherGame.PublisherGameID);

            if (result.IsSuccess)
            {
                RemoveGameDomainRequest removeGameRequest = new RemoveGameDomainRequest(publisher, publisherGame);
                LeagueAction            leagueAction      = new LeagueAction(removeGameRequest, _clock.GetCurrentInstant());
                await _fantasyCriticRepo.AddLeagueAction(leagueAction);
            }

            return(result);
        }
        public async Task <ClaimResult> ClaimGame(ClaimGameDomainRequest request)
        {
            PublisherGame playerGame = new PublisherGame(Guid.NewGuid(), request.GameName, _clock.GetCurrentInstant(), request.CounterPick, null, null,
                                                         new MasterGameYear(request.MasterGame.Value, request.Publisher.Year), request.DraftPosition, request.OverallDraftPosition, request.Publisher.Year);

            ClaimResult claimResult = await CanClaimGame(request);

            if (!claimResult.Success)
            {
                return(claimResult);
            }

            LeagueAction leagueAction = new LeagueAction(request, _clock.GetCurrentInstant());
            await _fantasyCriticRepo.AddLeagueAction(leagueAction);

            await _fantasyCriticRepo.AddPublisherGame(request.Publisher, playerGame);

            return(claimResult);
        }