コード例 #1
0
        // POST api/presupuestoproyecto
        public string Post(JObject value)
        {
            dynamic data   = value;
            string  action = (string)data.action;

            string strReturn = null;

            switch (action)
            {
            case "addVariable":
            {
                Pry_Variables variable = new Pry_Variables()
                {
                    Nombre            = (string)data.nombre,
                    FuenteInformacion = (string)data.fuenteInformacion
                };

                Context.addVariable(variable);
                strReturn = variable.IdVariable.ToString();
            }
            break;

            case "modifyVariable":
            {
                Pry_Variables variable = Context.GetVariable((int)data.idVariable);
                bool          modified = false;

                if (variable.Nombre != (string)data.nombre)
                {
                    variable.Nombre = (string)data.nombre;
                    modified        = true;
                }
                if (variable.FuenteInformacion != (string)data.fuenteInformacion)
                {
                    variable.FuenteInformacion = (string)data.fuenteInformacion;
                    modified = true;
                }

                Context.modifyData();
            }
            break;

            case "deleteVariable":
            {
                Pry_Variables variable = Context.GetVariable((int)data.idVariable);
                Context.deleteVariable(variable);
            }
            break;

            case "checkFormula":
            {
                strReturn = FormulaEvaluator.Evaluar((string)data.strFormula);
            }
            break;
            }

            return(strReturn);
        }
コード例 #2
0
ファイル: VariableCommand.cs プロジェクト: windischb/middler
        public ITreeNode GetVariable(string path)
        {
            path = path.Replace(".", "/");

            string parent = null;
            string name   = path;

            if (path.Contains("/"))
            {
                var parts = path.Split('/');
                parent = String.Join("/", parts.Take(parts.Length - 1));
                name   = parts.Last();
            }

            return(_variablesStore.GetVariable(parent, name));
        }