Esempio n. 1
0
 public GroupType(NotificationFacade notificationFacade, UserGroupFacade userGroupFacade,
                  GroupSubjectFacade groupSubjectFacade)
 {
     Field(x => x.Id);
     Field <StringGraphType>("name",
                             resolve: context => context.Source.Name);
     Field <ListGraphType <NotificationType> >(
         "notifications",
         resolve: context => notificationFacade.GetByGroupId(context.Source.Id));
     Field <ListGraphType <UserGroupType> >(
         "userGroups",
         resolve: context => userGroupFacade.GetByGroupId(context.Source.Id));
     Field <ListGraphType <GroupSubjectType> >(
         "groupSubjects",
         resolve: context => groupSubjectFacade.GetByGroupId(context.Source.Id));
     Field <NotificationType>("notification",
                              arguments: new QueryArguments(new QueryArgument <IntGraphType> {
         Name = "id"
     }),
                              resolve: context => notificationFacade.GetById(context.GetArgument <int>("id")));
     Field <UserGroupType>("userGroup",
                           arguments: new QueryArguments(new QueryArgument <IntGraphType> {
         Name = "id"
     }),
                           resolve: context => userGroupFacade.GetById(context.GetArgument <int>("id")));
     Field <GroupSubjectType>("groupSubject",
                              arguments: new QueryArguments(new QueryArgument <IntGraphType> {
         Name = "id"
     }),
                              resolve: context => groupSubjectFacade.GetById(context.GetArgument <int>("id")));
 }
Esempio n. 2
0
 public UserType(UserGroupFacade userGroupFacade, UserMarkFacade userMarkFacade, UserRoleFacade userRoleFacade,
                 GroupFacade groupFacade, GroupSubjectFacade groupSubjectFacade)
 {
     Field(x => x.Id);
     Field <StringGraphType>("login",
                             resolve: context => context.Source.Login);
     Field <StringGraphType>("password",
                             resolve: context => context.Source.Password);
     Field <StringGraphType>("firstName",
                             resolve: context => context.Source.FirstName);
     Field <StringGraphType>("lastName",
                             resolve: context => context.Source.LastName);
     Field <StringGraphType>("secondName",
                             resolve: context => context.Source.SecondName);
     Field <ListGraphType <GroupType> >("group",
                                        resolve: context => {
         return(userGroupFacade.GetByUserId(context.Source.Id, groupFacade));
     }
                                        );
     Field <ListGraphType <UserMarkType> >("userMarks",
                                           resolve: context => userMarkFacade.GetByUserId(context.Source.Id)
                                           );
     Field <UserMarkType>("userMark",
                          arguments: new QueryArguments(new QueryArgument <IntGraphType> {
         Name = "id"
     }),
                          resolve: context => userMarkFacade.GetById(context.GetArgument <int>("id")));
     Field <UserRoleType>(
         "userRole",
         resolve: context => userRoleFacade.GetById(context.Source.UserRoleId)
         );
 }
Esempio n. 3
0
        private bool ValidateUserPreservesAdminRights(IUserGroup userGroup, List <string> newUserGroupEntityTokens)
        {
            string systemPerspectiveEntityToken = EntityTokenSerializer.Serialize(AttachingPoint.SystemPerspective.EntityToken);

            Guid   groupId  = userGroup.Id;
            string userName = UserSettings.Username;

            var userGroupIds = UserGroupFacade.GetUserGroupIds(userName);

            HashSet <Guid> groupsWithAccessToSystemPerspective = new HashSet <Guid>(GetGroupsThatHasAccessToPerspective(systemPerspectiveEntityToken));

            if (groupsWithAccessToSystemPerspective.Contains(groupId) &&
                !newUserGroupEntityTokens.Contains(systemPerspectiveEntityToken) &&
                !UserPerspectiveFacade.GetSerializedEntityTokens(userName).Contains(systemPerspectiveEntityToken) &&
                !userGroupIds.Any(anotherGroupId => anotherGroupId != groupId && groupsWithAccessToSystemPerspective.Contains(anotherGroupId)))
            {
                this.ShowMessage(DialogType.Message,
                                 SR.GetString("Composite.Management", "EditUserWorkflow.EditErrorTitle"),
                                 SR.GetString("Composite.Management", "EditUserWorkflow.EditOwnAccessToSystemPerspective"));

                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        public Mutations(MarkFacade markFacade, UserFacade userFacade, GroupFacade groupFacade,
                         GroupSubjectFacade groupSubjectFacade, NotificationFacade notificationFacade,
                         NotificationStudentFacade notificationStudentFacade, SubjectFacade subjectFacade,
                         UserGroupFacade userGroupFacade, UserMarkFacade userMarkFacade, UserRoleFacade userRoleFacade)
        {
            AddMarkMutations(markFacade);

            AddUserMutations(userFacade, userRoleFacade, userGroupFacade, groupFacade);

            AddGroupMutations(groupFacade);

            AddGroupSubjectMutations(groupSubjectFacade, userFacade);

            AddNotificationMutations(notificationFacade, groupFacade, notificationStudentFacade);

            AddNotificationStudentMutations(notificationStudentFacade);

            AddSubjectMutations(subjectFacade);

            AddUserGroupMutations(userGroupFacade);

            AddUserMarkMutations(userMarkFacade);

            AddUserRoleMutations(userRoleFacade);
        }
Esempio n. 5
0
        public Queries(MarkFacade markFacade, UserFacade userFacade, GroupFacade groupFacade,
                       GroupSubjectFacade groupSubjectFacade, NotificationFacade notificationFacade,
                       NotificationStudentFacade notificationStudentFacade, SubjectFacade subjectFacade,
                       UserGroupFacade userGroupFacade, UserMarkFacade userMarkFacade, UserRoleFacade userRoleFacade)
        {
            AddMarkQueries(markFacade);

            AddUserQueries(userFacade, userRoleFacade);

            AddGroupQueries(groupFacade);

            AddGroupSubjectQueries(groupSubjectFacade, subjectFacade, userFacade);

            AddNotificationQueries(notificationFacade);

            AddNotificationStudentQueries(notificationStudentFacade);

            AddSubjectQueries(subjectFacade);

            AddUserGroupQueries(userGroupFacade);

            AddUserMarkQueries(userMarkFacade);

            AddUserRoleQueries(userRoleFacade);

            AddAuthorizeQueries(userFacade, userRoleFacade);
        }
Esempio n. 6
0
        private void AddUserGroupQueries(UserGroupFacade userGroupFacade)
        {
            Field <ListGraphType <UserGroupType> >(
                "allUserGroups",
                resolve: context => userGroupFacade.GetAll()
                );

            Field <UserGroupType>("userGroup",
                                  arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                                  resolve: context => {
                var id = context.GetArgument <int?>("id");

                return(id != null ? (userGroupFacade.GetById((int)id)) : null);
            }
                                  );
        }
Esempio n. 7
0
        /// <summary>
        /// Filtering search results to which the given user does not have read access permission.
        /// </summary>
        /// <param name="userName"></param>
        public void FilterByUser(string userName)
        {
            Verify.ArgumentNotNullOrEmpty(userName, nameof(userName));

            var tokens = new List <string> {
                userName
            };

            using (ThreadDataManager.EnsureInitialize())
            {
                tokens.AddRange(UserGroupFacade.GetUserGroupIds(userName).Select(id => id.ToString()));
            }

            Selection.Add(new SearchQuerySelection
            {
                FieldName = DocumentFieldNames.ConsoleAccess,
                Operation = SearchQuerySelectionOperation.Or,
                Values    = tokens.ToArray()
            });
        }
Esempio n. 8
0
 private void AddUserGroupMutations(UserGroupFacade userGroupFacade)
 {
 }
Esempio n. 9
0
        private void AddUserMutations(UserFacade userFacade, UserRoleFacade userRoleFacade,
                                      UserGroupFacade userGroupFacade, GroupFacade groupFacade)
        {
            User ParseUser(User user)
            {
                user.UserRole = userRoleFacade.GetAll().SingleOrDefault(x => x.RoleName == "Student");
                return(user);
            }

            Field <UserType>("addUser",
                             arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "groupId"
            },
                                                           new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "userId"
            },
                                                           new QueryArgument <NonNullGraphType <UserInputType> > {
                Name = "user"
            }),
                             resolve: context => {
                var user    = ParseUser(context.GetArgument <User>("user"));
                var groupId = context.GetArgument <int>("groupId");
                if (user.FirstName == null || user.LastName == null || user.Login == null ||
                    user.Password == null)
                {
                    throw new ArgumentException();
                }

                if (userFacade.GetByLogin(user.Login) != null)
                {
                    return(null);
                }

                user.UserRoleId = userRoleFacade.GetByName("Студент").Id;

                user = userFacade.Add(user);

                UserGroup userGroup = new UserGroup {
                    User = user, Group = groupFacade.GetById(groupId)
                };

                userGroupFacade.Add(userGroup);

                return(user);
            }
                             );

            Field <UserType>("deleteUser",
                             arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "userId"
            },
                                                           new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "deleteId"
            }),
                             resolve: context => {
                var deleteUser = userFacade.GetById(context.GetArgument <int>("deleteId"));
                userGroupFacade.Delete(userGroupFacade.GetUserGroupByUserId(deleteUser.Id));
                return(userFacade.Delete(deleteUser));
            }
                             );

            Field <UserType>("editUser",
                             arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "userId"
            },
                                                           new QueryArgument <NonNullGraphType <UserInputType> > {
                Name = "user"
            },
                                                           new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "editId"
            }),
                             resolve: context => {
                var editId = context.GetArgument <int>("editId");
                var user   = ParseUser(context.GetArgument <User>("user"));
                return(userFacade.Edit(editId, user));
            }
                             );
        }
Esempio n. 10
0
 /// <exclude />
 public static IEnumerable <CultureInfo> GetActiveLocaleCultureInfos(string username, bool includeGroupAssignedCultures = true)
 {
     return(includeGroupAssignedCultures ?
            _implementation.GetActiveLocaleCultureInfos(username).Union(UserGroupFacade.GetUserGroupActiveCultures(username)) :
            _implementation.GetActiveLocaleCultureInfos(username));
 }