public async Task <bool> Bet(BetUser model) { var validate = this.ValidateStateRoulette(model.IdRoulette); if (validate.Result == 1) { var totalBet = this.ValidateBetRoulette(model.IdRoulette); if ((totalBet.Result + model.MoneyBet) <= 10000) { if (model.Number != null && model.Number >= 0 && model.Number <= 36) { model.Color = string.Empty; } else if (model.Color == null || (model.Color.ToUpper() != "NEGRO" && model.Color.ToUpper() != "ROJO")) { return(false); } var result = await _rouletteService.Bet(model); _cacheService.ClearKeysByPattern(string.Format(REDIS_CACHE_LIST_BET_KEY, model.IdRoulette)); return(result); } } return(false); }
public async Task <ActionResult <BaseResponse <BetResponse> > > Bet(BetRequest request) { BetAppRequest data = new BetAppRequest { bet = request, idUser = Convert.ToInt32(HttpContext.User.FindFirst("idPerson").Value) }; BaseResponse <BetResponse> response = await _rouletteService.Bet(data); if (!string.IsNullOrEmpty(response.message)) { return(BadRequest(response)); } return(Ok(response)); }
public IActionResult Bet([FromBody] Bet request, [FromHeader(Name = "user-id")] string userId) { if (!ModelState.IsValid) { return(BadRequest(new ServiceResponse { Code = 0, Message = "Debe ingresar los parámtros obligatorios." })); } try { Roulette roulette = _rouletteService.Bet(request, userId); return(Ok(roulette)); } catch (Exception e) { Console.WriteLine(e); return(StatusCode(405)); } }
public IActionResult Bet([FromHeader(Name = "user-id")] string UserId, [FromRoute(Name = "id")] string id, [FromBody] BetRequest request) { if (!ModelState.IsValid) { return(BadRequest(new { error = true, msg = "Bad Request" })); } try { Roulette roulette = rouletteService.Bet(id, UserId, request.position, request.money); return(Ok(roulette)); } catch (Exception e) { Console.WriteLine(e); return(StatusCode(405)); } }
public async Task <IActionResult> Bet(decimal amount, decimal number) { var response = await _RouletteService.Bet(CurrentUserId, amount, number); return(Ok(response)); }