public CreateBetResponse MakeBet(CreateBetRequest betRequest, string clientId) { CreateBetResponse response = new CreateBetResponse(); var currentRoulette = _redisHelper.FindRoulette(betRequest.RouletteId); if (!currentRoulette.IsOpen) { response.Message = "The roulette is Closed"; return(response); } Entities.Bet newBet = new Entities.Bet(); if (betRequest.TypeofBet == Enums.BetType.Color) { newBet.Color = betRequest.Color; newBet.NumbertoBet = null; } else { newBet.Color = Enums.BetColor.None; newBet.NumbertoBet = betRequest.NumbertoBet; } newBet.RouletteId = betRequest.RouletteId; newBet.Type = betRequest.TypeofBet; newBet.MoneytoBet = betRequest.MoneytoBet; _redisHelper.CreateBet(newBet); response.Successful = true; response.Message = "Success"; return(response); }
public IActionResult CreateBet([FromBody] CreateBetRequest bet, [FromHeader] string clientId) { if (!string.IsNullOrEmpty(clientId)) { CreateBetResponse response = _betService.MakeBet(bet, clientId); return(Ok(response)); } else { return(BadRequest("You must enter a Client Id")); } }
public async Task CreateBet(BetBindingModel model) { IUser account = await this._userManager.FindByNameAsync(User.Identity.Name); CreateBetResponse response = await this._betsService.CreateBet( new CreateBetRequest { AccountId = Guid.Parse(account.Id), EventId = model.EventId, BetAmount = model.BetAmount, OutcomesType = model.OutcomesType }); }