Ejemplo n.º 1
0
        public Spin CreateSpin(SpinBindingModel model, string userId)
        {
            WheelConfiguration wheel = new WheelConfiguration {
                Id = 1, DateCreated = new DateTime(2017, 10, 10, 10, 20, 4), User = user
            };

            return(new Spin {
                Id = 6, BetValue = 20, ScoreValue = -1, ResultValue = -20.0m, ExecutionDate = new DateTime(2017, 11, 11, 8, 20, 4), User = user, WheelConfiguration = wheel
            });
        }
Ejemplo n.º 2
0
        public Spin CreateSpin(SpinBindingModel model, string userId)
        {
            if (model.BetValue == null)
            {
                throw new Exception("You must set bet value");
            }
            if (model.ResultValue == null)
            {
                throw new Exception("You must set result value");
            }
            if (model.ScoreValue == null)
            {
                throw new Exception("You must set score value");
            }

            var spin = _spinRepo.CreateSpin(model, userId);

            UpdateTransactionAndBalance(spin, userId);
            return(spin);
        }
Ejemplo n.º 3
0
        public Spin CreateSpin(SpinBindingModel model, string userId)
        {
            var user = _context.Users.FirstOrDefault(x => x.Id == userId);

            if (user == null)
            {
                throw new Exception("User does not exist");
            }

            var spin = new Spin
            {
                BetValue           = model.BetValue ?? 0,
                ResultValue        = model.ResultValue ?? 0,
                ScoreValue         = model.ScoreValue ?? 0,
                User               = user,
                ExecutionDate      = DateTime.Now,
                WheelConfiguration = _context.WheelConfigurations.FirstOrDefault(x => x.Id == model.WheelConfigurationId)
            };

            _context.Spins.Add(spin);
            _context.SaveChanges();

            return(spin);
        }
Ejemplo n.º 4
0
        public SpinViewModel AddSpin(SpinBindingModel model)
        {
            var userId = HttpContext.Current.User.Identity.GetUserId();

            return(TransformModels.ToSpinViewModel(_wheelService.CreateSpin(model, userId)));
        }