public async Task <ActionResult <IEnumerable <Game> > > GetMyGames( [FromBody] GamesRequest request, [FromQuery] bool fullRecord = true) { if (await appsService.IsRequestValidOnThisLicense( request.AppId, request.License, request.RequestorId)) { var result = await gamesService .GetMyGames(request, fullRecord); if (result.Success) { result.Message = ControllerMessages.StatusCode200(result.Message); return(Ok(result)); } else { result.Message = ControllerMessages.StatusCode404(result.Message); return(NotFound(result)); } } else { return(BadRequest(ControllerMessages.InvalidLicenseRequestMessage)); } }
public async Task <ActionResult <Game> > DeleteMyGame( int id, [FromBody] GamesRequest request) { if (await appsService.IsRequestValidOnThisLicense( request.AppId, request.License, request.RequestorId)) { var result = await gamesService.DeleteMyGame( id, request); if (result.Success) { result.Message = ControllerMessages.StatusCode200(result.Message); return(Ok(result)); } else { result.Message = ControllerMessages.StatusCode404(result.Message); return(NotFound(result)); } } else { return(BadRequest(ControllerMessages.InvalidLicenseRequestMessage)); } }
public async Task <GamesResponse> GamesData(GamesRequest request) { var player = await _gameQueries.GetPlayerByUsernameAsync(request.PlayerUsername); var brandId = _gameQueries.GetPlayerData(player.Id).BrandId; var lobby = _gameQueries.GetLobby(brandId, request.IsForMobile); var data = await _productOperations.GetProductsForPlayerAsync(lobby.Id, player.Id, request.LobbyUrl, request.PlayerIpAddress, request.UserAgent); return(new GamesResponse() { CdnRoot = data.products.cdnroot, Iconres = data.products.iconres, GameGroups = data.products.groups.Select(gamegroup => new GameGroupDto() { Name = gamegroup.name, Code = gamegroup.code, Order = gamegroup.order, Games = gamegroup.games.Select(game => new GameDto() { Id = game.id, IconPath = game.iconpath, Name = game.name, Code = game.code, Url = game.url, Order = game.order, ProviderCode = game.providercode, IsActive = game.isactive }).ToArray() }).ToArray() }); }
public async Task Setup() { context = await TestDatabase.GetDatabaseContext(); mockGamesService = new MockGamesService(context); mockAppsService = new MockAppsService(context); baseRequest = new BaseRequest(); createGameRequest = new CreateGameRequest(); getMyGameRequest = new GamesRequest() { UserId = 1, License = TestObjects.GetLicense(), RequestorId = 1, Paginator = new Paginator() }; updateGameRequest = TestObjects.GetUpdateGameRequest(); sutSuccess = new GamesController( mockGamesService.GamesServiceSuccessfulRequest.Object, mockAppsService.AppsServiceSuccessfulRequest.Object); sutFailure = new GamesController( mockGamesService.GamesServiceFailedRequest.Object, mockAppsService.AppsServiceSuccessfulRequest.Object); }
public void GamesRequest_ReturnsGameDto() { var sut = new GamesRequest(); var result = sut.Submit( "mlb-was", new DateTime(2019, 6, 19)); Assert.IsNotNull(result); }
public async Task GetUsersGames() { // Arrange var userId = 1; var getMyGameRequest = new GamesRequest() { Paginator = new Paginator(), UserId = userId }; // Act var result = await sut.GetMyGames(getMyGameRequest); // Assert Assert.That(result.Success, Is.True); Assert.That(result.Message, Is.EqualTo("Games Found")); Assert.That(result.Games, Is.TypeOf <List <IGame> >()); }
public async Task <GameListResponse> GameList(GamesRequest request) { var player = await _gameQueries.GetPlayerByUsernameAsync(request.PlayerUsername); if (player == null) { throw new RegoValidationException(ErrorMessagesEnum.PlayerWithRequestedIdDoesntExist.ToString()); } var brandId = _gameQueries.GetPlayerData(player.Id).BrandId; if (brandId == null) { throw new RegoValidationException(ErrorMessagesEnum.NoBrandRelatedToThisPlayer.ToString()); } var lobby = _gameQueries.GetLobby(brandId, request.IsForMobile); if (lobby == null) { throw new RegoValidationException(ErrorMessagesEnum.LobbyIsMissingForThisBrand.ToString()); } var data = await _productOperations.GetProductsForPlayerAsync(lobby.Id, player.Id, request.LobbyUrl, request.PlayerIpAddress, request.UserAgent); return(new GameListResponse { GameProviders = data.products.groups.SelectMany(x => x.games).GroupBy(x => x.providercode, x => x) .Select(gameProvider => new GameProviderData { Code = gameProvider.Key, Games = data.products.groups .SelectMany(group => group.games) .Where(game => game.providercode == gameProvider.Key) .Select(game => new GameData { Id = game.id, Name = game.name, Url = game.url }).ToList() }).ToList() }); }
public async Task Setup() { context = await TestDatabase.GetDatabaseContext(); mockGamesRepository = new MockGamesRepository(context); mockAppsRepository = new MockAppsRepository(context); mockUsersRepository = new MockUsersRepository(context); mockDifficultiesRepositorySuccessful = new MockDifficultiesRepository(context); mockDifficultiesRepositoryFailed = new MockDifficultiesRepository(context); mockSolutionsRepository = new MockSolutionsRepository(context); sut = new GamesService( mockGamesRepository.GamesRepositorySuccessfulRequest.Object, mockAppsRepository.AppsRepositorySuccessfulRequest.Object, mockUsersRepository.UsersRepositorySuccessfulRequest.Object, mockDifficultiesRepositorySuccessful.DifficultiesRepositorySuccessfulRequest.Object, mockSolutionsRepository.SolutionsRepositorySuccessfulRequest.Object); sutFailure = new GamesService( mockGamesRepository.GamesRepositoryFailedRequest.Object, mockAppsRepository.AppsRepositorySuccessfulRequest.Object, mockUsersRepository.UsersRepositorySuccessfulRequest.Object, mockDifficultiesRepositorySuccessful.DifficultiesRepositorySuccessfulRequest.Object, mockSolutionsRepository.SolutionsRepositorySuccessfulRequest.Object); sutAnonFailure = new GamesService( mockGamesRepository.GamesRepositorySuccessfulRequest.Object, mockAppsRepository.AppsRepositorySuccessfulRequest.Object, mockUsersRepository.UsersRepositorySuccessfulRequest.Object, mockDifficultiesRepositoryFailed.DifficultiesRepositoryFailedRequest.Object, mockSolutionsRepository.SolutionsRepositorySuccessfulRequest.Object); sutUpdateFailure = new GamesService( mockGamesRepository.GamesRepositoryUpdateFailedRequest.Object, mockAppsRepository.AppsRepositorySuccessfulRequest.Object, mockUsersRepository.UsersRepositorySuccessfulRequest.Object, mockDifficultiesRepositorySuccessful.DifficultiesRepositorySuccessfulRequest.Object, mockSolutionsRepository.SolutionsRepositorySuccessfulRequest.Object); getGamesRequest = TestObjects.GetGamesRequest(); }
public async Task <GamesResponse> GamesAsync(GamesRequest request) { var result = await HttpClient.SecurePostAsJsonAsync(Token, "api/Games/GamesData", request); return(await EnsureApiResult <GamesResponse>(result)); }