Esempio n. 1
0
        public ThrowModel SaveThrowModel(ThrowModel model)
        {
            var result = model;

            model.ValidateModel();
            var throwEngine   = new ThrowEngine();
            var throwAccessor = new ThrowAccessor();
            var betEngine     = new BetEngine();
            var betAccessor   = new BetAccessor();
            var parentBet     = betAccessor.GetBetByParticipant(model.ParticipantID);

            using (var scope = new TransactionScope())
            {
                var savedThrow = throwAccessor.SaveThrow(throwEngine.BuildThrow(model));
                var betsToAdd  = betEngine.BuildBets(savedThrow, model.RedemptionBets, parentBet.BetID);

                foreach (var bet in betsToAdd)
                {
                    betAccessor.AddNewBetWithNewParticipants(bet);
                }

                result = throwAccessor.GetThrowModel(savedThrow.ThrowID);
                scope.Complete();
            }

            return(result);
        }
Esempio n. 2
0
 public Throw BuildThrow(ThrowModel model)
 {
     return(new Throw()
     {
         ThrowID = model.ThrowID,
         ThrowTypeID = model.ThrowTypeID,
         ParticipantID = model.ParticipantID,
         Notes = model.Notes,
         Success = model.Success
     });
 }
Esempio n. 3
0
        public ThrowModel GetThrowModel(int throwID)
        {
            ThrowModel result = null;

            using (var db = new CFLSuiteDB())
            {
                result = db.Throws.Where(x => x.ThrowID == throwID).ToThrowModels().First();
            }

            return(result);
        }
Esempio n. 4
0
        public ThrowModel DeleteThrowModel(ThrowModel model)
        {
            var result = model;

            using (var db = new CFLSuiteDB())
            {
                var existing = db.Throws.First(x => x.ThrowID == model.ThrowID);
                db.Throws.Remove(existing);
                db.SaveChanges();
            }
            return(result);
        }
Esempio n. 5
0
    public void Start()
    {
        if (canon == null)
        {
            canon = this.GetComponent <ThrowModel>();
        }
        if (myAnim != null)
        {
            return;
        }
        else
        {
            myAnim = GameObject.FindObjectOfType <Animator>();
        }

        PlayerControllerFinal.instance.On_TossNow_Sent += On_TossNow_Received;
    }
Esempio n. 6
0
        public Throw(ThrowModel @throw, ExecutionEngine logic)
        {
            this.create = () =>
            {
                Operator message = logic.Operators.CreateFrom(@throw.Message);

                if (message.Expression.Type != typeof(string))
                {
                    throw new ExpressionConfigException("Exception argument must be a string");
                }

                var exceptionType = @throw.Type.IfExists(type =>
                                                         logic.Operators.Models.Sources
                                                         .Select(source => source.Assembly)
                                                         .SelectMany(types => types.ExportedTypes)
                                                         .FirstOrDefault(candidate => candidate.FullName.Contains(type) && typeof(ExpressionRuntimeException).IsAssignableFrom(candidate)))
                                    ?? typeof(ExpressionRuntimeException);

                var ctor = exceptionType.FindCtorAccepting(typeof(string)).Value;
                var ex   = Expression.New(ctor, message.Expression);

                return(Expression.Throw(ex, typeof(string)));
            };
        }
Esempio n. 7
0
        public ActionResult DeleteThrowModel([DataSourceRequest] DataSourceRequest req, ThrowModel model)
        {
            var result = model;

            try
            {
                result = new BetService().DeleteThrowModel(model);
            }
            catch (Exception e)
            {
                ModelState.AddModelError("Error", e.Message);
            }

            return(Json(new[] { result }.ToDataSourceResult(req, ModelState)));
        }
Esempio n. 8
0
 public ThrowModel DeleteThrowModel(ThrowModel model)
 {
     return(new ThrowAccessor().DeleteThrowModel(model));
 }