コード例 #1
0
        public async Task <BetOption> AddBetOption(string name, float odds, string betName)
        {
            Bet bet = await _repository.GetBetByName(betName);

            if (bet == null)
            {
                return(null);
            }

            if (bet.Resolved)
            {
                return(null);
            }

            if (odds <= 1)
            {
                return(null);
            }

            BetOption newOption = new BetOption
            {
                Id   = bet.Options.Count() + 1,
                Name = name,
                Odds = odds
            };

            bet.Options = bet.Options.Concat(new[] { newOption });
            await _repository.UpdateBet(bet);

            await _repository.SaveAsync();

            return(newOption);
        }