Esempio n. 1
0
        public bool RemoveRole(Guid roleId, Guid groupId)
        {
            try
            {
                var groupRoleBO = new GroupRoleBO();
                var groupRole   = groupRoleBO.Get(this.ConnectionHandler, groupId, roleId);
                if (groupRole != null)
                {
                    if (!groupRoleBO.Delete(this.ConnectionHandler, groupId, roleId))
                    {
                        throw new Exception("خطایی در حذف نقش گروه وجود دارد");
                    }
                }

                return(true);
            }
            catch (KnownException ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
Esempio n. 2
0
        public bool AddRole(Guid roleId, Guid groupId)
        {
            try
            {
                var groupRoleBO = new GroupRoleBO();
                var groupRole   = groupRoleBO.Get(this.ConnectionHandler, groupId, roleId);
                if (groupRole == null)
                {
                    var role = new GroupRole {
                        GroupId = groupId, RoleId = roleId
                    };
                    if (!groupRoleBO.Insert(this.ConnectionHandler, role))
                    {
                        throw new Exception("خطایی در ذخیره نقش گروه وجود دارد");
                    }
                }

                return(true);
            }
            catch (KnownException ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }