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 }); }
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 }); }
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 }); }