Пример #1
0
    public async Task <Result> SellGame(RoyalePublisher publisher, RoyalePublisherGame publisherGame)
    {
        var currentDate = _clock.GetToday();

        if (publisherGame.MasterGame.MasterGame.IsReleased(currentDate))
        {
            return(Result.Failure("That game has already been released."));
        }
        if (publisherGame.MasterGame.MasterGame.CriticScore.HasValue)
        {
            return(Result.Failure("That game already has a score."));
        }

        if (!publisher.PublisherGames.Contains(publisherGame))
        {
            return(Result.Failure("You don't have that game."));
        }

        var masterGameTags = await _masterGameRepo.GetMasterGameTags();

        var currentlyInEligible = publisherGame.CalculateIsCurrentlyIneligible(masterGameTags);
        await _royaleRepo.SellGame(publisherGame, currentlyInEligible);

        return(Result.Success());
    }
Пример #2
0
 public RoyalePublisherGameViewModel(RoyalePublisherGame domain, LocalDate currentDate, IEnumerable <MasterGameTag> allMasterGameTags)
 {
     PublisherID         = domain.PublisherID;
     YearQuarter         = new RoyaleYearQuarterViewModel(domain.YearQuarter);
     MasterGame          = new MasterGameYearViewModel(domain.MasterGame, currentDate);
     Locked              = domain.IsLocked(currentDate, allMasterGameTags);
     Timestamp           = domain.Timestamp;
     AmountSpent         = domain.AmountSpent;
     AdvertisingMoney    = domain.AdvertisingMoney;
     FantasyPoints       = domain.FantasyPoints;
     CurrentlyIneligible = domain.CalculateIsCurrentlyIneligible(allMasterGameTags);
     RefundAmount        = AmountSpent;
     if (!CurrentlyIneligible)
     {
         RefundAmount /= 2;
     }
 }