예제 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserGroupPermissions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserGroupPermissions(UserGroupPermission userGroupPermission)
 {
     base.AddObject("UserGroupPermissions", userGroupPermission);
 }
예제 #2
0
 /// <summary>
 /// Create a new UserGroupPermission object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="groupID">Initial value of the GroupID property.</param>
 /// <param name="permissionID">Initial value of the PermissionID property.</param>
 public static UserGroupPermission CreateUserGroupPermission(global::System.Guid id, global::System.Guid groupID, global::System.Guid permissionID)
 {
     UserGroupPermission userGroupPermission = new UserGroupPermission();
     userGroupPermission.ID = id;
     userGroupPermission.GroupID = groupID;
     userGroupPermission.PermissionID = permissionID;
     return userGroupPermission;
 }
예제 #3
0
        private void PermissionModelOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            var permission = sender as PermissionModel;

            if (args.PropertyName == "IsChecked")
            {
                IsDirty = true;
                if (permission.IsChecked)
                {
                    SelectedUserGroup.UserGroup.Users.ForEach(user =>
                        {
                            var userPermission = user.UserPermissions.FirstOrDefault(per => per.PermissionID == permission.Permission.ID);
                            if (userPermission == null)
                            {
                                var newUserPermission = new UserPermission()
                                                {
                                                    ID = Guid.NewGuid(),
                                                    UserID = user.ID,
                                                    PermissionID = permission.Permission.ID,
                                                };

                                _adminDataUnit.UserPermissionsRepository.Add(newUserPermission);
                            }
                        });
                    var groupPermission = new UserGroupPermission()
                        {
                            ID = Guid.NewGuid(),
                            GroupID = SelectedUserGroup.UserGroup.ID,
                            PermissionID = permission.Permission.ID,
                        };
                    _adminDataUnit.UserGroupPermissionsRepository.Add(groupPermission);
                }
                else
                {
                    SelectedUserGroup.UserGroup.Users.ForEach(user =>
                       {
                           var userPermission = user.UserPermissions.FirstOrDefault(per => per.PermissionID == permission.Permission.ID);
                           if (userPermission != null)
                               _adminDataUnit.UserPermissionsRepository.Delete(userPermission);
                       });
                    var groupPermission = SelectedUserGroup.UserGroup.UserGroupPermissions.FirstOrDefault(x => x.PermissionID == permission.Permission.ID);
                    _adminDataUnit.UserGroupPermissionsRepository.Delete(groupPermission);
                }
            }
        }