private void FetchUsers_fetches_session_and_calls_UpdateItemCollection_and_updates_Items() { var client = new Mock <ISessionClient>(); var items = new List <ItemDTO> { new ItemDTO { Title = "Test", Description = "Test" } }; var session = new SessionDTO { Items = items, SessionKey = "1234567" }; client.Setup(s => s.GetByKeyAsync(session.SessionKey)).ReturnsAsync(session); var lobbyViewModel = new LobbyViewModel(client.Object); lobbyViewModel.UpdateItemCollection(session.Items); Assert.Equal(session.Items.Count, lobbyViewModel.Items.Count); }
public void Create(LobbyViewModel lobby) { var lobbies = new Lobby(); var teamsRadiant = _context.Teams.Where(x => x.TeamName == lobby.Radiant_team_name).FirstOrDefault(); var teamsDire = _context.Teams.Where(x => x.TeamName == lobby.Dire_team_name).FirstOrDefault(); if (lobbies.Id == 0) { lobbies.ScoreWinner = lobby.ScoreWinner; lobbies.DateStart = lobby.DateStart; lobbies.Winner = lobby.Winner; lobbies.ScoreLoser = lobby.ScoreLoser; lobbies.TournamentId = lobby.TournamentId; lobbies.Team_id_radiant = teamsRadiant.Id; lobbies.Team_id_dire = teamsDire.Id; _context.Lobbies.Add(lobbies); } else { Lobby dbEntry = _context.Lobbies.Find(lobbies.Id); if (dbEntry != null) { dbEntry.ScoreWinner = lobby.ScoreWinner; dbEntry.DateStart = lobby.DateStart; dbEntry.Winner = lobby.Winner; dbEntry.ScoreLoser = lobby.ScoreLoser; dbEntry.TournamentId = lobby.TournamentId; dbEntry.Team_id_radiant = teamsRadiant.Id; dbEntry.Team_id_dire = teamsDire.Id; _context.Lobbies.Add(dbEntry); } } _context.SaveChanges(); }
public IActionResult ForladLobby(LobbyViewModel model) { var currentUser = _userSession.User; var lobby = _lobbyProxy.LeaveLobbyAsync(model.Id, currentUser.Username, currentUser.Password).Result; return(RedirectToAction("TilslutLobby")); }
// GET: /<controller>/Show/<id> public ActionResult Show(long id) { using (var myWork = _factory.GetUOF()) { // Get the lobby from the database. var lobby = myWork.Lobby.Get(id); if (lobby == null) { // Error. throw new Exception("No such lobby"); } // Create a viewmodel for the lobby. var viewModel = new LobbyViewModel() { ID = lobby.LobbyId, Name = lobby.Name, Description = lobby.Description, Bets = lobby.Bets }; return(View(viewModel)); } }
public void IsStartedTrue(int lobbyId) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.lobby.id = lobbyId; lobbyClient.UpdateLobbyStatus(lobbyViewModel.lobby); }
public IActionResult Lobby(int id) { var jogo = _context.Jogos .Include(j => j.Jogador1) .Include(j => j.Jogador2) .Where(j => j.Id == id) .Select(j => j) .FirstOrDefault(); if (jogo == null) { return(NotFound()); } if (jogo.Jogador1 is JogadorPessoa) { jogo.Jogador1 = _context.JogadorPessoas .Include(j => j.Usuario) .Where(j => j.Id == jogo.Jogador1Id) .FirstOrDefault(); } if (jogo.Jogador2 is JogadorPessoa) { jogo.Jogador2 = _context.JogadorPessoas .Include(j => j.Usuario) .Where(j => j.Id == jogo.Jogador2Id) .FirstOrDefault(); } int?jogadorId = _userManager.GetUserAsync(User).Result.JogadorId; if (!(jogadorId == jogo.Jogador1Id || jogadorId == jogo.Jogador2Id)) { if (jogo.Jogador1 is JogadorPessoa && jogo.Jogador2 is JogadorPessoa) { return(Forbid()); } } var listaComputadores = _context.JogadorComputador.Select(j => new SelectListItem() { Text = j.Nome, Value = j.Id.ToString() }) .ToList(); listaComputadores.Add(new SelectListItem() { Selected = true, Text = "Esperar Jogador", Value = null }); var computadores = new SelectList(listaComputadores); LobbyViewModel lobbyViewModel = new LobbyViewModel { Jogo = jogo, Items = listaComputadores }; return(View(lobbyViewModel)); }
public ActionResult LeaveLobby(int userId, int categoryId) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.user.id = userId; userClient.ClearUsersJoinedLobbyId(lobbyViewModel.user); return(RedirectToAction("Lobby", new { categoryId = categoryId })); }
public Lobby(string sessionKey) { this.InitializeComponent(); this.BindingContext = this.lobbyViewModel = (Application.Current as App)?.Container.GetRequiredService <LobbyViewModel>(); this.lobbyViewModel.Key = sessionKey; this.lobbyViewModel.Title = sessionKey; }
public async Task <IActionResult> Index(LobbyViewModel lobbyViewModel) { var room = await roomRepository.CreateRoom(lobbyViewModel.NewRoom.Name, lobbyViewModel.NewRoom.IdWordlist, lobbyViewModel.NewRoom.AmountOfSeconds ); return(RedirectToAction(nameof(Game), new { room.Id })); }
public ActionResult DeleteLobby(int userId, int lobbyOwnedId, int categoryId) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.user.id = userId; lobbyViewModel.user.lobbyOwnedId = lobbyOwnedId; userClient.ClearsUsersLobbyOwnedIdAndDeleteLobby(lobbyViewModel.user); return(RedirectToAction("Lobby", new { categoryId = categoryId })); }
public ActionResult Lobby() { LobbyViewModel model = new LobbyViewModel(); List <GameSessions> Games = GameDB.GameSession.Where(entry => entry.IsStarted == false && entry.IsCompleted == false).ToList(); model.LobbyGames = Games; return(View(model)); }
public ActionResult Lobby() { var viewModel = new LobbyViewModel(); var concessionHelper = new ConcessionHelper(); viewModel.ConcessionCategories = concessionHelper.GetConcessions(); return(View(ProjectConst.ControllerViews.Lobby, viewModel)); }
public ActionResult JoinLobby(LobbyViewModel lobbyViewModel, int lobbyId) { lobbyViewModel.lobbyUser.id = userClient.GetUserByUsername(SessionLogin.UserName).id; lobbyViewModel.lobby.id = lobbyId; lobbyViewModel.user.joinedLobbyId = lobbyId; lobbyClient.JoinLobby(lobbyViewModel.lobbyUser, lobbyViewModel.lobby); lobbyViewModel.lobby = lobbyClient.GetLobby(lobbyId); lobbyViewModel.users = userClient.GetUsersInLobby(lobbyId); return(View(lobbyViewModel)); }
public ActionResult CreateLobby(int categoryId) { if (SessionLogin.UserIsInSession()) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.categoryId = categoryId; lobbyViewModel.user = userClient.GetUserByUsername(SessionLogin.UserName); return(View(lobbyViewModel)); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Index() { var lobby = new LobbyViewModel() { Rooms = await roomRepository.GetRooms(), NewRoom = new Room(), Wordlists = await wordlistRepository.GetWordlists() }; return(View(lobby)); }
public async Task <IActionResult> Index() { DateTime theTime = await GetLocationTime(); ViewBag.DateTime = theTime; ViewBag.Country = await GetLocation(); if (User.Identity.IsAuthenticated) { var member = db.Members.Find(CurrentMember.MemberID); member.LastLoggedIn = DateTime.Now; db.SaveChanges(); //return RedirectToAction("Index", "Members"); } if (string.IsNullOrEmpty(HttpContext.Session.GetString("ShownIntro"))) { ViewBag.ShowIntro = true; HttpContext.Session.SetString("ShownIntro", "True"); } LobbyViewModel vm = new LobbyViewModel(); for (int i = 0; i < 4; i++) { Screen screen = (Screen)i; var film = db.Films.Join(db.FilmDetails.Include(fd => fd.StillUrls), f => f.FilmID, fd => fd.FilmID, (f, fd) => new { Film = f, FilmDetails = fd }).Where(f => f.Film.Showing > theTime && f.FilmDetails.Screen == screen && f.Film.FilmCollectionID == null).OrderBy(f => f.Film.Showing).ThenBy(f => f.Film.FilmID).FirstOrDefault(); if (film != null) { var title = film.Film.Title == "Collection" ? db.FilmCollections.Where(fc => fc.FilmID == film.Film.FilmID).First().Name : film.Film.Title; vm.Films.Add(new LobbyFilmViewModel() { FilmTitle = title, Rating = film.Film.Rating.GetDescription(), Time = film.Film.Showing.ToString("HH:mm"), Date = film.Film.Showing.ToString("dddd dd MMMM"), PosterUrl = film.FilmDetails.PosterUrl, FilmDetails = film.FilmDetails }); } else { vm.Films.Add(null); } } return(View(vm)); }
private void Init() { if (!App.Current.Properties.Keys.Contains("Login")) { MainPage = new NavigationPage(new Views.LoginPage()); } else { string login = App.Current.Properties["Login"].ToString(); var vm = new LobbyViewModel(login); MainPage = new NavigationPage(vm.TabbedPage); } }
public MainViewModel() { lobbyViewModel_ = new LobbyViewModel(); loginViewModel_ = new LoginViewModel(); createAccountModel_ = new CreateAccountViewModel(); modifyAccountViewModel_ = new ModifyAccountViewModel(); CallbackMediator.Subscribe("ToLobby", ToLobby); CallbackMediator.Subscribe("ToLogin", ToLogin); CallbackMediator.Subscribe("ToCreateAccount", ToCreateAccount); CallbackMediator.Subscribe("ToModifyAccount", ToModifyAccount); CurrentViewModel = loginViewModel_; }
public ActionResult JoinLobby(int lobbyId, int categoryId) { if (SessionLogin.UserIsInSession()) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.PlayerName = SessionLogin.UserName; lobbyViewModel.quizCategory = categoryClient.GetCategory(categoryId); lobbyViewModel.lobby = lobbyClient.GetLobby(lobbyId); lobbyViewModel.users = userClient.GetUsersInLobby(lobbyId); lobbyViewModel.user = userClient.GetUserByUsername(SessionLogin.UserName); return(View(lobbyViewModel)); } return(RedirectToAction("Index")); }
public ActionResult CreateLobby(LobbyViewModel lobbyViewModel, int categoryId) { if (ModelState.IsValid) { lobbyViewModel.lobby.name = lobbyViewModel.name; lobbyViewModel.category.id = categoryId; lobbyViewModel.lobby.category = lobbyViewModel.category; lobbyViewModel.lobby.isStarted = false; lobbyViewModel.lobbyUser.id = userClient.GetUserByUsername(SessionLogin.UserName).id; lobbyClient.CreateLobby(lobbyViewModel.lobby, lobbyViewModel.lobbyUser); return(RedirectToAction("Lobby", new { categoryId = categoryId })); } return(View(lobbyViewModel)); }
private void ActivateLobbyState(Object sender, EventArgs e) { System.Windows.Application.Current.Dispatcher.Invoke(delegate { LobbyGrid.Visibility = Visibility.Visible; GameGrid.Visibility = Visibility.Hidden; MatchmakingButton.Visibility = Visibility.Visible; QuitButton.Visibility = Visibility.Hidden; LobbyBatchState.Visibility = Visibility.Visible; RematchBatchState.Visibility = Visibility.Hidden; GameBatchState.Visibility = Visibility.Hidden; WaitingBatchState.Visibility = Visibility.Hidden; DataContext = new LobbyViewModel(); }); }
private void Menu_JoinGame(object sender, EventArgs e) { _client = new GTTcpClient(); _playerListViewModel = new PlayerListViewModel(_client); _playerListViewModel.LostConnection += PlayerListViewModel_LostConnection; _lobbyViewModel = new LobbyViewModel(_client, _playerListViewModel); _lobbyViewModel.BackToMenu += LobbyViewModel_BackToMenu; _lobbyViewModel.BuildingStarted += LobbyViewModel_BuildingStarted; ConnectControl connectControl = new ConnectControl { DataContext = _lobbyViewModel }; _mainWindow.Content = connectControl; }
public ActionResult Lobby(int categoryId) { if (SessionLogin.UserIsInSession()) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.PlayerName = SessionLogin.UserName; lobbyViewModel.lobbies = lobbyClient.GetAllLobbiesWithCategoryId(categoryId).OrderByDescending(x => x.id).ToList(); lobbyViewModel.categoryId = categoryId; lobbyViewModel.user = userClient.GetUserByUsername(SessionLogin.UserName); lobbyViewModel.IsUserInLobby = lobbyClient.IsUserInLobby(SessionLogin.UserName); lobbyViewModel.DoesUserAlreadyOwnALobby = lobbyClient.DoesUserAlreadyOwnALobby(SessionLogin.UserName); return(View(lobbyViewModel)); } return(RedirectToAction("Index")); }
public IActionResult TilslutLobby(LobbyViewModel model) { var currentuser = _userSession.User; ILobby concreateLobby = _lobbyProxy.JoinLobbyAsync(model.Id, currentuser.Username, currentuser.Password).Result; if (concreateLobby != null) { LobbyViewModel updatedModel = new LobbyViewModel(); updatedModel.Id = concreateLobby.Id; updatedModel.Admin = concreateLobby.AdminUserName; updatedModel.Usernames = concreateLobby.Usernames.ToList(); return(RedirectToAction("Lobby", updatedModel)); } return(RedirectToAction("TilslutLobby")); }
public IActionResult Edit([FromBody] LobbyViewModel lobby) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _lobbyRepository.Edit(lobby); return(Ok(lobby)); } catch { return(BadRequest()); } }
public IActionResult Lobby(LobbyViewModel model) { //get the user var currentUser = _userSession.User; //get the concreate lobby again ILobby thisLobby = _lobbyProxy.RequestInstanceAsync(model.Id, currentUser.Username, currentUser.Password).Result; //make the model LobbyViewModel thisModel = new LobbyViewModel(); thisModel.Admin = thisLobby.AdminUserName; thisModel.Id = thisLobby.Id; thisModel.Usernames = thisLobby.Usernames.ToList(); return(View(thisModel)); }
public IActionResult Lobby(int id, [FromForm] LobbyViewModel viewModel) { var jogo = _context.Jogos .Include(j => j.Jogador1) .Include(j => j.Jogador2) .Where(j => j.Id == id) .Select(j => j) .FirstOrDefault(); jogo.Jogador2 = null; jogo.Jogador2Id = viewModel.jogo.Jogador2Id; if (jogo.Jogador2Id != null) { _context.SaveChanges(); return(RedirectToAction(nameof(Tabuleiro), new { Id = id })); } return(View(viewModel)); }
public void Edit(LobbyViewModel lobby) { try { var lobbies = _context.Lobbies.Where(c => c.Id == lobby.Id).FirstOrDefault(); var teamsRadiant = _context.Teams.Where(x => x.TeamName == lobby.Radiant_team_name).FirstOrDefault(); var teamsDire = _context.Teams.Where(x => x.TeamName == lobby.Dire_team_name).FirstOrDefault(); lobbies.Id = lobby.Id; lobbies.ScoreWinner = lobby.ScoreWinner; lobbies.DateStart = lobby.DateStart; lobbies.Winner = lobby.Winner; lobbies.ScoreLoser = lobby.ScoreLoser; lobbies.TournamentId = lobby.TournamentId; lobbies.Team_id_radiant = teamsRadiant.Id; lobbies.Team_id_dire = teamsDire.Id; _context.SaveChanges(); } catch (Exception ex) { } }
public async Task <IActionResult> Index(Guid playerId) { var playerDetails = await _mediator.Send(new GetPlayerDetailsRequest(playerId)); var player = new Player(playerId, playerDetails); var response = await _mediator.Send(new JoinOrCreateGameCommand(player)); try { var viewModel = new LobbyViewModel(response.Game, playerId); return(View(viewModel)); } catch (ArgumentException exception) { _logger.LogError($"{exception.Message} for PlayerId: {playerId}. JoinOrCreateGameResponse = {response}"); return(RedirectToAction("Index", "Error")); } }
public IActionResult OpretLobby(LobbyViewModel lobby) { //find brugeren der har lavet lobby var currentUser = _userSession.User; //add lobby ILobby lobbyReturn = _lobbyProxy.CreateInstanceAsync(lobby.Id, currentUser.Username, currentUser.Password).Result; if (lobbyReturn != null) { LobbyViewModel returns = new LobbyViewModel(); returns.Id = lobby.Id; returns.Admin = currentUser.Username; returns.Usernames.Add(currentUser.Username); return(RedirectToAction("Lobby", returns)); } else { return(RedirectToAction("LogInd", "Home")); } }