Example #1
0
        /// <summary>
        /// Method to consult a roulette by identifier
        /// </summary>
        /// <param name="rouletteId"> roulette identifier </param>
        /// <returns> Object with the transaction information </returns>
        public TransactionDTO <RouletteDTO> GetRouletteById(long rouletteId)
        {
            TransactionDTO <RouletteDTO> transaction = new TransactionDTO <RouletteDTO>();

            transaction.Data = new RouletteDTO();
            try
            {
                var getRouletteById = _rouletteRepository.GetRouletteById(rouletteId);
                if (getRouletteById.Id == 0)
                {
                    transaction.Status  = Common.Status.Failure;
                    transaction.Message = "No existen la ruleta solicitada.";

                    return(transaction);
                }
                transaction.Data = new RouletteDTO(getRouletteById.Id, getRouletteById.Name, getRouletteById.Code, getRouletteById.AllowBets);
            }
            catch (ArgumentException ex)
            {
                transaction.Status  = Common.Status.Failure;
                transaction.Message = ex.Message;
            }

            return(transaction);
        }
Example #2
0
        public async Task <Roulette> ConfigureRoulette(BetModel model, User user)
        {
            Roulette roulette = await _rouletteRepository.GetRouletteById(model.RouletteId);

            RouletteHelper.CheckBetRoulette(roulette, model.RouletteId);
            BetRoulette bet = new BetRoulette(model, user);

            roulette.AddBet(bet);
            return(roulette);
        }
        private async Task <DTORoulette> CheckIfRouletteExists(long rouletteId)
        {
            var roulette = await rouletteRepository.GetRouletteById(rouletteId : rouletteId);

            if (roulette is null)
            {
                throw new HttpResponseException("No se ha encontrado la ruleta ingresada.");
            }

            return(roulette);
        }
Example #4
0
 public Roulette Find(string Id)
 {
     return(rouletteRepository.GetRouletteById(Id));
 }