示例#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")));
 }
示例#2
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);
            }
                                  );
        }