private async Task ProcessPickupsForLeagueYear(LeagueYear leagueYear)
        {
            var allActiveBids = await GetActiveBids(leagueYear);

            if (!allActiveBids.Any())
            {
                return;
            }

            LeagueWideValues leagueWideValues = await GetLeagueWideValues();

            var insufficientFundsBids = allActiveBids.Where(x => x.BidAmount > x.Publisher.Budget);
            var winnableBids          = GetWinnableBids(allActiveBids, leagueYear.Options, leagueWideValues);
            var winningBids           = GetWinningBids(winnableBids);

            var takenGames = winningBids.Select(x => x.MasterGame);
            var losingBids = allActiveBids
                             .Except(winningBids)
                             .Except(insufficientFundsBids)
                             .Where(x => takenGames.Contains(x.MasterGame))
                             .Select(x => new FailedPickupBid(x, "Publisher was outbid."));

            var insufficientFundsBidFailures = insufficientFundsBids.Select(x => new FailedPickupBid(x, "Not enough budget."));
            var failedBids = losingBids.Concat(insufficientFundsBidFailures);

            await ProcessSuccessfulAndFailedBids(winningBids, failedBids);

            //When we are done, we run again.
            //This will repeat until there are no active bids.
            await Task.Delay(5);

            await ProcessPickupsForLeagueYear(leagueYear);
        }
示例#2
0
 public Trade ToDomain(LeagueYear leagueYear, Publisher proposer, Publisher counterParty, IEnumerable <MasterGameYearWithCounterPick> proposerMasterGames,
                       IEnumerable <MasterGameYearWithCounterPick> counterPartyMasterGames, IEnumerable <TradeVote> votes)
 {
     return(new Trade(TradeID, leagueYear, proposer, counterParty, proposerMasterGames, counterPartyMasterGames,
                      ProposerBudgetSendAmount, CounterPartyBudgetSendAmount, Message, ProposedTimestamp, AcceptedTimestamp, CompletedTimestamp,
                      votes, TradeStatus.FromValue(Status)));
 }
        public async Task <IReadOnlyList <PublisherGame> > GetAvailableCounterPicks(LeagueYear leagueYear, Publisher nextDraftingPublisher)
        {
            IReadOnlyList <Publisher> allPublishers = await _fantasyCriticRepo.GetPublishersInLeagueForYear(leagueYear.League, leagueYear.Year);

            IReadOnlyList <Publisher> otherPublishers = allPublishers.Where(x => x.PublisherID != nextDraftingPublisher.PublisherID).ToList();

            IReadOnlyList <PublisherGame> gamesForYear      = allPublishers.SelectMany(x => x.PublisherGames).ToList();
            IReadOnlyList <PublisherGame> otherPlayersGames = otherPublishers.SelectMany(x => x.PublisherGames).ToList();

            var alreadyCounterPicked = gamesForYear.Where(x => x.CounterPick).ToList();
            List <PublisherGame> availableCounterPicks = new List <PublisherGame>();

            foreach (var otherPlayerGame in otherPlayersGames)
            {
                bool playerHasCounterPick = alreadyCounterPicked.ContainsGame(otherPlayerGame);
                if (playerHasCounterPick)
                {
                    continue;
                }

                availableCounterPicks.Add(otherPlayerGame);
            }

            return(availableCounterPicks);
        }
    public async Task <ClaimResult> QueueGame(LeagueYear leagueYear, Publisher publisher, MasterGame masterGame)
    {
        IReadOnlyList <QueuedGame> queuedGames = await _fantasyCriticRepo.GetQueuedGames(publisher);

        bool alreadyQueued = queuedGames.Select(x => x.MasterGame.MasterGameID).Contains(masterGame.MasterGameID);

        if (alreadyQueued)
        {
            return(new ClaimResult(new List <ClaimError>()
            {
                new ClaimError("You already have that game queued.", false)
            }, null));
        }

        var claimRequest = new ClaimGameDomainRequest(leagueYear, publisher, masterGame.GameName, false, false, false, false, masterGame, null, null);
        var claimResult  = CanClaimGame(claimRequest, null, null, false, false);

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

        var        nextRank   = queuedGames.Count + 1;
        QueuedGame queuedGame = new QueuedGame(publisher, masterGame, nextRank);
        await _fantasyCriticRepo.QueueGame(queuedGame);

        return(claimResult);
    }
 public PublicLeagueYearViewModel(LeagueYear leagueYear)
 {
     LeagueID          = leagueYear.League.LeagueID;
     LeagueName        = leagueYear.League.LeagueName;
     NumberOfFollowers = leagueYear.League.NumberOfFollowers;
     PlayStatus        = leagueYear.PlayStatus.Value;
 }
示例#6
0
        private IReadOnlyList <ClaimError> GetMasterGameErrors(LeagueYear leagueYear, MasterGame masterGame, int year, bool counterPick, bool dropping, Instant?nextBidTime)
        {
            List <ClaimError> claimErrors = new List <ClaimError>();

            if (!dropping)
            {
                var overriddenEligibility = leagueYear.GetOverriddenEligibility(masterGame);
                if (overriddenEligibility.HasValue)
                {
                    if (!overriddenEligibility.Value)
                    {
                        claimErrors.Add(new ClaimError("That game has been specifically banned by your league.", false));
                    }
                }
                else
                {
                    //Normal eligibility (not manually set)
                    var eligibilityErrors = leagueYear.Options.AllowedEligibilitySettings.GameIsEligible(masterGame);
                    claimErrors.AddRange(eligibilityErrors);
                }
            }

            bool released = masterGame.IsReleased(_clock.GetCurrentInstant());

            if (released)
            {
                claimErrors.Add(new ClaimError("That game has already been released.", true));
            }

            if (nextBidTime.HasValue)
            {
                bool releaseBeforeNextBids = masterGame.IsReleased(nextBidTime.Value);
                if (releaseBeforeNextBids)
                {
                    claimErrors.Add(new ClaimError("That game will release before bids are processed.", true));
                }
            }

            if (released && masterGame.ReleaseDate.HasValue && masterGame.ReleaseDate.Value.Year < year)
            {
                claimErrors.Add(new ClaimError($"That game was released prior to the start of {year}.", false));
            }

            if (!dropping)
            {
                if (!released && masterGame.MinimumReleaseDate.Year > year && !counterPick)
                {
                    claimErrors.Add(new ClaimError($"That game is not scheduled to be released in {year}.", true));
                }
            }

            bool hasScore = masterGame.CriticScore.HasValue;

            if (hasScore)
            {
                claimErrors.Add(new ClaimError("That game already has a score.", true));
            }

            return(claimErrors);
        }
 public EditPublisherRequest(LeagueYear leagueYear, Publisher publisher, string newPublisherName, int budget, int freeGamesDropped, int willNotReleaseGamesDropped, int willReleaseGamesDropped)
 {
     LeagueYear = leagueYear;
     Publisher  = publisher;
     if (publisher.PublisherName != newPublisherName)
     {
         NewPublisherName = newPublisherName;
     }
     if (publisher.Budget != budget)
     {
         Budget = budget;
     }
     if (publisher.FreeGamesDropped != freeGamesDropped)
     {
         FreeGamesDropped = freeGamesDropped;
     }
     if (publisher.WillNotReleaseGamesDropped != willNotReleaseGamesDropped)
     {
         WillNotReleaseGamesDropped = willNotReleaseGamesDropped;
     }
     if (publisher.WillReleaseGamesDropped != willReleaseGamesDropped)
     {
         WillReleaseGamesDropped = willReleaseGamesDropped;
     }
 }
    public DropResult CanConditionallyDropGame(PickupBid request, LeagueYear leagueYear, Publisher publisher, Instant?nextBidTime)
    {
        List <ClaimError> dropErrors = new List <ClaimError>();

        var basicErrors = GetBasicErrors(leagueYear.League, publisher);

        dropErrors.AddRange(basicErrors);

        var currentDate = _clock.GetToday();
        var dateOfPotentialAcquisition = currentDate;

        if (nextBidTime.HasValue)
        {
            dateOfPotentialAcquisition = nextBidTime.Value.ToEasternDate();
        }

        if (request.ConditionalDropPublisherGame?.MasterGame is null)
        {
            throw new Exception($"Invalid conditional drop for bid: {request.BidID}");
        }

        var masterGameErrors = GetGenericSlotMasterGameErrors(leagueYear, request.ConditionalDropPublisherGame.MasterGame.MasterGame, leagueYear.Year,
                                                              true, currentDate, dateOfPotentialAcquisition, false, false, false);

        dropErrors.AddRange(masterGameErrors);

        //Drop limits
        var publisherGame = publisher.GetPublisherGameByPublisherGameID(request.ConditionalDropPublisherGame.PublisherGameID);

        if (publisherGame is null)
        {
            return(new DropResult(Result.Failure("Cannot drop a game that you do not have")));
        }
        if (dropErrors.Any())
        {
            return(new DropResult(Result.Failure("Game is no longer eligible for dropping.")));
        }
        bool gameWasDrafted = publisherGame.OverallDraftPosition.HasValue;

        if (!gameWasDrafted && leagueYear.Options.DropOnlyDraftGames)
        {
            return(new DropResult(Result.Failure("You can only drop games that you drafted due to your league settings.")));
        }

        var  otherPublishers      = leagueYear.GetAllPublishersExcept(publisher);
        bool gameWasCounterPicked = otherPublishers
                                    .SelectMany(x => x.PublisherGames)
                                    .Where(x => x.CounterPick)
                                    .ContainsGame(request.ConditionalDropPublisherGame.MasterGame.MasterGame);

        if (gameWasCounterPicked && leagueYear.Options.CounterPicksBlockDrops)
        {
            return(new DropResult(Result.Failure("You cannot drop that game because it was counter picked.")));
        }

        bool gameWillRelease = publisherGame.WillRelease();
        var  dropResult      = publisher.CanDropGame(gameWillRelease, leagueYear.Options);

        return(new DropResult(dropResult));
    }
示例#9
0
    public async Task <StartDraftResult> GetStartDraftResult(LeagueYear leagueYear, IReadOnlyList <FantasyCriticUser> activeUsers)
    {
        if (leagueYear.PlayStatus.PlayStarted)
        {
            return(new StartDraftResult(true, new List <string>()));
        }

        var supportedYears = await _fantasyCriticRepo.GetSupportedYears();

        var supportedYear = supportedYears.Single(x => x.Year == leagueYear.Year);

        List <string> errors = new List <string>();

        if (activeUsers.Count() < 2)
        {
            errors.Add("You need to have at least two players in the league.");
        }

        if (activeUsers.Count() > 20)
        {
            errors.Add("You cannot have more than 20 players in the league.");
        }

        if (leagueYear.Publishers.Count() != activeUsers.Count())
        {
            errors.Add("Not every player has created a publisher.");
        }

        if (!supportedYear.OpenForPlay)
        {
            errors.Add($"This year is not yet open for play. It will become available on {supportedYear.StartDate}.");
        }

        return(new StartDraftResult(!errors.Any(), errors));
    }
示例#10
0
        public async Task <IReadOnlyList <LeagueAction> > GetLeagueActions(LeagueYear leagueYear)
        {
            using (var connection = new MySqlConnection(_connectionString))
            {
                var entities = await connection.QueryAsync <LeagueActionEntity>(
                    "select * from tblleagueaction " +
                    "join tblpublisher on (tblleagueaction.PublisherID = tblpublisher.PublisherID) " +
                    "where tblpublisher.LeagueID = @leagueID and tblpublisher.Year = @leagueYear;",
                    new
                {
                    leagueID   = leagueYear.League.LeagueID,
                    leagueYear = leagueYear.Year
                });

                List <LeagueAction> leagueActions = new List <LeagueAction>();
                foreach (var entity in entities)
                {
                    Publisher    publisher    = (await GetPublisher(entity.PublisherID)).Value;
                    LeagueAction leagueAction = entity.ToDomain(publisher);
                    leagueActions.Add(leagueAction);
                }

                return(leagueActions);
            }
        }
示例#11
0
    private async Task <bool> CompleteDraft(LeagueYear leagueYear, int standardGamesAdded, int counterPicksAdded)
    {
        var publishers = leagueYear.Publishers;
        int numberOfStandardGamesToDraft = leagueYear.Options.GamesToDraft * publishers.Count;
        int standardGamesDrafted         = publishers.SelectMany(x => x.PublisherGames).Count(x => !x.CounterPick);

        standardGamesDrafted += standardGamesAdded;

        if (standardGamesDrafted < numberOfStandardGamesToDraft)
        {
            return(false);
        }

        int numberOfCounterPicksToDraft = leagueYear.Options.CounterPicksToDraft * publishers.Count;
        int counterPicksDrafted         = publishers.SelectMany(x => x.PublisherGames).Count(x => x.CounterPick);

        counterPicksDrafted += counterPicksAdded;

        if (counterPicksDrafted < numberOfCounterPicksToDraft)
        {
            return(false);
        }

        await _fantasyCriticRepo.CompleteDraft(leagueYear);

        return(true);
    }
    public async Task <IReadOnlyList <PossibleMasterGameYear> > GetTopAvailableGames(LeagueYear leagueYear, Publisher currentPublisher)
    {
        HashSet <MasterGame> publisherMasterGames = leagueYear.Publishers
                                                    .SelectMany(x => x.PublisherGames)
                                                    .Where(x => !x.CounterPick && x.MasterGame is not null)
                                                    .Select(x => x.MasterGame !.MasterGame)
                                                    .ToHashSet();

        HashSet <MasterGame> myPublisherMasterGames = currentPublisher.MyMasterGames;

        IReadOnlyList <MasterGameYear> masterGames = await _interLeagueService.GetMasterGameYears(leagueYear.Year);

        IReadOnlyList <MasterGameYear> matchingMasterGames = masterGames.OrderByDescending(x => x.DateAdjustedHypeFactor).ToList();
        List <PossibleMasterGameYear>  possibleMasterGames = new List <PossibleMasterGameYear>();
        var slots = currentPublisher.GetPublisherSlots(leagueYear.Options);
        var openNonCounterPickSlots = slots.Where(x => !x.CounterPick && x.PublisherGame is null).OrderBy(x => x.SlotNumber).ToList();

        LocalDate currentDate = _clock.GetToday();

        foreach (var masterGame in matchingMasterGames)
        {
            var eligibilityFactors = leagueYear.GetEligibilityFactorsForMasterGame(masterGame.MasterGame, currentDate);
            PossibleMasterGameYear possibleMasterGame = GetPossibleMasterGameYear(masterGame, openNonCounterPickSlots,
                                                                                  publisherMasterGames, myPublisherMasterGames, eligibilityFactors, currentDate);

            if (!possibleMasterGame.IsAvailable)
            {
                continue;
            }

            possibleMasterGames.Add(possibleMasterGame);
        }

        return(possibleMasterGames);
    }
示例#13
0
        public async Task <IReadOnlyList <LeagueYear> > GetLeagueYears(int year)
        {
            using (var connection = new MySqlConnection(_connectionString))
            {
                var queryObject = new
                {
                    year
                };

                IEnumerable <LeagueYearEntity> yearEntities = await connection.QueryAsync <LeagueYearEntity>("select * from tblleagueyear where Year = @year", queryObject);

                List <LeagueYear> leagueYears = new List <LeagueYear>();
                foreach (var entity in yearEntities)
                {
                    var league = await GetLeagueByID(entity.LeagueID);

                    if (league.HasNoValue)
                    {
                        throw new Exception($"Cannot find league for league-year (should never happen) LeagueID: {entity.LeagueID}");
                    }

                    var eligibilityLevel = await GetEligibilityLevel(entity.MaximumEligibilityLevel);

                    LeagueYear leagueYear = entity.ToDomain(league.Value, eligibilityLevel);
                    leagueYears.Add(leagueYear);
                }

                return(leagueYears);
            }
        }
示例#14
0
    protected async Task <GenericResultRecord <LeagueYearPublisherRecord> > GetExistingLeagueYearAndPublisher(Guid leagueID, int year, FantasyCriticUser userForPublisher,
                                                                                                              ActionProcessingModeBehavior actionProcessingModeBehavior, RequiredRelationship requiredRelationship, RequiredYearStatus requiredYearStatus)
    {
        var leagueYearRecord = await GetExistingLeagueYear(leagueID, year, actionProcessingModeBehavior, requiredRelationship, requiredYearStatus);

        if (leagueYearRecord.FailedResult is not null)
        {
            return(GetFailedResult <LeagueYearPublisherRecord>(leagueYearRecord.FailedResult));
        }

        var publisher = leagueYearRecord.ValidResult !.LeagueYear.GetUserPublisher(userForPublisher);

        if (publisher is null)
        {
            return(GetFailedResult <LeagueYearPublisherRecord>(BadRequest("That user does not have a publisher in that league.")));
        }

        bool userIsPublisher = leagueYearRecord.ValidResult.CurrentUser is not null &&
                               leagueYearRecord.ValidResult.CurrentUser.Id == publisher.User.Id;

        if (requiredRelationship.MustBePublisher && !userIsPublisher)
        {
            return(GetFailedResult <LeagueYearPublisherRecord>(Forbid()));
        }

        var publisherRelationship = new PublisherUserRelationship(leagueYearRecord.ValidResult.Relationship, userIsPublisher);

        return(new GenericResultRecord <LeagueYearPublisherRecord>(new LeagueYearPublisherRecord(leagueYearRecord.ValidResult.CurrentUser, leagueYearRecord.ValidResult.LeagueYear, publisher, publisherRelationship), null));
    }
示例#15
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);
        }
示例#16
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);
        }
示例#17
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);
        }
示例#18
0
    public Publisher?GetNextDraftPublisher(LeagueYear leagueYear)
    {
        if (!leagueYear.PlayStatus.DraftIsActive)
        {
            return(null);
        }

        var phase = GetDraftPhase(leagueYear);

        if (phase.Equals(DraftPhase.StandardGames))
        {
            var publishersWithLowestNumberOfGames = leagueYear.Publishers.WhereMin(x => x.PublisherGames.Count(y => !y.CounterPick));
            var allPlayersHaveSameNumberOfGames   = leagueYear.Publishers.Select(x => x.PublisherGames.Count(y => !y.CounterPick)).Distinct().Count() == 1;
            var maxNumberOfGames = leagueYear.Publishers.Max(x => x.PublisherGames.Count(y => !y.CounterPick));
            var roundNumber      = maxNumberOfGames;
            if (allPlayersHaveSameNumberOfGames)
            {
                roundNumber++;
            }

            bool roundNumberIsOdd = (roundNumber % 2 != 0);
            if (roundNumberIsOdd)
            {
                var sortedPublishersOdd = publishersWithLowestNumberOfGames.OrderBy(x => x.DraftPosition);
                var firstPublisherOdd   = sortedPublishersOdd.First();
                return(firstPublisherOdd);
            }
            //Else round is even
            var sortedPublishersEven = publishersWithLowestNumberOfGames.OrderByDescending(x => x.DraftPosition);
            var firstPublisherEven   = sortedPublishersEven.First();
            return(firstPublisherEven);
        }
        if (phase.Equals(DraftPhase.CounterPicks))
        {
            var publishersWithLowestNumberOfGames = leagueYear.Publishers.WhereMin(x => x.PublisherGames.Count(y => y.CounterPick));
            var allPlayersHaveSameNumberOfGames   = leagueYear.Publishers.Select(x => x.PublisherGames.Count(y => y.CounterPick)).Distinct().Count() == 1;
            var maxNumberOfGames = leagueYear.Publishers.Max(x => x.PublisherGames.Count(y => y.CounterPick));

            var roundNumber = maxNumberOfGames;
            if (allPlayersHaveSameNumberOfGames)
            {
                roundNumber++;
            }

            bool roundNumberIsOdd = (roundNumber % 2 != 0);
            if (roundNumberIsOdd)
            {
                var sortedPublishersOdd = publishersWithLowestNumberOfGames.OrderByDescending(x => x.DraftPosition);
                var firstPublisherOdd   = sortedPublishersOdd.First();
                return(firstPublisherOdd);
            }
            //Else round is even
            var sortedPublishersEven = publishersWithLowestNumberOfGames.OrderBy(x => x.DraftPosition);
            var firstPublisherEven   = sortedPublishersEven.First();
            return(firstPublisherEven);
        }

        return(null);
    }
        public Task <IReadOnlyList <Publisher> > GetPublishersInLeagueForYear(LeagueYear leagueYear, IEnumerable <FantasyCriticUser> usersInLeague)
        {
            var publishers = _publishers
                             .Where(x => x.LeagueYear.Equals(leagueYear))
                             .ToList();

            return(Task.FromResult <IReadOnlyList <Publisher> >(publishers));
        }
        public Task <IReadOnlyList <Publisher> > GetPublishersInLeagueForYear(LeagueYear leagueYear)
        {
            var publishers = _publishers
                             .Where(x => x.LeagueYear.Equals(leagueYear))
                             .ToList();

            return(Task.FromResult <IReadOnlyList <Publisher> >(publishers));
        }
 public IList <PlayerProjection> GetUnAvailablePlayerProjections(LeagueYear leagueYear)
 {
     return((from playerProjection in _context.Set <PlayerProjection>()
             join player in _context.Set <Player>() on playerProjection.PlayerId equals player.Id
             join draftPick in _context.Set <DraftPick>() on player.Id equals draftPick.PlayerId
             where draftPick.LeagueYearId == leagueYear.Id
             select playerProjection).ToList());
 }
        public ActionResult DeleteConfirmed(int id)
        {
            LeagueYear leagueYear = db.LeagueYears.Find(id);

            db.LeagueYears.Remove(leagueYear);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public AssociateGameDomainRequest(LeagueYear leagueYear, Publisher publisher, PublisherGame publisherGame, MasterGame masterGame, bool managerOverride)
 {
     LeagueYear      = leagueYear;
     Publisher       = publisher;
     PublisherGame   = publisherGame;
     MasterGame      = masterGame;
     ManagerOverride = managerOverride;
 }
示例#24
0
    public async Task <bool> RunAutoDraftAndCheckIfComplete(LeagueYear leagueYear)
    {
        var autoDraftResult = await AutoDraftForLeague(leagueYear, 0, 0);

        var draftComplete = await CompleteDraft(leagueYear, autoDraftResult.StandardGamesAdded, autoDraftResult.CounterPicksAdded);

        return(draftComplete);
    }
 public ManagerMessageEntity(LeagueYear leagueYear, ManagerMessage domainMessage)
 {
     MessageID   = domainMessage.MessageID;
     LeagueID    = leagueYear.League.LeagueID;
     Year        = leagueYear.Year;
     MessageText = domainMessage.MessageText;
     IsPublic    = domainMessage.IsPublic;
     Timestamp   = domainMessage.Timestamp.ToDateTimeUtc();
 }
 public LeagueActionViewModel(LeagueYear leagueYear, LeagueAction leagueAction)
 {
     LeagueName    = leagueYear.League.LeagueName;
     PublisherName = leagueAction.Publisher.PublisherName;
     Timestamp     = leagueAction.Timestamp;
     ActionType    = leagueAction.ActionType;
     Description   = leagueAction.Description;
     ManagerAction = leagueAction.ManagerAction;
 }
示例#27
0
    public LeagueYear GetUpdatedLeagueYear(LeagueYear leagueYear)
    {
        var updatedPublishersInLeague = _leagueLookup[leagueYear.Key];

        return(new LeagueYear(leagueYear.League, leagueYear.SupportedYear, leagueYear.Options, leagueYear.PlayStatus,
                              leagueYear.EligibilityOverrides,
                              leagueYear.TagOverrides, leagueYear.DraftStartedTimestamp, leagueYear.WinningUser,
                              updatedPublishersInLeague));
    }
 public LeagueActionProcessingSet(LeagueYear leagueYear, Guid processSetID, Instant processTime, string processName, IEnumerable <DropRequest> drops, IEnumerable <PickupBid> bids)
 {
     LeagueYear   = leagueYear;
     ProcessSetID = processSetID;
     ProcessTime  = processTime;
     ProcessName  = processName;
     Drops        = drops.ToList();
     Bids         = bids.ToList();
 }
        public Task <Maybe <Publisher> > GetPublisher(LeagueYear leagueYear, FantasyCriticUser user)
        {
            var publisher = _publishers
                            .Where(x => x.LeagueYear.Equals(leagueYear))
                            .Where(x => x.User.Equals(user))
                            .SingleOrDefault();

            return(Task.FromResult <Maybe <Publisher> >(publisher));
        }
示例#30
0
    public async Task UndoLastDraftAction(LeagueYear leagueYear)
    {
        var publisherGames = leagueYear.Publishers.SelectMany(x => x.PublisherGames);
        var newestGame     = publisherGames.WhereMax(x => x.Timestamp).First();

        var publisher = leagueYear.Publishers.Single(x => x.PublisherGames.Select(y => y.PublisherGameID).Contains(newestGame.PublisherGameID));

        await _publisherService.RemovePublisherGame(leagueYear, publisher, newestGame);
    }