public PvPViewModel() { CurrentViewModel = new PlayerViewModel(); NavigationCommand = new RelayCommand<string>(OnNavigation); PlayerDisplayName = "SKT Marin"; }
protected override void OnInitialize() { base.OnInitialize(); var musicFileContext = Container.GetExportedValue<MockMusicFileContext>(); musicFiles = new ObservableCollection<MusicFile>() { musicFileContext.Create(@"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity.wav"), musicFileContext.Create(@"C:\Culture Beat - Serenity - Epilog.wma"), }; selectionService = Container.GetExportedValue<SelectionService>(); selectionService.Initialize(musicFiles); playlistManager = new PlaylistManager(); playlistSettings = new PlaylistSettings(); controller = Container.GetExportedValue<PlayerController>(); controller.PlaylistSettings = playlistSettings; controller.PlaylistManager = playlistManager; controller.Initialize(); shellService = Container.GetExportedValue<ShellService>(); shellService.ShowPlaylistViewAction = () => { }; view = (MockPlayerView)shellService.PlayerView; viewModel = ViewHelper.GetViewModel<PlayerViewModel>(view); }
public ActionResult AddPlayer(PlayerViewModel playerModel) { if (ModelState.IsValid) { var playerDataModel = MappingService.MappingProvider.Map <Player>(playerModel); this.playerService.Add(playerDataModel, playerModel.TeamName, playerModel.CountryName); } this.TempData[GlobalConstants.SuccessMessage] = string.Format( "Player {0} {1} added successfully!", playerModel.FirstName, playerModel.LastName); return(this.RedirectToAction <PlayersGridController>(c => c.Index())); }
public async Task <ActionResult> Create(PlayerViewModel viewModel) { if (ModelState.IsValid) { var result = await _playerService.Add(viewModel.ToModel()); if (result) { ViewBag.Message = "Player Added Successfully"; ModelState.Clear(); } } return(View(viewModel)); }
public ActionResult Delete(int?id) { try { PlayerViewModel player = new PlayerViewModel(); var playerDTO = playerService.GetPlayer(id); player.Name = playerDTO.Name; player.Surname = playerDTO.Surname; return(View(player)); } catch (ValidationException e) { return(Content("Not Found")); } }
void PlayerInfoView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { PlayerViewModel model = e.OldValue as PlayerViewModel; if (model != null) { model.PropertyChanged -= _OnPropertyChanged; } model = e.NewValue as PlayerViewModel; if (model != null) { model.PropertyChanged += _OnPropertyChanged; cbRoleBox.DataContext = model.PossibleRoles; } }
public async void TestRepositoryDeletePlayer() { var repository = MakeRepository("TestRepositoryDeletePlayer"); var pvm = new PlayerViewModel() { userName = "******", password = "******" }; var createResult = await repository.CreatePlayer(pvm); var createdPlayer = createResult.Value; var deleteResult = await repository.DeletePlayer(createdPlayer.playerId); Assert.Null(deleteResult); }
public async void TestRepositoryCreatePlayer() { var repository = MakeRepository("TestRepositoryCreatePlayer"); var pvm = new PlayerViewModel() { userName = "******", password = "******" }; var result = await repository.CreatePlayer(pvm); var player = result.Value; Assert.Equal("tylercadena", player.userName); Assert.Equal("revature", player.password); }
// GET: /Player/Details/5 public ActionResult Details(int id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} var PlayerViewModel = new PlayerViewModel(id); if (PlayerViewModel == null) { return(HttpNotFound()); } return(View(PlayerViewModel)); }
public void MapPlayerViewModelToPlayer() { var viewModel = new PlayerViewModel { Id = 2, FirstName = "First Name", LastName = "Last Name" }; var mapper = new PlayerMapper(); var player = mapper.Map(viewModel); Assert.Equal(viewModel.Id, player.Id); Assert.Equal(viewModel.FirstName, player.FirstName); Assert.Equal(viewModel.LastName, player.LastName); }
public void InsertPlayer(PlayerViewModel player) { int playerID; if (player != null) { using (ApplicationDbContext ctx = new ApplicationDbContext()) { Player addPlayer = InsertNewPlayer(player, ctx); playerID = addPlayer.ID; InsertPlayerInClassification(player, playerID, ctx); ctx.Dispose(); } } }
public void Add(PlayerViewModel playerViewModel) { var config = _configuration.GetValue <string>("Config:AtletaBase64"); if (playerViewModel.Picture == "") { playerViewModel.Picture = Divers.Base64ToImage(config, "PLAYER"); } else { playerViewModel.Picture = Divers.Base64ToImage(playerViewModel.Picture, "PLAYER"); } _playerRepository.Add(_mapper.Map <Player>(playerViewModel)); }
public void Update(PlayerViewModel playerViewModel) { string[] picture = playerViewModel.Picture.Split('/'); if (picture[0] != "data:image") { playerViewModel.Picture = picture[picture.Count() - 1]; } else { playerViewModel.Picture = Divers.Base64ToImage(playerViewModel.Picture, "PLAYER"); } _playerRepository.Update(_mapper.Map <Player>(playerViewModel)); }
public LeagueViewModel(League league, bool isManager, bool userIsInLeague, bool userIsFollowingLeague) { LeagueID = league.LeagueID; LeagueName = league.LeagueName; LeagueManager = new PlayerViewModel(league, league.LeagueManager, false); IsManager = isManager; Archived = league.Archived; Years = league.Years; ActiveYear = Years.Max(); PublicLeague = league.PublicLeague; TestLeague = league.TestLeague; UserIsInLeague = userIsInLeague; UserIsFollowingLeague = userIsFollowingLeague; NumberOfFollowers = league.NumberOfFollowers; }
public async Task SaveTwoPlayersWithSameNames() { var clubsList = new List <Club> { new Club { Id = 1, Name = "Manchester United" } }; var countriesList = new List <Country> { new Country { Id = 1, Name = "Portugal", Code = "PT" } }; var playersList = new List <Player>(); var mockClubRepo = new Mock <IRepository <Club> >(); mockClubRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => clubsList.FirstOrDefault(c => c.Id == id)); var mockCountryRepo = new Mock <IRepository <Country> >(); mockCountryRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => countriesList.FirstOrDefault(c => c.Id == id)); var mockPlayerRepo = new Mock <IRepository <Player> >(); mockPlayerRepo.Setup(r => r.All()).Returns(playersList.AsQueryable()); mockPlayerRepo.Setup(r => r.AddAsync(It.IsAny <Player>())).Callback <Player>(player => playersList.Add(player)); var playerService = new PlayerService(mockPlayerRepo.Object, mockCountryRepo.Object, mockClubRepo.Object); var firstPlayerViewModel = new PlayerViewModel { Name = "Bruno Fernandesh", CountryId = 1, ClubId = 1 }; var secondPlayerViewModel = new PlayerViewModel { Name = "Bruno Fernandesh", CountryId = 1, ClubId = 1 }; await playerService.CreateAsync(firstPlayerViewModel); await Assert.ThrowsAsync <Exception>(() => playerService.CreateAsync(secondPlayerViewModel)); }
public IActionResult Post([FromBody] PlayerViewModel player) { try { if (ModelState.IsValid) { var gripStyle = _playerRepository.GetGripStyle(player.GripStyleId); var skillLevel = _playerRepository.GetSkillLevel(player.SkillLevelId); var newPlayer = new Player() { Id = player.PlayerId, Name = player.PlayerName, NickName = player.PlayerNickname, GripStyle = gripStyle, SkillLevel = skillLevel, Date = DateTime.Now }; _playerRepository.AddEntity(newPlayer); if (_playerRepository.SaveAll()) { var vm = new PlayerViewModel() { PlayerId = newPlayer.Id, PlayerName = newPlayer.Name, PlayerNickname = newPlayer.NickName, GripStyleId = newPlayer.GripStyle.Id, SkillLevelId = newPlayer.SkillLevel.Id, CreatedDate = newPlayer.Date }; return(Created($"/api/player/{vm.PlayerId}", vm)); } } else { return(BadRequest(ModelState)); } } catch (Exception ex) { _logger.LogError($"Failed to save new player {ex}"); } return(BadRequest("Failed to save new player")); }
public IActionResult Create(PlayerViewModel model) { if (!ModelState.IsValid) { return(View()); } var player = new Player() { Name = model.Name }; _playerRepository.AddPlayer(player); return(RedirectToAction("Index")); }
public void PointsPerGame_PointsAndGamesPlayed_CalculatesCorrectly() { var goals = 1; var assists = 1; var games = 2; var expectedResult = 1; var player = new PlayerViewModel { Goals = goals, Assists = assists, GamesPlayed = games }; Assert.That(player.PointsPerGame, Is.EqualTo(expectedResult)); }
public void AddsAnOwnedGame() { var playerViewModel = new PlayerViewModel { Id = 1, GameId = 1 }; var mockPlayerContext = new MockPlayerContext(); var controller = new PlayerController(mockPlayerContext); var result = controller.Add(playerViewModel); Assert.IsType <RedirectToRouteResult>(result); Assert.Equal("Index", result.RouteValues["action"]); Assert.Equal("Player", result.RouteValues["controller"]); mockPlayerContext.VerifyAddGameOwnedCalledWith(1, 1); }
public ActionResult Edit(PlayerViewModel model, HttpPostedFileBase playerImage) { if (ModelState.IsValid) { var player = Data.Players.GetById(model.Id); var updatedPlayer = Mapper.Map(model, player); playerService.UpdatePlayer(updatedPlayer, playerImage); return(this.RedirectToAction(c => c.Index())); } return(this.View(Views.Edit, model)); }
public PlayerViewModel EditedPlayer(PlayerViewModel playerViewModel) { Player player = _repo.GetPlayerById(playerViewModel.PlayerId); player.Fname = playerViewModel.Fname; player.Lname = playerViewModel.Lname; player.numLosses = playerViewModel.numLosses; player.numWins = playerViewModel.numWins; player.ByteArrayImage = _mapper.ConvertIformFileToByteArray(playerViewModel.IformFileImage); Player editedPlayer = _repo.EditPlayer(player); PlayerViewModel editedPlayerViewModel = _mapper.ConvertPlayerToPlayerViewModel(editedPlayer); return(editedPlayerViewModel); }
public async Task <IActionResult> AddPlayer(PlayerViewModel model) { if (ModelState.IsValid) { Player player = new Player() { Name = model.Name, Age = model.Age, TeamId = model.TeamId }; await _PlayerService.AddPlayer(player); return(RedirectToAction("TeamHome", "Team", new { id = model.TeamId })); } return(View(model)); }
public ActionResult Ranking() { var gameSessions = _context.GameSessions.Include(gs => gs.User).ToList(); var players = _context.Users.ToList(); var ranking = _context.GameSessions.OrderByDescending(gs => gs.Score).ToList(); var difficulties = _context.Difficulties.ToList(); var viewModel = new PlayerViewModel { Players = players, GameSessions = gameSessions, Ranking = ranking, Difficulties = difficulties }; return(View(viewModel)); }
public Player UpdatePlayer(PlayerViewModel playerVM) { var player = context.Players.Include(x => x.Orders).FirstOrDefault(p => p.GlobalUid == playerVM.GlobalUid); if (player is null) { return(null); } player.Points = playerVM.Points; player.Orders.ForEach(o => o.Reference = playerVM.Orders.FirstOrDefault(x => x.Id == o.Id)?.Reference); context.Update(player); context.SaveChanges(); return(player); }
/// <summary> /// takes a LoginPlayerView model instance and retunrs a PlayerViewModel instance /// </summary> /// <param name=""></param> /// <returns></returns> public PlayerViewModel LoginPlayer(LoginPlayerViewModel loginPlayerViewModel) { //have all logic confined to this business layer Player player = new Player() { Fname = loginPlayerViewModel.Fname, Lname = loginPlayerViewModel.Lname }; Player player1 = _repository.LoginPlayer(player); //convert Player to PlayerViewModel PlayerViewModel playerViewModel = _mapper.ConvertPlayerToPlayerViewModel(player1); return(playerViewModel); }
public void PointsPerGame_ZeroGamesPlayed_ReturnsZero() { var goals = 2; var assists = 2; var games = 0; var expectedResult = 0; var player = new PlayerViewModel { Goals = goals, Assists = assists, GamesPlayed = games }; Assert.That(player.PointsPerGame, Is.EqualTo(expectedResult)); }
public PlayerViewModel EditedPlayer(PlayerViewModel playerViewModel) { // get an instance of the player being edited. Player player = _repository.GetPlayerById(playerViewModel.playerId); player.Fname = playerViewModel.Fname; player.Lname = playerViewModel.Lname; player.numLosses = playerViewModel.numLosses; player.numWins = playerViewModel.numWins; player.ByteArrayImage = _mapperClass.ConvertIformFileToByteArray(playerViewModel.IformFileImage); //call the mapper class method ot convert the iformfile to byte[] Player player1 = _repository.EditPlayer(player); PlayerViewModel playerViewModel1 = _mapperClass.ConvertPlayerToPlayerViewModel(player1); return(playerViewModel1); }
/// ------------------------------------------------------------------------------------ public void Stop() { PlaybackInProgress = false; //_paused = false; _annotationPlaybackLoopCount = 0; DisableTimer(); PlayerViewModel.PlaybackStarted -= HandleMediaPlayStarted; PlayerViewModel.PlaybackEnded -= HandleMediaPlaybackEnded; PlayerViewModel.PlaybackPositionChanged = null; PlayerViewModel.Stop(); lock (_mediaFileQueue) { _mediaFileQueue.Clear(); } }
public void PlayerGivesPlayerMoney_ShouldRemoveAmountOfMoneyFromPlayerAndAddAmountOfMoneyToAnotherPlayer() { //Arrange int expectedCashPlayerOne = 1000; int expectedCashPlayerTwo = 3000; PlayerViewModel testPlayerTwo = new PlayerViewModel(new PlayerModel() { CurrentPosition = 0, AmountHotels = 0, AmountHouses = 0, FirstThrow = 0, PlayerCash = 2000, PlayerID = 0, PlayerName = "Test", PrisonRoll = 3 }); //Act testPlayer.PlayerGivesPlayerMoney(testPlayerTwo, 1000); //Assert Assert.Equal(expectedCashPlayerOne, testPlayer.PlayerCash); Assert.Equal(expectedCashPlayerTwo, testPlayerTwo.PlayerCash); }
public void PrevSong(PlayerViewModel main) { try { _offset -= 1; if (_offset == -1) { _offset = ApiDatas.Audio.Count - 1; } SetAudioInfo(main, true); } catch { SetAudioInfo(main, true); } }
private async void SetDurration(PlayerViewModel main) { try { await Task.Factory.StartNew(() => { Thread.Sleep(100); main.DurrationMaximum = main.Player.currentMedia.duration; main.MaximumTimePosition = main.Player.currentMedia.durationString; }); } catch { // ignored } }
private void Settings_Executed(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; PauseGame(); if (!ViewModel.IsGameRunning) { PlayerSettingsViewModel vm = TryShowSettings(); if (vm != null) { Controller.changePlayerSettings( new Tuple <Model.Player.Types, Model.Player.Types>(PlayerViewModel.PlayerTypeToModel(vm.WhitePlayer), PlayerViewModel.PlayerTypeToModel(vm.BlackPlayer)), new Tuple <string, string>(vm.WhitePlayer.Name, vm.BlackPlayer.Name), new Tuple <Model.Player.Levels, Model.Player.Levels>(PlayerViewModel.PlayerLevelToModel(vm.WhitePlayer), PlayerViewModel.PlayerLevelToModel(vm.BlackPlayer))); } } }
public PlayerDiagnostics(PlayerViewModel playerViewModel, AssetViewerViewModel assetViewerViewModel, BaseShellViewModel shellViewModel, ISettingsService settingsService, ScriptBridge scriptBridge) { EventHandler<ViewAttachedEventArgs> handler = null; this._playerViewModel = playerViewModel; this._assetViewerViewModel = assetViewerViewModel; this._baseShellViewModel = shellViewModel; this._settingsService = settingsService; if (handler == null) { handler = delegate (object s, ViewAttachedEventArgs e) { this._bufferingTimeMonitor = new BufferingTimeMonitor(this._playerViewModel.Instance); this._videoPlayer = this._playerViewModel.Instance; }; } this._playerViewModel.ViewAttached += handler; this._playerViewModel.PropertyChanged += new PropertyChangedEventHandler(this._playerViewModel_PropertyChanged); }
public ActionResult Index() { List<PlayerViewModel> players = new List<PlayerViewModel>(); StockEngine engine = new YahooStockEngine(); // Chris Player player = new Chris(); Investment investment = engine.GetCurrentInvestmentForPlayer(player.Name); Quote quote = engine.GetCurrentQuoteForPlayer(player.Name); PlayerViewModel model = new PlayerViewModel(investment, quote, player); players.Add(model); // Fiona player = new Fiona(); investment = engine.GetCurrentInvestmentForPlayer(player.Name); quote = engine.GetCurrentQuoteForPlayer(player.Name); model = new PlayerViewModel(investment, quote, player); players.Add(model); // Wilson player = new Wilson(); investment = engine.GetCurrentInvestmentForPlayer(player.Name); quote = engine.GetCurrentQuoteForPlayer(player.Name); model = new PlayerViewModel(investment, quote, player); players.Add(model); // Katherine player = new Katherine(); investment = engine.GetCurrentInvestmentForPlayer(player.Name); quote = engine.GetCurrentQuoteForPlayer(player.Name); model = new PlayerViewModel(investment, quote, player); players.Add(model); // Jon player = new Jon(); investment = engine.GetCurrentInvestmentForPlayer(player.Name); quote = engine.GetCurrentQuoteForPlayer(player.Name); model = new PlayerViewModel(investment, quote, player); players.Add(model); return View(players); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> /// <param name="collectionService"> /// The collection service. /// </param> /// <param name="service"> /// The service. /// </param> /// <param name="spotify"> /// The spotify. /// </param> /// <param name="audioticaService"> /// The audiotica service. /// </param> /// <param name="audioPlayer"> /// The audio player. /// </param> /// <param name="playerViewModel"></param> public MainViewModel( ICollectionService collectionService, IScrobblerService service, ISpotifyService spotify, IAudioticaService audioticaService, AudioPlayerHelper audioPlayer, PlayerViewModel playerViewModel) { PlayerViewModel = playerViewModel; _collectionService = collectionService; _service = service; _spotify = spotify; _audioticaService = audioticaService; _audioPlayer = audioPlayer; _collectionService.LibraryLoaded += CollectionServiceOnLibraryLoaded; _audioPlayer.TrackChanged += CollectionServiceOnLibraryLoaded; // Load data automatically LoadChartDataAsync(); }
private void OnNavigation(string destination) { switch (destination) { case "play": CurrentViewModel = new PlayViewModel(); break; case "player": CurrentViewModel = new PlayerViewModel(); break; case "customize": CurrentViewModel = new CustomizeViewModel(); break; case "statistics": CurrentViewModel = new StatisticsViewModel(); break; default: throw new ArgumentException($"Failed to navigate to '{destination}', the destination was not recognized"); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { ViewModel = new PlayerViewModel(); await ViewModel.StartListeningAsync(); Frame rootFrame = Window.Current.Content as Frame; if (rootFrame.CanGoBack) { // Show UI in title bar if opted-in and in-app backstack is not empty. SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; } else { // Remove the UI from the title bar if in-app back stack is empty. SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } }
public OnlineProfileViewModel(PhotoSelectorViewModel photoSelectorViewModel, AccountManager accountManager) { _photoSelectorViewModel = photoSelectorViewModel; _accountManager = accountManager; Player = new PlayerViewModel(accountManager.CurrentUser); }
public ItemBoughtEventArgs(CardViewModel purchasedCardID, PlayerViewModel purchasingPlayer) { this.PurchasedCard = purchasedCardID; this.PurchasingPlayer = purchasingPlayer; }
public void UpdateUI() { Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { var data = PokerGameObject.GetData(); if (!data.Players.Any()) { return; } ViewModel.Players.Clear(); data.Players.Select(x => { var p = new PlayerViewModel() { Name = x.Name, IsActive = x == data.ActivePlayer, Money = x.Wallet.Money }; var bet = data.Bets.FirstOrDefault(b => b.Player == x); if (bet != null) { p.CurrentBet = bet.Amount; } if (x.Cards.Any()) { p.Cards = new ObservableCollection<StandartCard>(x.Cards); } return p; }).ToList().ForEach(x => ViewModel.Players.Add(x)); ViewModel.Pot = data.Pot; ViewModel.DealerCards = new ObservableCollection<StandartCard>(data.DealerCards); ViewModel.RaiseAmount = 0; })); }