示例#1
0
        public Toggle(int idApplication, int idVersion)
        {
            //Set default properties
            //Application ID 1 = ABC
            if (idApplication == 1)
            {
                isButtonBlue  = true;
                isButtonGreen = true;
                isButtonRed   = false;
            }
            else
            {
                isButtonBlue  = true;
                isButtonGreen = false;
                isButtonRed   = true;
            }

            //Get property in database with ID Application and ID Version
            List <tabControlToggle> list = ControlToggleBLL.GetById(idApplication, idVersion);

            if (list != null && list.Count() > 0)
            {
                //Set new value in property
                foreach (tabControlToggle objAux in list)
                {
                    var objResult = this.GetType().GetProperty(objAux.strKey);
                    objResult.SetValue(this, objAux.strValue);
                }
            }
        }
示例#2
0
        public IHttpActionResult SetToggles(int idApplication, int idVersion, string strToggle, bool value)
        {
            //Create object
            Toggle obj = new Toggle();

            var objAux = obj.GetType().GetProperty(strToggle);

            if (objAux != null)
            {
                objAux.SetValue(obj, value);

                //Verify is existes key in database
                tabControlToggle objToggle = ControlToggleBLL.GetById(idApplication, idVersion, strToggle);
                bool             bitInsert = false;

                //Create new object to insert or update in database
                if (objToggle == null)
                {
                    objToggle = new tabControlToggle();
                    bitInsert = true;
                }

                objToggle.idApplication = idApplication;
                objToggle.idVersion     = idVersion;
                objToggle.strKey        = strToggle;
                objToggle.strValue      = value;

                if (bitInsert)
                {
                    ControlToggleBLL.Insert(objToggle);
                }
                else
                {
                    ControlToggleBLL.Update(objToggle);
                }
            }
            else
            {
                obj.msgError = "This property is not defined.";
            }

            return(Ok(obj));
        }