Ejemplo n.º 1
0
        public async Task <CreateBetResponse> CreateBet(CreateBetRequest request)
        {
            Account account = await this._repositoryAccount.Get(request.AccountId);

            Event @event = await this._repositoryEvent.Get(request.EventId);

            OutcomesType outcomesType = await this._repositoryOutcomesType.GetBy(v => v.Name == request.OutcomesType);

            Bet bet = await this._betsFactory.CreateBet(account, @event, outcomesType, request.BetAmount);

            return(new CreateBetResponse {
                BetId = bet.Id
            });
        }
Ejemplo n.º 2
0
        public GetBetResponse Convert(Bet bet)
        {
            OutcomesType outcomesType = this._repositoryOutcomesType.Get(bet.OutcomesTypeId).GetAwaiter().GetResult();
            CurrencyType currencyType = this._repositoryCurrencyType.Get(bet.CurrencyTypeId).GetAwaiter().GetResult();

            return(new GetBetResponse
            {
                AccountId = bet.AccountId,
                EventId = bet.EventId,
                OutcomesType = outcomesType.Name,
                CurrencyType = currencyType.Name,
                CreationDate = bet.CreationDate,
                Value = bet.Value
            });
        }
Ejemplo n.º 3
0
        public async Task <CalculateBetRateResponse> CalculateBetRate(CalculateBetRateRequest request)
        {
            Account account = await this._repositoryAccount.Get(request.AccountId);

            Event @event = await this._repositoryEvent.Get(request.EventId);

            OutcomesType outcomesType = await this._repositoryOutcomesType.GetBy(v => v.Name == request.OutcomesType);

            BetRate betRate = await this._betsFactory.CalculateBetRate(account, @event, outcomesType, request.BetAmount);

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

            return(new CalculateBetRateResponse {
                CreationDate = betRate.CreationDate, WinValue = betRate.WinValue, WinRate = betRate.WinRate, Rate = betRate.Rate
            });
        }