public IActionResult Get(string formula, double x = Double.NaN) { if (string.IsNullOrEmpty(formula)) { var data = new { status = "error", message = "Please enter the formula!" }; return(BadRequest(data)); } if (Double.IsNaN(x)) { var data = new { status = "error", message = "Please enter X!" }; return(BadRequest(data)); } RPN onp = new RPN(formula); if (onp.IsCorrect() == "true") { var data = new { status = "ok", result = onp.CalX(onp.Tokens(), x) }; return(Ok(data)); } else { var data = new { status = "error", message = onp.IsCorrect() }; return(BadRequest(data)); } }