示例#1
0
        public virtual ActionResult Edit(int id, ApplicationUser currentUser)
        {
            var viewModel = new EditPlayedGameViewModel();

            viewModel              = (EditPlayedGameViewModel)FillCreatePlayedGameViewModel(currentUser, viewModel);
            viewModel.EditMode     = true;
            viewModel.PlayedGameId = id;

            FillCreatePlayedGameViewModel(currentUser, viewModel);

            var playedGame = _playedGameRetriever.GetPlayedGameDetails(id);

            viewModel.DatePlayed       = playedGame.DatePlayed;
            viewModel.Notes            = playedGame.Notes;
            viewModel.GameDefinitionId = playedGame.GameDefinitionId;

            var gameDefinition = _gameDefinitionRetriever.GetGameDefinitionDisplayInfo(playedGame.GameDefinitionId);

            viewModel.BoardGameGeekGameDefinitionId = gameDefinition.BoardGameGeekGameDefinitionId;
            viewModel.GameDefinitionName            = gameDefinition.Name;

            viewModel.PlayerRanks = playedGame.PlayerGameResults.Select(item => new CreatePlayerRankRequest {
                GameRank = item.GameRank, PlayerId = item.PlayerId, PlayerName = item.Player.Name, PointsScored = item.PointsScored
            }).ToList();

            return(View(MVC.PlayedGame.Views.CreateOrEdit, viewModel));
        }
示例#2
0
        public override void TestSetUp()
        {
            base.TestSetUp();

            _expectedEditPlayedGameViewModel = new EditPlayedGameViewModel();

            AutoMocker.ClassUnderTest.Expect(mock =>
                                             mock.MakeBaseCreatePlayedGameViewModel <EditPlayedGameViewModel>(Arg <int> .Is.Anything))
            .Return(_expectedEditPlayedGameViewModel);

            //PlayerList = new List<Player> {new Player {Id = 42, Name = "Smitty Werbenjagermanjensen"}};
            //PlayerSelectList = PlayerList
            //    .Select(item => new SelectListItem {Text = item.Name, Value = item.Id.ToString()}).ToList();
            //GameDefinitionList =
            //    new List<GameDefinition> {new GameDefinition {Id = 1, Name = "Betrayal At The House On The Hill"}};
            //GameDefinitionSelectList = GameDefinitionList
            //    .Select(item => new SelectListItem {Text = item.Name, Value = item.Id.ToString()}).ToList();
            //ExpectedPopulatedCompletedGameViewModel = new PlayedGameEditViewModel
            //{
            //    GameDefinitions = GameDefinitionSelectList,
            //    Players = PlayerSelectList
            //};
        }