コード例 #1
0
        public ActionResult <StringCalculatorDTO> PostStringCalculator(StringCalculatorRequest modelo)
        {
            SaveAction          action    = new SaveAction(new StringCalculator());
            StringCalculatorDTO resultado = action.ExecuteAPI(modelo.Numbers);

            if (resultado == null)
            {
                return(BadRequest(new BadRequestJSONegativesNotAllowed()));
            }
            return(resultado);
        }
 public ActionResult <StringCalculatorItem> StringCalculatorPost(StringCalculatorRequest request)
 {
     try
     {
         return(Run(GenerateStore(), request.Numbers));
     }
     catch (Exception exception)
     {
         return(BadRequest(new ExceptionJSON {
             Type = exception.Message
         }));
     }
 }
コード例 #3
0
        public ActionResult <StringCalculatorResult> PostStringCalculatora(StringCalculatorRequest request)
        {
            var saveAction             = new SaveAction(new StringCalculator(), new PersistenceFile(@"..\OperationLog.txt"));
            var stringCalculatorResult = saveAction.Execute(request.Numbers);

            if (stringCalculatorResult == null)
            {
                return(BadRequest(new ErrorMessage()
                {
                    Error = "Negative numbers not allowed"
                }));
            }
            return(stringCalculatorResult);
        }
 public ActionResult <StringCalculatorItem> StringCalculatorPost2(StringCalculatorRequest request)
 {
     try
     {
         return(new StringCalculatorItem()
         {
             Operation = "operacion", Result = 100
         });
     }
     catch (Exception exception)
     {
         return(BadRequest(new ExceptionJSON {
             Type = exception.Message
         }));
     }
 }