Exemplo n.º 1
0
        public ActionResult ToggleAllowexport(int id, int idGroup)
        {
            var helperBo = new HelperBo();
            var res      = helperBo.IsExistWhere(tableName, "ID_GROUP=" + idGroup + " AND ID_FUNCTION=" + id);
            var result   = "failed";

            if (res.success)
            {
                // not exist => add new
                if (res.message == "0")
                {
                    var g2f = new GroupToFunctionDto()
                    {
                        ID_FUNCTION  = id,
                        ID_GROUP     = idGroup,
                        ALLOW_ADD    = 0,
                        ALLOW_DEL    = 0,
                        ALLOW_EDIT   = 0,
                        ALLOW_EXPORT = 1,
                        ALLOW_VIEW   = 0
                    };
                    helperBo.Add(tableName, g2f);
                }
                //exist => update
                else
                {
                    helperBo.ToggleWhere(tableName, "ALLOW_EXPORT", "ID_GROUP=" + idGroup + " AND ID_FUNCTION=" + id);
                }
                result = "success";
            }
            return(Content(JsonConvert.SerializeObject(new
            {
                isSuccess = result
            }), "application/json"));
        }
Exemplo n.º 2
0
        public ActionResult Update(int ID, int ID_GROUP, int ID_FUNCTION, int ALLOW_VIEW, int ALLOW_ADD, int ALLOW_EDIT, int ALLOW_DEL, int ALLOW_EXPORT)
        {
            string res = "Failed";
            var    groupToFunctionBo = new HelperBo();


            if (ID == 0)
            {
                var obj = new GroupToFunctionDto()
                {
                    ALLOW_VIEW   = ALLOW_VIEW,
                    ALLOW_EXPORT = ALLOW_EXPORT,
                    ALLOW_EDIT   = ALLOW_EDIT,
                    ALLOW_DEL    = ALLOW_DEL,
                    ALLOW_ADD    = ALLOW_ADD,
                    ID_FUNCTION  = ID_FUNCTION,
                    ID_GROUP     = ID_GROUP
                };
                // not exist

                var resultAdd = groupToFunctionBo.Add(tableName, obj);
                if (resultAdd.success == true)
                {
                    res = "success";
                }
            }
            else
            {
                var obj = new GroupToFunctionDto()
                {
                    ALLOW_VIEW   = ALLOW_VIEW,
                    ALLOW_EXPORT = ALLOW_EXPORT,
                    ALLOW_EDIT   = ALLOW_EDIT,
                    ALLOW_DEL    = ALLOW_DEL,
                    ALLOW_ADD    = ALLOW_ADD,
                    ID_FUNCTION  = ID_FUNCTION,
                    ID_GROUP     = ID_GROUP
                };
                var result = groupToFunctionBo.UpdateWhere(tableName, obj, "ID=" + ID);
                if (result.success)
                {
                    res = result.message;
                }
                else
                {
                    _log.Error("ERROR", result.error.exception);
                }
            }

            return(Content(JsonConvert.SerializeObject(new
            {
                isSuccess = res
            }), "application/json"));
        }
Exemplo n.º 3
0
        public ActionResult SetAllowVal(int id, int val)
        {
            var groupToFunctionBo = new HelperBo();
            var obj = new GroupToFunctionDto()
            {
                ALLOW_ADD    = val,
                ALLOW_DEL    = val,
                ALLOW_EDIT   = val,
                ALLOW_EXPORT = val,
                ALLOW_VIEW   = val
            };
            var res    = groupToFunctionBo.UpdateWhere(tableName, val, "ID=" + id);
            var result = "failed";

            if (res.success)
            {
                result = "success";
            }
            return(Content(JsonConvert.SerializeObject(new
            {
                isSuccess = result
            }), "application/json"));
        }