Exemple #1
0
        public IActionResult CalculateInterval(string formula, double?from, double?to, int?n)
        {
            if (formula == null || from == null || to == null || n == null)
            {
                var bad2 = new {
                    status = "error",
                    result = "wrong input"
                };
                return(BadRequest(bad2));
            }

            RPN rpn = new RPN(formula, (double)from, (double)to, (int)n);

            if (rpn.CheckInput())
            {
                var good = new {
                    status = "ok",
                    result = rpn.CalculateValueOfGivenInterval()
                };
                return(Ok(good));
            }
            var bad = new {
                status = "error",
                result = rpn.Message()
            };

            return(BadRequest(bad));
        }