public TimeReportType(TimeReportRepository repository)
 {
     Name = "TimeReport";
     Field(x => x.Id);
     Field(x => x.Hours);
     Field(x => x.date);
     Field <UserType>(
         "user",
         resolve: context => repository.User(context.Source.UserId)
         );
     Field <ProjectType>(
         "project",
         resolve: context => repository.Project(context.Source.ProyectId)
         );
 }
Exemple #2
0
 public ProjectMutation(ProjectRepository project, UserRepository repository, ProjectUserRepository userProjectRepositorie, TimeReportRepository timeReportRepository, IHttpContextAccessor accessor)
 {
     Field <ProjectType>("createProject",
                         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <ProjectInputType> > {
         Name = "input"
     }),
                         resolve: context => project.Create(context.GetArgument <Project>("input"), accessor.HttpContext)
                         );
     Field <UserType>("createUser",
                      arguments: new QueryArguments(new QueryArgument <NonNullGraphType <UserInputType> > {
         Name = "input"
     }),
                      resolve: context => repository.Create(context.GetArgument <User>("input"), accessor.HttpContext)
                      );
     Field <ProjectUserType>("createProjectUser",
                             arguments: new QueryArguments(new QueryArgument <NonNullGraphType <ProjectUserInputType> > {
         Name = "input"
     }),
                             resolve: context => userProjectRepositorie.Create(context.GetArgument <ProjectUser>("input"), accessor.HttpContext)
                             );
     Field <ProjectType>("addUser",
                         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <ProjectUserInputType> > {
         Name = "input"
     }),
                         resolve: context => project.addUser(context.GetArgument <ProjectUser>("input"), accessor.HttpContext)
                         );
     Field <TimeReportType>("createTimeReport",
                            arguments: new QueryArguments(new QueryArgument <NonNullGraphType <TimeReportInputType> > {
         Name = "input"
     }),
                            resolve: context => timeReportRepository.Create(context.GetArgument <TimeReport>("input"), accessor.HttpContext)
                            );
     Field <ProjectType>("updateProject",
                         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <ProjectInputType> > {
         Name = "input"
     }, new QueryArgument <NonNullGraphType <IntGraphType> > {
         Name = "id"
     }),
                         resolve: context => project.update(context.GetArgument <int>("id"), context.GetArgument <Project>("input"), accessor.HttpContext)
                         );
     Field <ProjectType>("deleteUserFromProject",
                         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <ProjectUserInputType> > {
         Name = "input"
     }),
                         resolve: context => project.deleteUser(context.GetArgument <ProjectUser>("input"), accessor.HttpContext)
                         );
     Field <UserType>("deleteUser",
                      arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
         Name = "input"
     }),
                      resolve: context => repository.deleteUser(context.GetArgument <int>("input"), accessor.HttpContext)
                      );
     Field <ProjectType>("deleteProject",
                         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
         Name = "input"
     }),
                         resolve: context => project.deleteProject(context.GetArgument <int>("input"), accessor.HttpContext)
                         );
 }
Exemple #3
0
 public ProjectQuery(ProjectRepository projectRepository, UserRepository userRepository, TimeReportRepository timeReportRepository, IHttpContextAccessor accessor)
 {
     Field <ListGraphType <ProjectType> >("projects",
                                          arguments: new QueryArguments(
                                              new QueryArgument <IntGraphType> {
         Name = "id"
     },
                                              new QueryArgument <StringGraphType> {
         Name = "description"
     },
                                              new QueryArgument <StringGraphType> {
         Name = "name"
     }
                                              ),
                                          resolve: context => projectRepository.filter(context, accessor.HttpContext)
                                          );
     Field <ListGraphType <UserType> >("users",
                                       arguments: new QueryArguments(
                                           new QueryArgument <IntGraphType> {
         Name = "id"
     }
                                           ),
                                       resolve: context => userRepository.filter(context, accessor.HttpContext)
                                       );
     Field <ListGraphType <TimeReportType> >("timeReports",
                                             arguments: new QueryArguments(
                                                 new QueryArgument <IntGraphType> {
         Name = "id"
     }
                                                 ),
                                             resolve: context => timeReportRepository.filter(context, accessor.HttpContext)
                                             );
     Field <StringGraphType>("projectReport",
                             arguments: new QueryArguments(
                                 new QueryArgument <NonNullGraphType <IntGraphType> > {
         Name = "id"
     },
                                 new QueryArgument <StringGraphType> {
         Name = "initialDate"
     },
                                 new QueryArgument <StringGraphType> {
         Name = "endDate"
     }
                                 ),
                             resolve: context => projectRepository.CSV(context, accessor.HttpContext)
                             );
     Field <StringGraphType>("projectReportPDF",
                             arguments: new QueryArguments(
                                 new QueryArgument <NonNullGraphType <IntGraphType> > {
         Name = "id"
     },
                                 new QueryArgument <StringGraphType> {
         Name = "initialDate"
     },
                                 new QueryArgument <StringGraphType> {
         Name = "endDate"
     }
                                 ),
                             resolve: context => projectRepository.PDF(context, accessor.HttpContext)
                             );
     Field <StringGraphType>("userReport",
                             arguments: new QueryArguments(
                                 new QueryArgument <NonNullGraphType <IntGraphType> > {
         Name = "id"
     },
                                 new QueryArgument <StringGraphType> {
         Name = "initialDate"
     },
                                 new QueryArgument <StringGraphType> {
         Name = "endDate"
     }
                                 ),
                             resolve: context => userRepository.CSV(context, accessor.HttpContext)
                             );
     Field <StringGraphType>("userReportPDF",
                             arguments: new QueryArguments(
                                 new QueryArgument <NonNullGraphType <IntGraphType> > {
         Name = "id"
     },
                                 new QueryArgument <StringGraphType> {
         Name = "inicialDate"
     },
                                 new QueryArgument <StringGraphType> {
         Name = "endDate"
     }
                                 ),
                             resolve: context => userRepository.PDF(context, accessor.HttpContext)
                             );
     Field <UserType>("login",
                      arguments: new QueryArguments(
                          new QueryArgument <NonNullGraphType <StringGraphType> > {
         Name = "name"
     },
                          new QueryArgument <NonNullGraphType <StringGraphType> > {
         Name = "password"
     }
                          ),
                      resolve: context => userRepository.login(context.GetArgument <string>("name"), context.GetArgument <string>("password"))
                      );
 }