public IEnumerable<IResult> ExecuteSearch() { //TALK: AsResult (extension method) wraps our SearchGames query into a new // QueryResult<IEnumerable<SearchResult>> QueryResult<IEnumerable<SearchResult>> search = new SearchGames { SearchText = SearchText }.AsResult(); yield return Show.Busy(); yield return search; int resultCount = search.Response.Count(); if (resultCount == 0) SearchResults = _noResults.WithTitle(SearchText); else if (resultCount == 1 && search.Response.First().Title == SearchText) { QueryResult<GameDTO> getGame = new GetGame { Id = search.Response.First().Id }.AsResult(); yield return getGame; yield return Show.Child<ExploreGameViewModel>() .In<IShell>() .Configured(x => x.WithGame(getGame.Response)); } else SearchResults = _results.With(search.Response); yield return Show.NotBusy(); }
public IEnumerable<IResult> ExecuteSearch() { var search = new SearchGames { SearchText = SearchText }.AsResult(); yield return Show.Busy(); yield return search; var resultCount = search.Response.Count(); if(resultCount == 0) SearchResults = noResults.WithTitle(SearchText); else if(resultCount == 1 && search.Response.First().Title == SearchText) { var getGame = new GetGame { Id = search.Response.First().Id }.AsResult(); yield return getGame; yield return Show.Child<ExploreGameViewModel>() .In<IShell>() .Configured(x => x.WithGame(getGame.Response)); } else SearchResults = results.With(search.Response); yield return Show.NotBusy(); }
public IEnumerable <IResult> ExecuteSearch() { var search = new SearchGames { SearchText = SearchText }.AsResult(); yield return(Show.Busy()); yield return(search); var resultCount = search.Response.Count(); if (resultCount == 0) { SearchResults = noResults.WithTitle(SearchText); } else if (resultCount == 1 && search.Response.First().Title == SearchText) { var getGame = new GetGame { Id = search.Response.First().Id }.AsResult(); yield return(getGame); yield return(Show.Child <ExploreGameViewModel>() .In <IShell>() .Configured(x => x.WithGame(getGame.Response))); } else { SearchResults = results.With(search.Response); } yield return(Show.NotBusy()); }
public IEnumerable<IResult> Open() { var getGame = new GetGame { Id = result.Id }.AsResult(); yield return Show.Busy(); yield return getGame; yield return Show.Child<ExploreGameViewModel>() .In<IShell>() .Configured(x => x.WithGame(getGame.Response)); yield return Show.NotBusy(); }
public async Task <Maybe <Game> > Handle(GetGame request, CancellationToken cancellationToken) { var gameDb = await _context.Games .Where(g => g.Id == request.Id) .FirstOrDefaultAsync(cancellationToken); var mapDb = await _context.Maps .Where(c => c.GameId == request.Id) .FirstOrDefaultAsync(cancellationToken); var playerOne = _context.Players .Where(c => c.GameId == request.Id) .Select(s => s.FirstPlayer) .Select(x => x.HaunterId) .FirstOrDefaultAsync(cancellationToken) .Result; var playerTwo = _context.Players .Where(c => c.GameId == request.Id) .Select(s => s.SecondPlayer) .Select(x => x.HaunterId) .FirstOrDefaultAsync(cancellationToken) .Result; var cells = await _context.Cells.Where(c => c.MapId == mapDb.Id) .ToListAsync(cancellationToken); var cellList = new List <int>(); foreach (var item in cells) { cellList.Add(item.TicTac); } var gameDto = new Game { Id = request.Id, MapId = mapDb.Id, PlayerOne = Convert.ToInt32(playerOne), PlayerTwo = Convert.ToInt32(playerTwo), TicTacList = cellList }; return(gameDb == null ? Maybe <Game> .None : Maybe <Game> .From(_mapper.Map <Game>(gameDto))); }
public Task <GameDetail> Handle(GetGame request, CancellationToken cancellationToken) { var id = request.Id; var result = simpleDBClient.SelectAsync(new SelectRequest() { SelectExpression = $"SELECT * FROM `Boardgames` where itemName() = '{id}' LIMIT 1" }); result.Wait(); var retval = result.Result.Items.First().Attributes.ToGameDetail(); return(Task.FromResult(retval)); }
public IEnumerable <IResult> Open() { var getGame = new GetGame { Id = result.Id }.AsResult(); yield return(Show.Busy()); yield return(getGame); yield return(Show.Child <ExploreGameViewModel>() .In <IShell>() .Configured(x => x.WithGame(getGame.Response))); yield return(Show.NotBusy()); }
/// <summary> /// Encodes a file /// </summary> /// <returns>The task</returns> public async Task EncodeFileAsync() { // Allow the user to select the files var fileResult = await Services.BrowseUI.BrowseFileAsync(new FileBrowserViewModel() { Title = Resources.Utilities_Decoder_EncodeFileSelectionHeader, DefaultDirectory = GetGame?.GetInstallDir(false).FullPath, ExtensionFilter = GetFileFilter, MultiSelection = true }); if (fileResult.CanceledByUser) { return; } // Allow the user to select the destination directory var destinationResult = await Services.BrowseUI.BrowseDirectoryAsync(new DirectoryBrowserViewModel() { Title = Resources.Browse_DestinationHeader, }); if (destinationResult.CanceledByUser) { return; } try { // Process the files await Task.Run(() => ProcessFile(fileResult.SelectedFiles, destinationResult.SelectedDirectory, false)); await Services.MessageUI.DisplaySuccessfulActionMessageAsync(Resources.Utilities_Decoder_EncodeSuccess); } catch (NotImplementedException ex) { ex.HandleExpected("Encoding files"); await Services.MessageUI.DisplayMessageAsync(Resources.NotImplemented, MessageType.Error); } catch (Exception ex) { ex.HandleError("Encoding files"); await Services.MessageUI.DisplayExceptionMessageAsync(ex, Resources.Utilities_Decoder_EncodeError); } }
public async Task <GetGameResult> Handle(GetGame request, CancellationToken cancellationToken) { var validationResult = await requestsValidator.Validate(request); if (!validationResult.IsSuccessful) { return(new GetGameResult(validationResult.Error)); } var game = await queryExecutor .QueryFirstOrDefault <GameData>(GetGameDataQuery, new { request.GameId, request.UserId }); var players = await queryExecutor .Query <PlayerData>(GetGamePlayersQuery, new { request.GameId, request.UserId }); return(new GetGameResult { Game = game, Players = players.ToList() }); }
public async Task <IActionResult> GetGameAsync([FromQuery] GetGame model) { _logger.LogDebug( $"Action: {ControllerContext.ActionDescriptor.ActionName} Parameters: id = {model.Id}"); var result = await _mediator.Send(model); if (result.HasValue) { _logger.LogInformation( $"Action: {ControllerContext.ActionDescriptor.ActionName} " + $"Parameter: Id = {model.Id}"); return(Ok(result.Value)); } _logger.LogWarning( $"Action: {ControllerContext.ActionDescriptor.ActionName} : " + $"Id = {model.Id}, - game not found"); return(NotFound()); }
public async Task <GameDetail> GetOne(string gameId) { var response = await mediator.Send(GetGame.With(gameId)); return(response); }
public void TheGamesDB_GetGameDeserialize() { GetGame game = gamesDBList.DeserializeOnly <GetGame>(Properties.Resources.Interfaces_TheGamesDB_GetGame); Assert.IsNotNull(game); }
public IEnumerable<IResult> ExecuteSearch() { var search = new SearchGames { SearchText = SearchText }.AsResult(); yield return Show.Busy(); yield return search; var hits = search.Response.Hits; if (hits.Count() == 0) SearchResults = _noResults.WithTitle(SearchText); else if (hits.Count() == 1 && hits.First().Title == SearchText) { var getGame = new GetGame { Id = hits.First().Id }.AsResult(); yield return getGame; yield return Show.Screen<ExploreGameViewModel>() .Configured(x => x.WithGame(getGame.Response)); } else SearchResults = _results.With(hits); yield return Show.NotBusy(); }