public GameProcessModel Edit(int id) { var player = _playersRepository.GetAll().ToList(); var gameProcess = _gameProcessRepository.GetAll().First(c => c.Id == id); var gameProcessItems = GetGameProcessItems(gameProcess); var totalInput = gameProcessItems.SelectMany(c => c.Input.Select(i => i.Amount).ToList()).Sum(); var totalOutput = gameProcessItems.Where(c => c.OutPut != null).Select(c => c.OutPut.Amount).Sum(); var subtract = !gameProcess.EndDateTime.HasValue ? DateTime.Subtract(gameProcess.StartDateTime.GetValueOrDefault()) : gameProcess.EndDateTime.Value.Subtract(gameProcess.StartDateTime.GetValueOrDefault()); var vm = new GameProcessModel { Items = gameProcessItems, DirationTime = subtract, PlayerCount = gameProcessItems.Count, TotalInput = totalInput, TotalOutput = totalOutput, Total = (totalInput - totalOutput), Id = id, EditModel = new Action { GameProcessId = id, Amount = 6000 }, Players = player.Select(c => new PlayerItem { Name = c.Name, Id = c.Id.ToString(), ImageUrl = c.ImageUrl }).ToList() }; return(vm); }
public List <PlayerItem> Search(string query) { var players = _playersRepository.GetAll().Where(c => c.Name.Contains(query) || c.Phone == query).ToList(); return(players.Select(c => { var phone = (c.Phone ?? "0").Replace("+", "").Replace(" ", ""); return new PlayerItem { Id = c.Id.ToString(), Name = c.Name, Phone = long.Parse(phone), ImageUrl = c.ImageUrl, }; }).ToList()); }
public void PlayersAll() { var playersRepository = new PlayersRepository(); var players = playersRepository.GetAll().ToList(); Assert.NotNull(players); }
public async Task GetsPlayers() { using (var context = new ApplicationDbContext(_options)) { context.Players.AddRange( new Player { Id = 1 }, new Player { Id = 2 }, new Player { Id = 3 }); context.SaveChanges(); } using (var context = new ApplicationDbContext(_options)) { var playersRepository = new PlayersRepository(context); var players = await playersRepository.GetAll(0, 2); Assert.Equal(2, players.Count); Assert.NotNull(players.SingleOrDefault(x => x.Id == 1)); Assert.NotNull(players.SingleOrDefault(x => x.Id == 2)); } }
private async Task DisplayPlayers() { try { FeedIterator <Player> feedIterator = PlayersRepository.GetAll(); List <Task> playerTasks = new List <Task>(); while (feedIterator.HasMoreResults) { foreach (Player player in await feedIterator.ReadNextAsync()) { Task playerTask = DisplayPlayer(player); playerTasks.Add(playerTask); } } await Task.WhenAll(playerTasks.ToArray()); } catch (Exception e) { Console.WriteLine(e); } }
public ActionResult <IEnumerable <string> > Get() { IEnumerable <Players> players = _playersRepository.GetAll(); return(Ok(players)); }