public BreakType(PlayerRepository playerRepository, FrameRepository frameRepository) { Field(x => x.Id, type: typeof(IdGraphType)); Field(x => x.Score); Field(x => x.PlayerId, type: typeof(IdGraphType)); Field <PlayerType>( "player", resolve: context => playerRepository.GetById(context.Source.PlayerId) ); Field(x => x.FrameId, type: typeof(IdGraphType)); Field <FrameType>( "frame", resolve: context => frameRepository.GetById(context.Source.FrameId) ); }
public FrameType( FrameRepository frameRepository, TournamentRepository tournamentRepository, GroupRepository groupRepository, PlayerRepository playerRepository ) { Field(x => x.Id, type: typeof(IdGraphType)); Field(x => x.StartDate, type: typeof(DateTimeGraphType)); Field(x => x.EndDate, type: typeof(DateTimeGraphType)); Field(x => x.TournamentPhase, type: typeof(IntGraphType), nullable: true); Field(x => x.TournamentId, type: typeof(IdGraphType), nullable: true); Field <TournamentType>( "tournament", resolve: context => { if (context.Source.TournamentId != null) { return(tournamentRepository.GetById((Guid)context.Source.TournamentId)); } return(null); } ); Field(x => x.GroupId, type: typeof(IdGraphType), nullable: true); Field <GroupType>( "group", resolve: context => { if (context.Source.GroupId != null) { return(groupRepository.GetById((Guid)context.Source.GroupId)); } return(null); } ); Field(x => x.WinnerId, type: typeof(IdGraphType), nullable: true); Field <PlayerType>( "winner", resolve: context => { if (context.Source.WinnerId != null) { return(playerRepository.GetById((Guid)context.Source.WinnerId)); } return(null); } ); Field <ListGraphType <PlayerType> >( "players", resolve: context => frameRepository.GetPlayersOfFrameById(context.Source.Id) ); Field <ListGraphType <BreakType> >( "breaks", resolve: context => frameRepository.GetBreaksOfFrameById(context.Source.Id) ); }
public SCQuery( LeagueRepository leagueRepository, PlayerRepository playerRepository, TournamentRepository tournamentRepository, FrameRepository frameRepository, UserRepository userRepository, SettingRepository settingRepository ) { // Leagues Field <ListGraphType <LeagueType> >( "leagues", resolve: context => leagueRepository.Get(null, p => p.OrderBy(p => p.DisplayName)) ); Field <LeagueType>( "league", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => leagueRepository.GetById(context.GetArgument <Guid>("id")) ); // Players Field <ListGraphType <PlayerType> >( "players", resolve: context => playerRepository.Get(null, p => p.OrderBy(p => p.FirstName)) ); Field <PlayerType>( "player", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => playerRepository.GetById(context.GetArgument <Guid>("id")) ); // Tournaments Field <ListGraphType <TournamentType> >( "tournaments", resolve: context => tournamentRepository.Get(null, t => t.OrderByDescending(t => t.Date)) ); Field <TournamentType>( "tournament", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => tournamentRepository.GetById(context.GetArgument <Guid>("id")) ); // Frames Field <ListGraphType <FrameType> >( "frames", resolve: context => frameRepository.Get(null, t => t.OrderByDescending(t => t.EndDate)) ); Field <FrameType>( "frame", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => frameRepository.GetById(context.GetArgument <Guid>("id")) ); // Users Field <ListGraphType <UserType> >( "users", resolve: context => { // TODO //ClaimsPrincipal user = (ClaimsPrincipal)context.UserContext; //if (!user.IsInRole("Admin")) { return null; } return(userRepository.Get()); } ); Field <UserType>( "user", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { // TODO //ClaimsPrincipal user = (ClaimsPrincipal)context.UserContext; //if (!user.IsInRole("Admin")) { return null; } return(userRepository.GetById(context.GetArgument <Guid>("id"))); } ); // Settings Field <ListGraphType <SettingType> >( "settings", resolve: context => settingRepository.Get(null, s => s.OrderByDescending(s => s.Key)) ); Field <SettingType>( "setting", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "key" }), resolve: context => settingRepository.GetByKey(context.GetArgument <string>("key")) ); }
public FrameBLL(FrameRepository frameRepository) { this.frameRepository = frameRepository; }