Ejemplo n.º 1
0
        public IActionResult  Get(string formula)
        {
            if (string.IsNullOrEmpty(formula))
            {
                var data = new {
                    status  = "error",
                    message = "Please enter the formula!"
                };
                return(BadRequest(data));
            }
            RPN onp = new RPN(formula);

            if (onp.IsCorrect() == "true")
            {
                var data = new {
                    status = "ok",
                    result = new {
                        infix   = onp.Tokens().ToArray(),
                        postfix = onp.InfixToPostfix(onp.Tokens())
                    }
                };
                return(Ok(data));
            }
            else
            {
                var data = new {
                    status  = "error",
                    message = onp.IsCorrect()
                };
                return(BadRequest(data));
            }
        }