Example #1
0
        public GraphQLQuery(ContextServiceLocator contextServiceLocator)
        {
            Field <PlayerType>(
                "player",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context => contextServiceLocator.PlayerRepository.Get(context.GetArgument <int>("id")));

            Field <PlayerType>(
                "randomPlayer",
                resolve: context => contextServiceLocator.PlayerRepository.GetRandom());

            Field <ListGraphType <PlayerType> >(
                "allplayers",
                resolve: context => contextServiceLocator.PlayerRepository.All());

            Field <PagingType>(
                "players",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "num"
            }, new QueryArgument <IntGraphType> {
                Name = "limit"
            }),
                resolve: context => contextServiceLocator.PlayerRepository.Paging(context.GetArgument <int>("num"), context.GetArgument <int>("limit")));
        }
 public EmployeePaginateType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.TotalPages);
     Field(x => x.TotalRecords);
     Field(x => x.Error);
     FieldAsync <ListGraphType <EmployeeType> >("results",
                                                arguments: new QueryArguments(new List <QueryArgument>
     {
         new QueryArgument <NonNullGraphType <IntGraphType> >
         {
             Name = "pageSize"
         },
         new QueryArgument <NonNullGraphType <IntGraphType> >
         {
             Name = "page"
         },
         new QueryArgument <StringGraphType>
         {
             Name         = "filter",
             Description  = "Filter for Name and IdentificationNumber",
             DefaultValue = null
         }
     }),
                                                resolve: async context =>
     {
         return(await new EmployeeBL(contextServiceLocator.employeeRepository)
                .GetAll(
                    pageSize: context.GetArgument <int?>("pageSize").Value,
                    page: context.GetArgument <int?>("page").Value,
                    filter: context.GetArgument <string>("filter")));
     }
                                                );
 }
Example #3
0
        public EventBookingQuery(ContextServiceLocator serviceLocator)
        {
            this.AuthorizeWith("IsAdmin");
            Field <ListGraphType <UserGraphType> >(
                "users",
                resolve: context => serviceLocator.UserService.All());//.AuthorizeWith("IsAdmin");

            Field <AuthDataGraphType>(
                "login",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <LoginInputGraphType> > {
                Name = "login"
            }),
                resolve: context =>
            {
                var cred = context.GetArgument <LoginCredential>("login");
                return(serviceLocator.UserService.Login(cred.email, cred.password));
            });

            Field <ListGraphType <EventGraphType> >(
                "events",
                resolve: context => serviceLocator.EventService.All());

            Field <ListGraphType <BookingGraphType> >(
                "bookings",
                resolve: context => serviceLocator.EventService.GetAllBookings());
        }
Example #4
0
 public ClienteType(ContextServiceLocator contextServiceLocator)
 {
     Name = "Cliente";
     Field(x => x.Id, false);
     Field(x => x.Nome, false);
     Field(x => x.Identidade, false);
 }
        public StationObject(ContextServiceLocator contextServiceLocator)
        {
            Name = "Station";
            // Description = "";

            Field(x => x.Id);
            Field(x => x.Name);
            Field(x => x.Altitude);
            Field(x => x.City);
            //Field<CountryObject>(
            //    "country",
            //    resolve: ctx => contextServiceLocator.CountryRepository.GetOne(ctx.Source.CountryCode),
            //    description: "Country in which the wheather station is located."
            //);
            Field(x => x.Latitude);
            Field(x => x.Longitude);
            Field(x => x.Timezone);
            Field(x => x.StaticMap);
            Field <ListGraphType <DeviceUnion> >(
                "devices",
                arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            }),
                resolve: ctx => contextServiceLocator.DeviceRepository.GetAll(ctx.Source.Id)
                );
        }
Example #6
0
 public JobType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.Title);
     Field(x => x.VacancyUrl);
     Field(x => x.CompanyName);
     Field(x => x.Description);
 }
Example #7
0
        public ProductQuery(ContextServiceLocator contextServiceLocator)
        {
            Name = "productQuery";

            FieldAsync<ListGraphType<ProductType>>("productList",
                arguments: new QueryArguments(
                    new QueryArgument<StringGraphType> {Name = "name"},
                    new QueryArgument<StringGraphType> {Name = "description"},
                    new QueryArgument<IntGraphType> {Name = "quantity"}),
                resolve: async context =>
                {
                    var name = context.GetArgument<string>("name");
                    var description = context.GetArgument<string>("description");
                    var quantity = context.GetArgument<int?>("quantity");
                    var query = contextServiceLocator.ProductRepository.GetQuery();

                    if (!string.IsNullOrEmpty(name)) query = query.Where(q => q.Name == name);
                    if (!string.IsNullOrEmpty(description)) query = query.Where(q => q.Description == description);
                    if (quantity.HasValue) query = query.Where(q => q.Quantity == quantity);

                    var results = await query.ToListAsync();
                    return results;
                });

            FieldAsync<ProductType>("product",
                arguments: new QueryArguments(new QueryArgument<StringGraphType> {Name = "id"}),
                resolve: async context => await contextServiceLocator.ProductRepository.Get(context.GetArgument<string>("id")));
        }
Example #8
0
        public NHLStatsQuery(ContextServiceLocator contextServiceLocator)
        {
            Field <PlayerType>(
                "player",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context => contextServiceLocator.PlayerRepository.Get(context.GetArgument <int>("id")));

            Field <PlayerType>(
                "playerByWeight",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "weight"
            }),
                resolve: context => contextServiceLocator.PlayerRepository.GetByWeight(context.GetArgument <int>("weight")));


            Field <PlayerType>(
                "randomPlayer",
                resolve: context => contextServiceLocator.PlayerRepository.GetRandom());

            Field <ListGraphType <PlayerType> >(
                "players",
                resolve: context => contextServiceLocator.PlayerRepository.All());
        }
Example #9
0
        public PokemonTypeType(ContextServiceLocator ContextServiceLocator)
        {
            Name = "PokemonType";

            Field<StringGraphType>("id", resolve: context => context.Source.Id.ToString());
            Field(x => x.Name);
        }
        public FullStackJobsQuery(ContextServiceLocator contextServiceLocator)
        {
            FieldAsync <JobType>("job",
                                 arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                                 // Extract the user id from the name claim to fetch the target employer's job
                                 resolve: async context => await contextServiceLocator.JobRepository.GetSingleBySpec(new JobSpecification(j => j.Id == context.GetArgument <int>("id", default))));

            FieldAsync <ListGraphType <JobSummaryType> >("employerJobs",
                                                         resolve: async context =>
            {
                // Extract the user id from the name claim to fetch the target employer's jobs
                var jobs = await contextServiceLocator.JobRepository.List(new JobSpecification(j => j.Employer.Id == context.GetUserId()));
                return(jobs.OrderByDescending(j => j.Modified));
            });

            FieldAsync <ListGraphType <JobSummaryType> >("publicJobs",
                                                         resolve: async context =>
            {
                // Fetch published Jobs from all employers
                var jobs = await contextServiceLocator.JobRepository.List(new JobSpecification(j => j.Status == Status.Published));
                return(jobs.OrderByDescending(j => j.Modified));
            });
        }
Example #11
0
        public ImageQuery(ContextServiceLocator locator)
        {
            // Name = "Images";

            // FieldAsync<ListGraphType<ImageType>>(
            //     name: "getImages",
            //     description: "All Images",
            //     resolve: async context => await locator.ImageRepository.GetImagesAsync()
            // );

            // FieldAsync<ImageType>(
            //     name: "getImage",
            //     description: "A single image",
            //     arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "imageId", Description = "The Image's Id" }),
            //     resolve: async context =>
            //     {
            //         var id = context.GetArgument<int>("imageId");
            //         var image = await locator.ImageRepository.GetImageAsync(id);
            //         return image;
            //     }
            // );

            // FieldAsync<ListGraphType<ImageType>>(
            //     name: "getImagesForUser",
            //     description: "All Images for a User",
            //     arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "userId", Description = "The User's Id" }),
            //     resolve: async context =>
            //     {
            //         var userId = context.GetArgument<int>("userId");
            //         var images = await locator.ImageRepository.GetUserImages(userId);
            //         return images;
            //     }
            // );
        }
Example #12
0
 public ContaOperacaoOutputType(ContextServiceLocator contextServiceLocator)
 {
     //Name = "ContaOperacao";
     Field(x => x.Cliente.Nome, true).Name("cliente");
     Field(x => x.Conta.NumeroConta, true).Name("conta");
     Field(x => x.Valor, true).Name("saldo");
 }
 public PromoType(ContextServiceLocator contextServiceLocator, DiscountPromoType discountPromoType, SpecialPrizePromoType specialPrizePromoType)
 {
     Field("id", x => x.Id, type: typeof(IdGraphType));
     Field(x => x.Title);
     Field(x => x.Conditions);
     Field("providerId", x => x.Provider.Id, type: typeof(IdGraphType));
     Field("providerName", x => x.Provider.Name);
 }
Example #14
0
        public BadgeType(ContextServiceLocator contextServiceLocator)
        {
            Name = "Badge";

            Field <StringGraphType>("id", resolve: context => context.Source.Id.ToString());
            Field(x => x.Name);
            Field(x => x.ImageUrl);
        }
Example #15
0
 public StaffSectionAssociationType(ContextServiceLocator contextServiceLocator)
 {
     Field <SectionType>("section",
                         arguments: new QueryArguments(new QueryArgument <StringGraphType> {
         Name = "sectionkey"
     }),
                         resolve: context => contextServiceLocator.SectionRepository.Get(context.Source.SectionKey), description: "Section");
 }
        public ModelQuery(ContextServiceLocator locator)
        {
            Name = "Query";

            Field <TestGraphQlModel>("PlaceholderEntity", resolve: context => new PlaceholderEntity
            {
                Id = 1
            });
        }
 public BookingGraphType(ContextServiceLocator serviceLocator)
 {
     Field(x => x.bookingId);
     Field <UserGraphType>("user", resolve: context => serviceLocator.UserService.FindById(context.Source.user));
     Field <EventGraphType>("event",
                            resolve: context => serviceLocator.EventService.FindById(context.Source.@event));
     Field <DateTimeGraphType>("createdAt", resolve: context => context.Source.createdAt);
     Field <DateTimeGraphType>("updatedAt", resolve: context => context.Source.updatedAt);
 }
Example #18
0
 public EmployeePlatformMutation(ContextServiceLocator contextServiceLocator, JwtSecurityTokenHandler jwtSecurityTokenHandler)
 {
     FieldAsync <EmployeeType>(
         "createEmployee",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <EmployeeTypeInput> > {
         Name = "input"
     }),
         resolve: async context =>
     {
         EmployeeDTO entity = context.GetArgument <EmployeeDTO>("input");
         entity.CreatedAt   = DateTime.Now;
         entity.ModifiedAt  = DateTime.Now;
         var userContext    = context.UserContext;
         entity.CreatedBy   = entity.FirstName;
         entity.ModifiedBy  = entity.FirstName;
         return(await new EmployeeBL(contextServiceLocator.employeeRepository).Add(entity));
     });
     //.AuthorizeWith(Policies.Admin);
     FieldAsync <EmployeeType>(
         "updateEmployee",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <EmployeeTypeUpdateInput> > {
         Name = "input"
     }),
         resolve: async context =>
     {
         EmployeeDTO entity = context.GetArgument <EmployeeDTO>("input");
         entity.ModifiedAt  = DateTime.Now;
         entity.ModifiedBy  = entity.FirstName;
         return(await new EmployeeBL(contextServiceLocator.employeeRepository).Update(entity));
     });
     //.AuthorizeWith(Policies.Admin);
     FieldAsync <UserType>(
         "signup",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <SignupTypeInput> > {
         Name = "input"
     }),
         resolve: async context =>
     {
         UserDTO entity    = context.GetArgument <UserDTO>("input");
         entity.CreatedAt  = DateTime.Now;
         entity.ModifiedAt = DateTime.Now;
         entity.CreatedBy  = entity.FirstName;
         entity.ModifiedBy = entity.FirstName;
         entity.Password   = BCrypt.Net.BCrypt.HashPassword(entity.Password);
         return(await new UserBL(contextServiceLocator.userRepository).Add(entity));
     }).AuthorizeWith(Policies.Admin);
     FieldAsync <UserResponseAuthenticateType>(
         "login",
         arguments: new QueryArguments(new QueryArgument <NonNullGraphType <LoginTypeInput> > {
         Name = "input"
     }),
         resolve: async context =>
     {
         UserDTO entity = context.GetArgument <UserDTO>("input");
         return(await new Auth().Authenticate(entity, jwtSecurityTokenHandler, contextServiceLocator.userRepository));
     });
 }
Example #19
0
 public ContaOperacaoType(ContextServiceLocator contextServiceLocator)
 {
     Name = "ContaOperacao";
     Field(x => x.Cliente.Nome).Name("cliente");
     Field(x => x.Conta.NumeroConta).Name("conta");
     Field(x => x.TipoOperacao);
     Field(x => x.Valor);
     Field(x => x.DataOperacao);
 }
Example #20
0
 public ItemType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.ItemId);
     Field(x => x.ReceiptId, true);
     Field(x => x.ProductCategory);
     Field(x => x.CO2Impact);
     Field(x => x.Price);
     Field(x => x.QRCode);
 }
Example #21
0
 public RobotType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.Id);
     Field(x => x.Name);
     Field(x => x.Image);
     Field(x => x.Favourite);
     Field(x => x.Score);
     Field(x => x.Categories);
 }
Example #22
0
 public SectionType(ContextServiceLocator contextServiceLocator)
 {
     Field("sectionkey", x => x.SectionKey);
     Field("schoolkey", x => x.SchoolKey);
     Field("localcoursecode", x => x.LocalCourseCode);
     Field("sessionname", x => x.SessionName);
     Field("sectionidentifier", x => x.SectionIdentifier);
     Field("schoolyear", x => x.SchoolYear);
 }
Example #23
0
        public PokemonType(ContextServiceLocator ContextServiceLocator)
        {
            Name = "Pokemon";

            Field <StringGraphType>("id", resolve: context => context.Source.Id.ToString());
            Field(x => x.Name);
            Field(x => x.PokedexNumber);
            Field(x => x.SpriteImageUrl);
            Field(x => x.PogoImageUrl);
        }
 public ProductCategoryType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.Id);
     Field(x => x.Name, true);
     Field <ListGraphType <ProductType> >("products",
                                          arguments: new QueryArguments(new QueryArgument <IntGraphType> {
         Name = "id"
     }),
                                          resolve: context => contextServiceLocator.ProductRepository.Get(context.Source.Id), description: "Products");
 }
Example #25
0
 public UserType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.UserId);
     Field(x => x.Email, true);
     Field(x => x.FirstName);
     Field(x => x.LastName);
     Field(x => x.RewardsTotal);
     Field(x => x.AccountLimit);
     Field(x => x.AccountNumber);
 }
Example #26
0
        public NHLStatsMutation(ContextServiceLocator contextServiceLocator)
        {
            Name = "PlayerMutation";

            Field <PlayerType>(
                "createPlayer",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <PlayerInputType> > {
                Name = "player"
            }
                    ),
                resolve: context =>
            {
                var player = context.GetArgument <Player>("player");
                return(contextServiceLocator.PlayerRepository.Add(player));
            });

            Field <PlayerType>(
                "updatePlayer",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <PlayerInputType> > {
                Name = "player"
            }
                    ),
                resolve: context =>
            {
                var player = context.GetArgument <Player>("player");
                var item   = contextServiceLocator.PlayerRepository.Update(player);
                if (item == null)
                {
                    context.Errors.Add(new GraphQL.ExecutionError($"Player: {player.Name} not found."));
                }
                return(item);
            });

            Field <PlayerType>(
                "deletePlayer",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }
                    ),
                resolve: context =>
            {
                var id     = context.GetArgument <int>("id");
                var result = contextServiceLocator.PlayerRepository.Delete(id);
                if (result.Result)
                {
                    return($"The player with the id: {id} has been successfully deleted.");
                }

                context.Errors.Add(new GraphQL.ExecutionError($"Player id: {id} not found."));
                return(null);
            });
        }
Example #27
0
 public JobSummaryType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.Id);
     Field(x => x.Position);
     Field(x => x.Company, true);
     Field(x => x.Icon);
     Field(x => x.Location, true);
     Field <EnumerationGraphType <Status> >("status");
     Field <StringGraphType>("modified", resolve: context => contextServiceLocator.Humanizer.TimeAgo(context.Source.Modified ?? context.Source.Created));
     Field <IntGraphType>("applicantCount", resolve: context => context.Source.JobApplicants.Count);
 }
 public EventGraphType(ContextServiceLocator serviceLocator)
 {
     Field(x => x.eventId);
     Field(x => x.title);
     Field(x => x.description);
     Field <DecimalGraphType>("price", resolve: context => context.Source.price);
     Field <DateGraphType>("date", resolve: context => context.Source.date);
     Field <UserGraphType>(
         "creator",
         resolve: context => serviceLocator.UserService.FindById(context.Source.creatorId));
 }
 public TransactionType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.TransactionId);
     Field(x => x.Date);
     Field(x => x.Location);
     Field(x => x.Amount);
     Field(x => x.HaveReceipt);
     Field <ReceiptType>(
         "receipt",
         resolve: x => contextServiceLocator.ReceiptRepository.Get(x.Source.TransactionId));
 }
Example #30
0
 public ReceiptType(ContextServiceLocator contextServiceLocator)
 {
     Field(x => x.ReceiptId);
     Field(x => x.TransactionId, true);
     Field(x => x.ReceiptCode);
     Field(x => x.Rewards);
     Field(x => x.Company);
     Field(x => x.CO2Impact);
     Field <ListGraphType <ItemType> >(
         "items",
         resolve: x => contextServiceLocator.ItemRepository.Get(x.Source.TransactionId));
 }