예제 #1
0
 public IActionResult CreateBet([FromHeader(Name = "IdUser")] string IdUser, Bet bet)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(new
         {
             error = true,
             msg = "Bad Request"
         }));
     }
     try
     {
         Roulette roulette = _rouletteService.CreateBet(IdUser, bet);
         return(Ok(roulette));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(StatusCode(405));
     }
 }
예제 #2
0
        public IActionResult CreateBet([FromHeader(Name = "UserId")] String UserId, [FromBody] BetRequest bet)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Model is not valid"));
                }

                var jsonResponse = new
                {
                    bet.Color,
                    bet.Number,
                    created = _rouletteService.CreateBet(bet),
                };
                return(Ok(jsonResponse));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }