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); }
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); }
private void AddNotificationStudentQueries(NotificationStudentFacade notificationStudentFacade) { Field <ListGraphType <NotificationStudentType> >( "allNotificationStudents", resolve: context => notificationStudentFacade.GetAll() ); Field <NotificationStudentType>("notificationStudent", arguments: new QueryArguments(new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <int?>("id"); return(id != null ? (notificationStudentFacade.GetById((int)id)) : null); } ); }
public NotificationType(NotificationStudentFacade notificationStudentFacade, GroupFacade groupFacade) { Field(x => x.Id); Field <StringGraphType>("message", resolve: context => context.Source.Message); Field <GroupType>("group", resolve: context => groupFacade.GetById(context.Source.GroupId) ); Field <ListGraphType <NotificationStudentType> >( "notificationStudents", resolve: context => notificationStudentFacade.GetByNotificationId(context.Source.Id)); Field <NotificationStudentType>("notificationStudent", arguments: new QueryArguments(new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => notificationStudentFacade.GetById(context.GetArgument <int>("id"))); }
private void AddNotificationStudentMutations(NotificationStudentFacade notificationStudentFacade) { }
private void AddNotificationMutations(NotificationFacade notificationFacade, GroupFacade groupFacade, NotificationStudentFacade notificationStudentFacade) { Field <NotificationType>("addNotification", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <NotificationInputType> > { Name = "notification" }), resolve: context => { var notification = context.GetArgument <Notification>("notification"); notification.Group = groupFacade.GetById(notification.GroupId); return(notificationFacade.Add(notification));; } ); Field <NotificationType>("deleteNotification", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "notificationId" }), resolve: context => { var notificationId = context.GetArgument <int>("notificationId"); Notification notification = notificationFacade.GetById(notificationId); notificationStudentFacade.DeleteByNotification(notification); return(notificationFacade.Delete(notification)); } ); Field <ListGraphType <NotificationType> >("notificationsForStudent", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "studentId" }, new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "groupId" } ), resolve: context => { var groupId = context.GetArgument <int>("groupId"); var studentId = context.GetArgument <int>("studentId"); IEnumerable <Notification> notifications = notificationFacade.GetByGroupId(groupId); List <Notification> notificationList = new List <Notification>(); foreach (var notification in notifications) { if (!notificationStudentFacade.getByUserIdAndNotificationId(studentId, notification.Id)) { notificationList.Add(notification); notificationStudentFacade.Add(new NotificationStudent { NotificationId = notification.Id, StudentId = studentId }); } } return(notificationList); } ); }