Beispiel #1
0
 public GamesessionType(
     IAlternativesRepository <Inheritance> inheritanceRepository,
     IAlternativesRepository <Road> roadRepository,
     IAlternativesRepository <Livingcondition> livingconditionRepository)
 {
     Field(_ => _.Id);
     Field(_ => _.OwnerId);
     Field(_ => _.UserIds, type: typeof(ListGraphType <StringGraphType>));
     Field(_ => _.GamemasterId);
     Field(_ => _.PlayerIds, type: typeof(ListGraphType <StringGraphType>));
     Field(_ => _.Name);
     FieldAsync <ListGraphType <InheritanceType>, List <Inheritance> >(
         "inheritances",
         resolve: async context =>
     {
         return(await inheritanceRepository.GetAsync(context.Source.Id));
     }
         );
     FieldAsync <ListGraphType <RoadType>, List <Road> >(
         "roads",
         resolve: async context =>
     {
         return(await roadRepository.GetAsync(context.Source.Id));
     }
         );
     FieldAsync <ListGraphType <LivingconditionType>, List <Livingcondition> >(
         "livingconditions",
         resolve: async context =>
     {
         return(await livingconditionRepository.GetAsync(context.Source.Id));
     }
         );
 }
Beispiel #2
0
 public RootMutations(
     ISubscriptionService <Building> buildingSubscriptionService,
     ISubscriptionService <Gamesession> gamesessionSubscriptionService,
     IAlternativesRepository <Inheritance> inheritancesRepository,
     IAlternativesRepository <Road> roadsRepository,
     IAlternativesRepository <Livingcondition> livingconditionsRepository
     )
 {
     AddBuildingFields(buildingSubscriptionService);
     AddGamesessionFields(gamesessionSubscriptionService, inheritancesRepository, roadsRepository, livingconditionsRepository);
 }
Beispiel #3
0
 partial void AddGamesessionFields(
     ISubscriptionService <Gamesession> gamesessionSubscriptionService,
     IAlternativesRepository <Inheritance> inheritancesRepository,
     IAlternativesRepository <Road> roadsRepository,
     IAlternativesRepository <Livingcondition> livingconditionsRepository
     );
Beispiel #4
0
        partial void AddGamesessionFields(
            ISubscriptionService <Gamesession> subscriptionService,
            IAlternativesRepository <Inheritance> inheritancesRepository,
            IAlternativesRepository <Road> roadsRepository,
            IAlternativesRepository <Livingcondition> livingconditionsRepository
            )
        {
            FieldAsync <MutationResponseType <Gamesession, GamesessionType> >(
                "addGamesession",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "userId"
            }
                    ),
                resolve: async context =>
            {
                var userId      = context.GetArgument <string>("userId");
                var gamesession = new Gamesession
                {
                    OwnerId = userId
                };

                gamesession.UserIds.Add(userId);
                //gamesession.Roads = await roadsRepository.GetAsync(gamesession.Id);
                //gamesession.Inheritances = await inheritancesRepository.GetAsync(gamesession.Id);
                //gamesession.Livingconditions = await livingconditionsRepository.GetAsync(gamesession.Id);

                return(await subscriptionService.Add(gamesession));
            }
                );

            FieldAsync <MutationResponseType <Gamesession, GamesessionType> >(
                "updateGamesession",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <GamesessionInputType> > {
                Name = "gamesession"
            }
                    ),
                resolve: async context =>
            {
                return(await subscriptionService.Update(
                           context.GetArgument <Gamesession>("gamesession")
                           ));
            }
                );

            FieldAsync <MutationResponseType <Gamesession, GamesessionType> >(
                "deleteGamesession",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <GuidGraphType> > {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                return(await subscriptionService.Delete(
                           context.GetArgument <Guid>("id")
                           ));
            }
                );
        }