コード例 #1
0
        /// <summary>
        /// Saves a record to the Permission table.
        /// </summary>
        public int Insert(PermissionEntity permission)
        {
            int  res  = 0;
            bool flag = false;

            try
            {
                var p = Param(permission);
                flag = (bool)unitOfWork.ProcedureExecute("ptgroup_Permission_Insert", p);
                if (flag)
                {
                    res = p.Get <int>("@Id");
                }
                else
                {
                    res = 0;
                }
            }
            catch (Exception ex)
            {
                Logging.PutError(ex.Message, ex);
                throw;
            }
            return(res);
        }
コード例 #2
0
        /// <summary>
        /// Updates a record in the Permission table.
        /// </summary>
        public bool Update(PermissionEntity permission)
        {
            bool res = false;

            try
            {
                var p = Param(permission, "edit");
                res = (bool)unitOfWork.ProcedureExecute("ptgroup_Permission_Update", p);
                return(res);
            }
            catch (Exception ex)
            {
                Logging.PutError(ex.Message, ex);
                throw;
            }
        }
コード例 #3
0
        /// <summary>
        /// Saves a record to the Permission table.
        /// </summary>
        private DynamicParameters Param(PermissionEntity permission, string action = "add")
        {
            var p = new DynamicParameters();

            if (action == "edit")
            {
                p.Add("@Id", permission.Id);
            }
            else
            {
                p.Add("@Id", dbType: DbType.Int32, direction: ParameterDirection.Output);
            }
            p.Add("@UserId", permission.UserId);
            p.Add("@GroupId", permission.GroupId);
            return(p);
        }