예제 #1
0
        public ActionResult <RouletteDto> CreateRoulette()
        {
            var rouletteEntity = new Roulette();
            var rouletteRepo   = _casinoRepository.AddRoulette(rouletteEntity);

            _casinoRepository.Save();
            var rouletteReturn = _mapper.Map <RouletteDto>(rouletteRepo);

            return(CreatedAtRoute("GetRoulette",
                                  new { rouletteId = rouletteReturn.RouletteId },
                                  rouletteReturn));
        }
예제 #2
0
        public ActionResult <BetDto> CreateBetForRoulette(
            Guid rouletteId, BetForCreation bet)
        {
            if (!_casinoRepository.RouletteExists(rouletteId))
            {
                return(NotFound("La ruleta no existe"));
            }
            if (!_casinoRepository.RouletteIsOpen(rouletteId))
            {
                return(BadRequest("La ruleta no se encuentra abierta"));
            }
            var betEntity = _mapper.Map <Bet>(bet);

            if (!_casinoRepository.UserExists(bet.UserId))
            {
                return(NotFound("El usuario no existe"));
            }
            if (!_casinoRepository.IsBetValid(betEntity))
            {
                return(BadRequest("Verifique los valores de la apuesta"));
            }
            _casinoRepository.AddBet(rouletteId, betEntity);
            _casinoRepository.Save();

            return(Ok("Se realizo la apuesta exitosamente"));
        }
예제 #3
0
        public ActionResult <UserDto> CreateUser(UserForCreationDto user)
        {
            var userEntity = _mapper.Map <User>(user);

            _casinoRepository.AddUser(userEntity);
            _casinoRepository.Save();
            var userReturn = _mapper.Map <UserDto>(userEntity);

            return(CreatedAtRoute("GetUser",
                                  new { userId = userReturn.Id },
                                  userReturn));
        }