Esempio n. 1
0
        public bool SetQuizOperators([FromBody] IEnumerable <int> operators)
        {
            var session = HttpContext.Current.Session;

            session.Clear();

            var decimalOperatorRange = new List <DecimalOperator>();

            decimalOperatorRange.Add(DecimalEngine.GetDecimalOperatorEnumFromDecimalIndex(operators.Min()));
            decimalOperatorRange.Add(DecimalEngine.GetDecimalOperatorEnumFromDecimalIndex(operators.Max()));

            session.Add(QuizDecimalOpertorRangeSessionKey, decimalOperatorRange);

            return(true);
        }
Esempio n. 2
0
        private static DecimalEngine CreateEngineFromSession()
        {
            var decimalOperatorRange = (IEnumerable <DecimalOperator>)HttpContext.Current.Session[QuizDecimalOpertorRangeSessionKey];
            int floorOp;
            int ceilingOp;
            int firstOp = DecimalEngine.GetDecimalIndexFromDecimalOperatorEnum(decimalOperatorRange.First());
            int lastOp  = DecimalEngine.GetDecimalIndexFromDecimalOperatorEnum(decimalOperatorRange.Last());

            if (firstOp > lastOp)
            {
                floorOp   = lastOp;
                ceilingOp = firstOp;
            }
            else
            {
                floorOp   = firstOp;
                ceilingOp = lastOp;
            }

            return(new DecimalEngine(DecimalEngine.GetDecimalOperatorEnumFromDecimalIndex(floorOp), DecimalEngine.GetDecimalOperatorEnumFromDecimalIndex(ceilingOp)));
        }