Exemplo n.º 1
0
 public BetedPair BetedPair(BetablePair betablePair, BetingType type)
 {
     return(new BetedPair
     {
         BetablePair = betablePair,
         BetablePairId = betablePair.Id,
         BetedType = type
     });
 }
Exemplo n.º 2
0
        public static decimal GetQuotaForType(this BetablePair pair, BetingType type)
        {
            switch (type)
            {
            case BetingType.Team1Win: return(pair.Team1WinQuota);

            case BetingType.Team2Win: return(pair.Team2WinQuota);

            case BetingType.Draw: return(pair.DrawQuota);

            default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Exemplo n.º 3
0
        public static async Task Seed(DbContext db)
        {
            var user = new User {
                UserId = "mladen"
            };
            var wallet = new UserWallet {
                Currency = "HRK", MoneyAmmount = 500, UserId = user.UserId
            };

            db.AddRange(user, wallet);

            var hajduk  = NewFootballTeam("Hajduk");
            var dinamo  = NewFootballTeam("Dinamo");
            var barca   = NewFootballTeam("Barcelona");
            var arsenal = NewFootballTeam("Arsenal");

            db.AddRange(hajduk, dinamo, barca, arsenal);

            var hajdukVsDinamo = new BetablePair
            {
                Team1         = hajduk,
                Team2         = dinamo,
                Team1WinQuota = 2,
                Team2WinQuota = 3,
                DrawQuota     = 2.5m
            };

            var barcaVsArsenal = new BetablePair
            {
                Team1         = barca,
                Team2         = arsenal,
                Team1WinQuota = 2,
                Team2WinQuota = 3.1m,
                DrawQuota     = 2.4m
            };

            db.AddRange(hajdukVsDinamo, barcaVsArsenal);

            var ticket = new Ticket
            {
                UserId     = user.UserId,
                BetedPairs = new []
                {
                    new BetedPair
                    {
                        BetablePair   = hajdukVsDinamo,
                        BetablePairId = hajdukVsDinamo.Id,
                        BetedType     = BetingType.Draw,
                    },
                    new BetedPair
                    {
                        BetablePair   = barcaVsArsenal,
                        BetablePairId = barcaVsArsenal.Id,
                        BetedType     = BetingType.Team1Win,
                    }
                }
            };

            ticket.Quota = ticket.BetedPairs.Select(p => p.GetQuota()).Product();

            db.Add(ticket);

            await db.SaveChangesAsync();
        }