예제 #1
0
        /// <summary>
        /// Method to create roulette
        /// </summary>
        /// <returns> Object with the transaction information </returns>
        public TransactionDTO <long> CreateRoulette()
        {
            TransactionDTO <long> transaction = new TransactionDTO <long>();

            transaction.Data = 0;
            try
            {
                RouletteModel rouletteModel = new RouletteModel();
                string        name          = RouletteNameGenerator();
                rouletteModel.Name = name;
                rouletteModel.Code = name;

                long createRouletteId = _rouletteRepository.CreateRoulette(rouletteModel);
                if (createRouletteId < 0)
                {
                    transaction.Status  = Common.Status.Failure;
                    transaction.Message = "No fue posible crear la nueva ruleta de juego.";

                    return(transaction);
                }
                transaction.Data = createRouletteId;
            }
            catch (ArgumentException ex)
            {
                transaction.Status  = Common.Status.Failure;
                transaction.Message = ex.Message;
            }

            return(transaction);
        }
예제 #2
0
        public async Task <ActionResult <string> > Create()
        {
            Roulette roulette = new Roulette();

            roulette.RouletteId = Guid.NewGuid().ToString();

            return(Ok(await _repository.CreateRoulette(roulette)));
        }
        public async Task <ActionResult <Roulette> > Post()
        {
            try
            {
                bool     succes   = false;
                Roulette roulette = new Roulette {
                    Id = Guid.NewGuid(), CreatedDate = DateTime.UtcNow
                };
                await Task.Run(() =>
                {
                    succes = repository.CreateRoulette(roulette: roulette);
                });

                if (!succes)
                {
                    return(BadRequest());
                }

                return(Ok(roulette.Id.ToString()));
            }
            catch (Exception ex)
            { return(BadRequest(ex.Message)); }
        }
예제 #4
0
        public Int64 CreateRoulette(string name)
        {
            Int64 idNewRoulette             = 1;
            var   sRoulettes                = _rouletteRepository.GetKeysRedis("Roulettes");
            List <RouletteEnt> objRoulettes = new List <RouletteEnt>();

            if (sRoulettes != null)
            {
                objRoulettes  = JsonConvert.DeserializeObject <List <RouletteEnt> >(sRoulettes);
                idNewRoulette = objRoulettes.Count + 1;
            }

            var rouletteEntNew = new RouletteEnt
            {
                Id     = idNewRoulette,
                Name   = name,
                IsOpen = false
            };

            objRoulettes.Add(rouletteEntNew);
            var response = _rouletteRepository.CreateRoulette("Roulettes", JsonConvert.SerializeObject(objRoulettes));

            return(idNewRoulette);
        }
예제 #5
0
        public async Task <ActionResult <Roulette> > CreateRoulette()
        {
            Roulette roulette = await _rouletterepository.CreateRoulette();

            return(Ok(new { id = roulette.IdRoulette }));
        }