public ActionResult <String> GetEvaluation(int id, String color)
 {
     try
     {
         var indicator = indicatorLogic.GetById(id);
         if (indicator == null)
         {
             return(NotFound());
         }
         NodeLogic     nl         = new NodeLogic(null);
         List <String> evaluation = new List <string>();
         evaluation.Add(nl.GetText(indicator.Green));
         evaluation.Add(nl.Evaluate(indicator.Green) + "");
         evaluation.Add(nl.GetText(indicator.Yellow));
         evaluation.Add(nl.Evaluate(indicator.Yellow) + "");
         evaluation.Add(nl.GetText(indicator.Red));
         evaluation.Add(nl.Evaluate(indicator.Red) + "");
         return(Ok(evaluation));
     }
     catch (NullException) { return(BadRequest("No es posible obtener un indicador nulo")); }
     catch (NotFoundException) { return(BadRequest("No fue posible obtener ese indicador")); }
     catch (NullReferenceException) { return(BadRequest("No es posible obtener un indicador nulo")); }
     catch (NotValidException) { return(BadRequest("No es posible obtener un indicador no válido")); }
     catch (DataBaseLogicException) { return(BadRequest("Error en la conexión con la base de datos")); }
     catch (InvalidOperationLogicException) { return(BadRequest("Error en el sistema")); }
 }
Пример #2
0
 public ActionResult <int> GetIndicators(int id, String color)
 {
     try
     {
         var user = userLogic.GetUserByID(id);
         List <Indicator> indicators = userLogic.GetAllIndicators(user);
         List <Indicator> toReturn   = new List <Indicator>();
         NodeLogic        nodeLogic  = new NodeLogic(null);
         foreach (Indicator indicator in indicators)
         {
             if (color.ToLowerInvariant() == "green" && nodeLogic.Evaluate(indicator.Green))
             {
                 toReturn.Add(indicator);
             }
             if (color.ToLowerInvariant() == "red" && nodeLogic.Evaluate(indicator.Red))
             {
                 toReturn.Add(indicator);
             }
             if (color.ToLowerInvariant() == "yellow" && nodeLogic.Evaluate(indicator.Yellow))
             {
                 toReturn.Add(indicator);
             }
             if (color.ToLowerInvariant() == "all")
             {
                 toReturn.Add(indicator);
             }
         }
         return(Ok(toReturn.Count));
     }
     catch (NullException) { return(BadRequest("No es posible obtener un usuario nulo")); }
     catch (NotFoundException) { return(BadRequest("No fue posible obtener ese usuario")); }
     catch (NullReferenceException) { return(BadRequest("No es posible obtener un usuario nulo")); }
     catch (NotValidException) { return(BadRequest("No es posible obtener un usuario no válido")); }
     catch (DataBaseLogicException) { return(BadRequest("Error en la conexión con la base de datos")); }
     catch (InvalidOperationLogicException) { return(BadRequest("Error en el sistema")); }
 }
        public void CompareBiggerNumeric()
        {
            var Left = new Operator
            {
                Type = 2,
                Text = "40000",
            };
            var Right = new Operator
            {
                Type = 2,
                Text = "123",
            };
            NodeLogic nodeLogic = new NodeLogic(null);

            Assert.AreEqual(nodeLogic.Evaluate(Right)[1], "123");
            Assert.IsTrue(nodeLogic.CompareBigger(Left, Right));
        }