Пример #1
0
        /// <summary>
        /// Checks the member permission.
        /// </summary>
        /// <param name="memberId">The member identifier.</param>
        /// <param name="permission">The permission.</param>
        /// <returns><c>true</c> if has permission, <c>false</c> otherwise.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// memberId
        /// or
        /// permission
        /// </exception>
		public bool CheckMemberPermission(string memberId, Permission permission)
		{
			if (memberId == null)
			{
				throw new ArgumentNullException("memberId");
			}
			if (permission == null)
			{
				throw new ArgumentNullException("permission");
			}

			var account = SecurityRepository.Accounts.FirstOrDefault(a => a.MemberId == memberId);

			if (account == null)
			{
				return false;
			}

			var retVal = false;
			//TODO: member organization check
			foreach (var assignment in SecurityRepository.RoleAssignments.Where(x => x.AccountId == account.AccountId).Expand("Role/RolePermissions"))
			{
				retVal = assignment.Role != null && assignment.Role.RolePermissions
					.Any(p=>p.PermissionId.Equals(permission.PermissionId, StringComparison.OrdinalIgnoreCase));
				if (retVal)
				{
					break;
				}
			}
			return retVal;
		}
 public PermissionViewModel(Permission innerItem, PermissionGroupViewModel parentViewModel)
 {
     InnerItem = innerItem;
     Parent = parentViewModel;
 }
Пример #3
0
 public PermissionGroup(string displayName, Permission[] availablePermissions)
 {
     DisplayName = displayName;
     AllAvailablePermissions = availablePermissions;
 }
Пример #4
0
		private string AddPermission(string name)
		{
			var client = GetRepository();
			var permission = new Permission { Name = name };
			client.Add(permission);
			client.UnitOfWork.Commit();
			return permission.PermissionId;
		}