Beispiel #1
0
 /// <summary>
 /// Initializing the CharacterController class
 /// </summary>
 /// <param name="repository">Injected repository</param>
 /// <param name="mapper">Injected mapper</param>
 public CharactersController(
     [FromServices] ICharacterRepository repository,
     [FromServices] IMapper mapper)
 {
     _repository = repository;
     _mapper     = mapper;
 }
Beispiel #2
0
        public HumanType(ICharacterRepository characterRepository, IMapper mapper)
        {
            Name = "Human";

            Field(h => h.Id).Description("The id of the human.");
            Field(h => h.Name, nullable: true).Description("The name of the human.");

            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context =>
            {
                var friends = characterRepository.GetFriends(int.Parse(context.Source.Id)).Result;
                var mapped  = mapper.Map <IEnumerable <Character> >(friends);
                return(mapped);
            }
                );

            Field <ListGraphType <EpisodeEnum> >(
                "appearsIn",
                "Which movie they appear in.",
                resolve: context =>
            {
                var episodes     = characterRepository.GetEpisodes(int.Parse(context.Source.Id)).Result;
                var episodeEnums = episodes.Select(y => (Episodes)y.Id).ToArray();
                return(episodeEnums);
            }
                );

            Field(h => h.HomePlanet, nullable: true).Description("The home planet of the human.");

            Interface <CharacterInterface>();
        }
        public DroidType(ICharacterRepository characterRepository) : base(characterRepository)
        {
            Name        = "Droid";
            Description = "A mechanical creature in the Star Wars universe.";

            Field(d => d.PrimaryFunction, nullable: true).Description("The primary function of the droid.");
        }
Beispiel #4
0
 public LoginActions(IPacketSendService packetSendService,
                     IPacketTranslator <IAccountLoginData> loginPacketTranslator,
                     IPacketTranslator <ILoginRequestGrantedData> loginRequestGrantedPacketTranslator,
                     IPacketTranslator <ILoginRequestCompletedData> loginRequestCompletedPacketTranslator,
                     ILocalizedStringFinder localizedStringFinder,
                     ICharacterSelectorRepository characterSelectorRepository,
                     IPlayerInfoRepository playerInfoRepository,
                     ICharacterRepository characterRepository,
                     ICurrentMapStateRepository currentMapStateRepository,
                     ILoginFileChecksumRepository loginFileChecksumRepository,
                     INewsRepository newsRepository,
                     IChatRepository chatRepository,
                     ICharacterInventoryRepository characterInventoryRepository,
                     IPaperdollRepository paperdollRepository)
 {
     _packetSendService     = packetSendService;
     _loginPacketTranslator = loginPacketTranslator;
     _loginRequestGrantedPacketTranslator   = loginRequestGrantedPacketTranslator;
     _loginRequestCompletedPacketTranslator = loginRequestCompletedPacketTranslator;
     _localizedStringFinder       = localizedStringFinder;
     _characterSelectorRepository = characterSelectorRepository;
     _playerInfoRepository        = playerInfoRepository;
     _characterRepository         = characterRepository;
     _currentMapStateRepository   = currentMapStateRepository;
     _loginFileChecksumRepository = loginFileChecksumRepository;
     _newsRepository = newsRepository;
     _chatRepository = chatRepository;
     _characterInventoryRepository = characterInventoryRepository;
     _paperdollRepository          = paperdollRepository;
 }
 public CharacterService(ICharacterRepository charRepo, IUserService userService, ISkillService skillService, IAspectService aspectService)
 {
     _charRepo = charRepo;
     _userService = userService;
     _skillService = skillService;
     _aspectService = aspectService;
 }
Beispiel #6
0
        public void SetUp()
        {
            _configuration = Substitute.For <IStarWarsApiConfiguration>();
            _configuration.PageSize.Returns(pageSize);

            _allCharacters = new List <SwCharacter>
            {
                new SwCharacter {
                    Name = "0", Planet = "0"
                },
                new SwCharacter {
                    Name = "1", Planet = "1"
                },
                new SwCharacter {
                    Name = "2", Planet = "2"
                },
                new SwCharacter {
                    Name = "3", Planet = "3"
                },
                new SwCharacter {
                    Name = "4", Planet = "4"
                },
                new SwCharacter {
                    Name = "5", Planet = "5"
                },
            };
            _repository = Substitute.For <ICharacterRepository>();
            _repository.GetQueryable().Returns(_allCharacters.AsQueryable());
            _validator = Substitute.For <IValidateActionsService>();

            _serviceUnderTest = new CharactersService(_configuration, _repository, _validator);
        }
 /// <summary>
 /// Retrieve a hero by a particular Star Wars episode.
 /// </summary>
 /// <param name="episode">The episode to look up by.</param>
 /// <param name="repository"></param>
 /// <returns>The character.</returns>
 public async Task <ICharacter> GetHeroAsync(
     [Service] ICharacterRepository repository,
     Episode episode
     )
 {
     return(await repository.GetHeroAsync(episode));
 }
        public async Task <IPreProcessedOffsetPageResults <ICharacter> > GetCharactersWithOffsetPagingAsync(
            [Service] ICharacterRepository repository,
            //THIS is now injected by Pre-Processed extensions middleware...
            [GraphQLParams] IParamsContext graphQLParams
            )
        {
            var repoDbParams = new GraphQLRepoDbMapper <CharacterDbModel>(graphQLParams);

            //********************************************************************************
            //Get the data from the database via our lower level data access repository class.
            //NOTE: Selections (e.g. Projections), SortFields, PagingArgs are all pushed
            //       down to the Repository (and underlying Database) layer.
            var charactersPage = await repository.GetOffsetPagedCharactersAsync(
                repoDbParams.GetSelectFields(),
                repoDbParams.GetSortOrderFields(),
                repoDbParams.GetOffsetPagingParameters()
                );

            //With a valid Page/Slice we can return a PreProcessed Cursor Result so that
            //  it will not have additional post-processing in the HotChocolate pipeline!
            //NOTE: Filtering can be applied but ONLY to the results we are now returning;
            //       Because this would normally be pushed down to the Sql Database layer.
            return(charactersPage.AsPreProcessedPageResults());
            //********************************************************************************
        }
        public async Task <PreProcessedCursorSlice <Droid> > GetDroidsPaginatedAsync(
            [Service] ICharacterRepository repository,
            //THIS is now injected by Pre-Processed extensions middleware...
            [GraphQLParams] IParamsContext graphQLParams
            )
        {
            var repoDbParams = new GraphQLRepoDbMapper <CharacterDbModel>(graphQLParams);

            //********************************************************************************
            //Get the data and convert to List() to ensure it's an Enumerable
            //  and no longer using IQueryable to successfully simulate
            //  pre-processed results.
            //NOTE: Selections (e.g. Projections), SortFields, PagingArgs are all pushed
            //       down to the Repository (and underlying Database) layer.
            var charactersSlice = await repository.GetPagedDroidCharactersAsync(
                repoDbParams.GetSelectFields(),
                repoDbParams.GetSortOrderFields() ?? OrderField.Parse(new { Name = Order.Ascending }),
                repoDbParams.GetCursorPagingParameters()
                );

            //With a valid Page/Slice we can return a PreProcessed Cursor Result so that
            //  it will not have additional post-processing in the HotChocolate pipeline!
            //NOTE: Filtering can be applied but ONLY to the results we are now returning;
            //       Because this would normally be pushed down to the Sql Database layer.
            return(charactersSlice.AsPreProcessedCursorSlice());
            //********************************************************************************
        }
Beispiel #10
0
 public ScheduleCharactersHandler(int batchSize, int delayBetweenMessages, ICharacterRepository characterRepository, ICharactersUpdatePublisher charactersUpdatePublisher)
 {
     _batchSize                 = batchSize;
     _delayBetweenMessages      = delayBetweenMessages;
     _characterRepository       = characterRepository;
     _charactersUpdatePublisher = charactersUpdatePublisher;
 }
Beispiel #11
0
        public void TestCanUpdateRemedial()
        {
            ISessionFactory fac     = RomViewContainer.Container.GetInstance <ISessionFactory>();
            ISession        session = fac.OpenSession();
            ITransaction    tx      = session.BeginTransaction();

            CallSessionContext.Bind(session);

            try
            {
                ICharacterRepository rep = RomViewContainer.Container.GetInstance <ICharacterRepository>();

                CharacterDefinition def = rep.FindByName("Remedial");
                def.PrimaryClass   = CharacterClass.Scout;
                def.PrimaryLevel   = 56;
                def.SecondaryLevel = 55;
                def.SecondayClass  = CharacterClass.Mage;
                def.Race           = "Human";
                def.Sex            = Sex.Female;

                rep.Update(def);
                tx.Commit();
            }
            finally
            {
                session.Close();
            }
        }
        public DroidTypeInput(ICharacterRepository characterRepository)
        {
            Name = "DroidInput";

            Field(x => x.Id).Description("The Id of the Droid.");
            Field(x => x.Name, nullable: true).Description("The name of the Droid.");
        }
        public HumanType(ICharacterRepository characterRepository) : base(characterRepository)
        {
            Name = "Human";

            Field("HomePlanet", h => h.HomePlanet != null ? h.HomePlanet.Name : "", nullable: true)
            .Description("The home planet of the human.");
        }
Beispiel #14
0
 public ClaimController(
     IProjectRepository projectRepository,
     IProjectService projectService,
     IClaimService claimService,
     IPlotRepository plotRepository,
     IClaimsRepository claimsRepository,
     IFinanceService financeService,
     IPluginFactory pluginFactory,
     ICharacterRepository characterRepository,
     IUriService uriService,
     IAccommodationRequestRepository accommodationRequestRepository,
     IAccommodationRepository accommodationRepository,
     IAccommodationInviteService accommodationInviteService,
     IAccommodationInviteRepository accommodationInviteRepository,
     IUserRepository userRepository)
     : base(projectRepository, projectService, userRepository)
 {
     _claimService     = claimService;
     _plotRepository   = plotRepository;
     _claimsRepository = claimsRepository;
     _accommodationRequestRepository = accommodationRequestRepository;
     _accommodationRepository        = accommodationRepository;
     AccommodationInviteService      = accommodationInviteService;
     AccommodationInviteRepository   = accommodationInviteRepository;
     FinanceService      = financeService;
     PluginFactory       = pluginFactory;
     CharacterRepository = characterRepository;
     UriService          = uriService;
 }
        public CharacterType(ICharacterRepository characterRepository)
        {
            Field(h => h.Id).Description("The id of the character.");
            Field(h => h.Name, nullable: true).Description("The name of the character.");

            Field <ListGraphType <CharacterInterface> >(
                "Friends",
                resolve: context =>
            {
                var friends = characterRepository.GetFriends(context.Source.Id).Result;
                return(friends);
            }
                );

            Field <ListGraphType <EpisodeEnum> >(
                "AppearsIn",
                "Which movie they appear in.",
                resolve: context =>
            {
                return(context.Source.CharacterEpisodes.Select(y => (Episodes)y.Episode.Id).ToArray());
            }
                );

            Interface <CharacterInterface>();
        }
 public ClaimController(ApplicationUserManager userManager,
                        IProjectRepository projectRepository,
                        IProjectService projectService,
                        IClaimService claimService,
                        IPlotRepository plotRepository,
                        IClaimsRepository claimsRepository,
                        IFinanceService financeService,
                        IExportDataService exportDataService,
                        IPluginFactory pluginFactory,
                        ICharacterRepository characterRepository,
                        IUriService uriService,
                        IAccommodationRequestRepository accommodationRequestRepository,
                        IAccommodationRepository accommodationRepository,
                        IAccommodationService accommodationService,
                        IAccommodationInviteService accommodationInviteService,
                        IAccommodationInviteRepository accommodationInviteRepository)
     : base(userManager, projectRepository, projectService, exportDataService)
 {
     _claimService     = claimService;
     _plotRepository   = plotRepository;
     _claimsRepository = claimsRepository;
     _accommodationRequestRepository = accommodationRequestRepository;
     _accommodationRepository        = accommodationRepository;
     AccommodationService            = accommodationService;
     AccommodationInviteService      = accommodationInviteService;
     AccommodationInviteRepository   = accommodationInviteRepository;
     FinanceService      = financeService;
     PluginFactory       = pluginFactory;
     CharacterRepository = characterRepository;
     UriService          = uriService;
 }
Beispiel #17
0
 public Factory(IGuildRepository guildRepository, ICharacterRepository characterRepository, GuildManagementContext guildContext, IBlizzardConnectionRepository blizzardRepository)
 {
     _guildRepository     = guildRepository;
     _characterRepository = characterRepository;
     _guildContext        = guildContext;
     _blizzardRepository  = blizzardRepository;
 }
Beispiel #18
0
        public MainPageViewModel(ICharacterRepository repository, IAuthenticationHelper helper, INavigationService service)
        {
            _repository = repository;
            _helper     = helper;
            _service    = service;

            Characters = new ObservableCollection <CharacterViewModel>();

            DetailsPageCommand = new RelayCommand(o =>
            {
                _service.Navigate(typeof(CharacterPage), o);
            });
            SignInOutCommand = new RelayCommand(async o =>
            {
                if (_account != null)
                {
                    await _helper.SignOutAsync(_account);
                    _account = null;
                    Characters.Clear();
                }
                else
                {
                    _account = await _helper.SignInAsync();
                    if (_account != null)
                    {
                        await Initialize();
                    }
                }
            });
        }
 //TODO: Make a service layer
 public BotController(ILogger <BotController> logger, ICharacterRepository characterRepository, ISoulbreakRepository soulbreakRepository, IFfrkSheetContext ffrkSheetContext)
 {
     _logger = logger;
     this.characterRepository = characterRepository;
     this.soulbreakRepository = soulbreakRepository;
     this.ffrkSheetContext    = ffrkSheetContext;
 }
Beispiel #20
0
        public DroidType(ICharacterRepository characterRepository, IMapper mapper)
        {
            Name        = "Droid";
            Description = "A mechanical creature in the Star Wars universe.";

            Field(x => x.Id).Description("The Id of the Droid.");
            Field(x => x.Name, nullable: true).Description("The name of the Droid.");

            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context =>
            {
                var friends = characterRepository.GetFriends(int.Parse(context.Source.Id)).Result;
                var mapped  = mapper.Map <IEnumerable <Character> >(friends);
                return(mapped);
            }
                );

            Field <ListGraphType <EpisodeEnum> >(
                "appearsIn",
                "Which movie they appear in.",
                resolve: context =>
            {
                var episodes     = characterRepository.GetEpisodes(int.Parse(context.Source.Id)).Result;
                var episodeEnums = episodes.Select(y => (Episodes)y.Id).ToArray();
                return(episodeEnums);
            }
                );


            Field(d => d.PrimaryFunction, nullable: true).Description("The primary function of the droid.");

            Interface <CharacterInterface>();
        }
Beispiel #21
0
 public EditModel(LarpBuilderContext larpBuilderContext, ICharacterRepository characterRepository,
                  ISkillRepository skillRepository)
 {
     _larpBuilderContext  = larpBuilderContext;
     _characterRepository = characterRepository;
     _skillRepository     = skillRepository;
 }
Beispiel #22
0
 public CreateCharacterFactory(
     IEpisodeRepository episodeRepository,
     ICharacterRepository characterRepository)
 {
     _episodeRepository   = episodeRepository;
     _characterRepository = characterRepository;
 }
 public SerieType(ICharacterRepository characterRepository)
 {
     Field(x => x.Id, type: typeof(IdGraphType));
     Field(x => x.Name);
     Field <ListGraphType <CharacterType> >("characters",
                                            resolve: context => characterRepository.GetBySerie(context.Source.Id));
 }
 public CharacterService(ICharacterRepository characterRepository, IUnitOfWork uow, IHouseService houseService, ICharacterFactory charactereFactory)
 {
     CharacterRepository = characterRepository ?? throw new ArgumentNullException(nameof(characterRepository));
     Uow              = uow ?? throw new ArgumentNullException(nameof(uow));
     HouseService     = houseService ?? throw new ArgumentNullException(nameof(houseService));
     CharacterFactory = charactereFactory ?? throw new ArgumentNullException(nameof(charactereFactory));
 }
 public CreateCharacterCommandHandler(
     ICharacterRepository characterRepository,
     IMapper mapper)
 {
     _characterRepository = characterRepository;
     _mapper = mapper;
 }
Beispiel #26
0
        public HumanType(ICharacterRepository characterRepository, IMapper mapper)
        {
            Name = nameof(Human);

            Field(h => h.Id).Description(string.Format(Descriptions.The_id_of_the_0, Name));
            Field(h => h.Name, true).Description(string.Format(Descriptions.The_name_of_the_0, Name));

            FieldAsync <ListGraphType <CharacterInterface> >(
                FieldNames.Friends,
                resolve: async context =>
            {
                var friends = await characterRepository.GetFriendsAsync(int.Parse(context.Source.Id));
                var mapped  = mapper.Map <IEnumerable <Character> >(friends);
                return(mapped);
            }
                );

            FieldAsync <ListGraphType <EpisodeEnum> >(
                FieldNames.Appearsin,
                Descriptions.Which_movie_they_appear_in,
                resolve: async context =>
            {
                var episodes     = await characterRepository.GetEpisodesAsync(int.Parse(context.Source.Id));
                var episodeEnums = episodes.Select(y => (Episodes)y.Id).ToArray();
                return(episodeEnums);
            }
                );

            Field(h => h.HomePlanet, true).Description(Descriptions.The_home_planet_of_the_human);

            Interface <CharacterInterface>();
        }
 public ChooseCharacterRaceCommandHandler(
     ICharacterRepository repository,
     IUnitOfWork unitOfWork)
 {
     this.repository = repository;
     this.unitOfWork = unitOfWork;
 }
 public GetAllCharactersService(
     ICharacterRepository characterRepository,
     IMapper mapper)
 {
     _characterRepository = characterRepository;
     _mapper = mapper;
 }
Beispiel #29
0
        public ApiUpdaterService(ILogger <ApiUpdaterService> logger,
                                 IPlayerService playerService,
                                 IPlayerRepository playerRepository,
                                 ICharacterRepository characterRepository,
                                 ICharacterService characterService,
                                 ISkillRepository skillRepository,
                                 ISkillService skillService,
                                 ICraftableService craftableService,
                                 ICraftableRepository craftableRepository,
                                 IBondService bondService,
                                 IBondRepository bondRepository,
                                 ICharacterSkillService characterSkillService,
                                 ICharacterSkillRepository characterSkillRepository)
        {
            _logger = logger;

            _playerService       = playerService;
            _playerRepository    = playerRepository;
            _characterService    = characterService;
            _characterRepository = characterRepository;
            _skillService        = skillService;
            _skillRepository     = skillRepository;
            _itemService         = craftableService;
            _itemRepository      = craftableRepository;
            _bondRepository      = bondRepository;
            _bondService         = bondService;
            _charSkillService    = characterSkillService;
            _charSkillRepository = characterSkillRepository;
        }
        public override void OnConfigure(
            IDescriptorContext context,
            IObjectFieldDescriptor descriptor,
            MemberInfo member)
        {
            descriptor.Resolve(async ctx =>
            {
                ICharacter character            = ctx.Parent <ICharacter>();
                ICharacterRepository repository = ctx.Service <ICharacterRepository>();
                //This is injected by the PreProcessing middleware wen enabled...
                var graphQLParams = new GraphQLParamsContext(ctx);

                //********************************************************************************
                //Perform some pre-processed retrieval of data from the Repository...
                //Notice Pagination processing is pushed down to the Repository layer also!

                //Get RepoDb specific mapper for the GraphQL parameter context...
                //Note: It's important that we map to the DB Model (not the GraphQL model).
                var repoDbParams = new GraphQLRepoDbMapper <CharacterDbModel>(graphQLParams);

                //Now we can retrieve the related and paginated data from the Repo...
                var pagedFriends = await repository.GetCharacterFriendsAsync(character.Id, repoDbParams.GetCursorPagingParameters());
                return(new PreProcessedCursorSlice <ICharacter>(pagedFriends));
                //********************************************************************************
            });
        }
        public static async Task Test_Controller_Produces_AlreadyHasActiveSession_When_Session_Has()
        {
            //arrange
            IServiceProvider            serviceProvider = ControllerTestsHelpers.BuildServiceProvider <CharacterSessionController>("Test", 1);
            CharacterSessionController  controller      = serviceProvider.GetService <CharacterSessionController>();
            ICharacterRepository        characterRepo   = serviceProvider.GetService <ICharacterRepository>();
            ICharacterSessionRepository sessionRepo     = serviceProvider.GetService <ICharacterSessionRepository>();

            await characterRepo.TryCreateAsync(new CharacterEntryModel(1, "Testing"));

            await sessionRepo.TryCreateAsync(new CharacterSessionModel(1, 0));

            //We can't create the claimed session through this interface because it's a stored procedure.
            //Raw SQL can't execute. So we must interact directly with the DbSet
            //await sessionRepo.TryClaimUnclaimedSession(1, 1);
            CharacterDatabaseContext context = serviceProvider.GetService <CharacterDatabaseContext>();
            await context.ClaimedSession.AddAsync(new ClaimedSessionsModel(1));

            await context.SaveChangesAsync();

            //act
            CharacterSessionEnterResponse response = await controller.EnterSession(1);

            //assert
            Assert.False(response.isSuccessful, $"Characters that already have ");
            Assert.AreEqual(CharacterSessionEnterResponseCode.AccountAlreadyHasCharacterSession, response.ResultCode);
        }
 public GetCharacterInfoQueryHandler()
 {
     repository = new CharacterRepository();
     mapper = new CharacterInfoMapper();
 }
 public CharacterController(ICharacterRepository repo, IUserManager userManager)
 {
     _repo = repo;
     _userManager = userManager;
 }
Beispiel #34
0
 public HomeController(IUserManager userManager, ICharacterRepository characterRepo)
 {
     UserManager = userManager;
     CharacterRepo = characterRepo;
 }
 public CharactersController(ICharacterRepository characterRepository)
 {
     _characterRepository = characterRepository;
 }
Beispiel #36
0
 public Dnd35Service(IDnd35Mapper mapper, ICharacterRepository characterRepository)
 {
     _mapper = mapper;
     _characterRepository = characterRepository;
 }
Beispiel #37
0
 public OldCharacterController(ICharacterRepository repository, IMapper<ICharacter, CharacterViewModel> mapper)
 {
     _repository = repository ?? new CharacterEfRepository();
     _mapper = mapper ?? new CharacterMapper();
 }
 public CharacterService(ICharacterRepository characterRepository)
 {
     _characterRepository = characterRepository;
 }
 public CharacterService(ICharacterRepository characterRepository, ICharacterParser parser)
 {
     _characterRepository = characterRepository;
     _parser = parser;
 }