예제 #1
0
        public async Task <CreateBetResult> RegisterBet(Bet bet)
        {
            CreateBetResult result = new CreateBetResult();

            var roulette = await _rouletteRepository.GetRoulette(new Roulette
            {
                Id = bet.RouletteId
            });

            if (roulette == null)
            {
                result.Success = false;
                result.Message = "Roulette not found";
                return(result);
            }

            if (!roulette.Open)
            {
                result.Success = false;
                result.Message = "Roulette not Open,Please First Open the Roulette";
                return(result);
            }

            await _betRepository.AddBet(bet);

            result.Data    = bet.Id;
            result.Success = true;
            return(result);
        }
예제 #2
0
        public async Task <ActionResult> Close(string rouletteId)
        {
            var roulette = await _repository.GetRoulette(rouletteId);

            if (roulette != null)
            {
                if (roulette.Status)
                {
                    return(Ok(await _repository.CloseRoulette(rouletteId)));
                }
                else
                {
                    return(BadRequest("Error ruleta Cerrada"));
                }
            }
            else
            {
                return(BadRequest("Identificador de ruleta no existe"));
            }
        }
        public async Task <OpenRouletteResult> OpenRoulette(Guid rouletteId)
        {
            var current = await _rouletteRepository.GetRoulette(new Roulette { Id = rouletteId });

            current.Open   = true;
            current.Status = StatusType.Active;
            current        = await _rouletteRepository.UpdateRoulette(current);

            var result = new OpenRouletteResult();

            result.Data    = true;
            result.Success = true;
            return(result);
        }