Exemplo n.º 1
0
        private async Task SeedChallengesAsync()
        {
            var strategy = _challengePayoutFactory.CreateInstance();

            var twoDollars = new EntryFee(2, CurrencyType.Money);

            var threeDollars = new EntryFee(3, CurrencyType.Money);

            var twoDollarsForOneEntries = strategy.GetChallengePayout(ChallengePayoutEntries.One, twoDollars);

            var twoDollarsForTwoEntries = strategy.GetChallengePayout(ChallengePayoutEntries.Two, twoDollars);

            var twoDollarsForThreeEntries = strategy.GetChallengePayout(ChallengePayoutEntries.Three, twoDollars);

            var threeDollarsForOneEntries = strategy.GetChallengePayout(ChallengePayoutEntries.One, threeDollars);

            var threeDollarsForTwoEntries = strategy.GetChallengePayout(ChallengePayoutEntries.Two, threeDollars);

            var threeDollarsForThreeEntries = strategy.GetChallengePayout(ChallengePayoutEntries.Three, threeDollars);

            var challenges = new List <IChallenge>
            {
                new Challenge(ChallengeId.Parse("d53b366f-e717-43d4-ac12-6e13d37f5cef"), twoDollarsForOneEntries),
                new Challenge(ChallengeId.Parse("369ae69d-b10d-4d72-84ba-698691646ba6"), twoDollarsForOneEntries),
                new Challenge(ChallengeId.Parse("eb76fa60-700f-4dce-b312-d69897563437"), twoDollarsForTwoEntries),
                new Challenge(ChallengeId.Parse("82592581-e6ac-41e0-9c61-773d924f233d"), twoDollarsForTwoEntries),
                new Challenge(ChallengeId.Parse("9457ae9a-4e5c-436f-b10f-33134af68439"), twoDollarsForThreeEntries),
                new Challenge(ChallengeId.Parse("91f6d007-b458-4f1c-9814-755b32059e00"), twoDollarsForThreeEntries),
                new Challenge(ChallengeId.Parse("4ecb13a4-0742-4140-93b0-27ee582e5cab"), threeDollarsForOneEntries),
                new Challenge(ChallengeId.Parse("fa38f697-2ef3-40e9-a165-d62c3cc750a8"), threeDollarsForOneEntries),
                new Challenge(ChallengeId.Parse("ac6851b4-2cb7-42ab-bf44-fb197d21221b"), threeDollarsForTwoEntries),
                new Challenge(ChallengeId.Parse("bb5f6e0c-ada7-47b4-9d24-a3c9ec7df034"), threeDollarsForTwoEntries),
                new Challenge(ChallengeId.Parse("6ec217f7-3d6a-41c2-b2eb-4cc8799d2af5"), threeDollarsForThreeEntries),
                new Challenge(ChallengeId.Parse("7d96b314-8d5b-4393-9257-9c0e2cf7c0f1"), threeDollarsForThreeEntries)
            };

            Challenges.AddRange(challenges.Where(challenge => Challenges.All(x => x.Id != challenge.Id)).Select(challenge => challenge.ToModel()));

            await this.CommitAsync();
        }
Exemplo n.º 2
0
        protected override async Task SeedProductionAsync()
        {
            await this.SeedAdministratorAccountAsync();

            var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) !;

            var file = File.OpenRead(Path.Combine(assemblyPath, "Setup/Challenges.Production.csv"));

            using var csvReader = file.OpenCsvReader();

            Challenges.AddRange(
                csvReader.GetRecords(
                    new
            {
                Id = default(Guid),
                EntryFeeCurrency = default(int),
                EntryFeeAmount   = default(decimal),
                Entries          = default(int)
            })
                .Select(
                    record =>
            {
                var payoutStrategy = new ChallengePayoutFactory().CreateInstance();

                var payoutEntries = new ChallengePayoutEntries(record.Entries / 2);

                var currency = CurrencyType.FromValue(record.EntryFeeCurrency) !;

                var entryFee = new EntryFee(record.EntryFeeAmount, currency);

                var payout = payoutStrategy.GetChallengePayout(payoutEntries, entryFee);

                return(new Challenge(record.Id.ConvertTo <ChallengeId>(), payout));
            })
                .Where(challenge => Challenges.All(x => x.Id != challenge.Id))
                .Select(challenge => challenge.ToModel()));

            await this.CommitAsync();

            var startedAt = DateTimeOffset.FromUnixTimeMilliseconds(1582261200000).UtcDateTime;

            var duration = TimeSpan.FromDays(4);

            var promotion1 = new Promotion(
                "DHANA20REDCUP",
                new Money(5),
                duration,
                new DateTimeProvider(startedAt + duration));

            promotion1.SetEntityId(PromotionId.Parse("885cdd1e-0ed9-4fdc-9c29-d48a9d071cfd"));

            var promotion2 = new Promotion(
                "DHANA20TOK",
                new Token(250),
                duration,
                new DateTimeProvider(startedAt + duration));

            promotion2.SetEntityId(PromotionId.Parse("263aa2ed-3f88-4070-96e6-a098814e44f3"));

            var promotions = new List <Promotion>
            {
                promotion1,
                promotion2
            };

            Promotions.AddRange(promotions.Where(promotion => Promotions.All(x => x.Id != promotion.Id)).Select(promotion => promotion.ToModel()));

            await this.CommitAsync();
        }