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)); }
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")); }
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)); }