Beispiel #1
0
 public EditGameViewModel MapModelToViewModel(EditGameModel editGameModel)
 {
     return new EditGameViewModel
     {
         GameId = editGameModel.GameId,
         HomeTeamId = editGameModel.HomeTeamId,
         AwayTeamId = editGameModel.AwayTeamId,
         HomeScore = editGameModel.HomeScore,
         AwayScore = editGameModel.AwayScore,
         GameDate = editGameModel.GameDate,
         FixtureTime = editGameModel.FixtureTime,
         Teams = editGameModel.Teams.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Text }).ToList()
     };
 }
Beispiel #2
0
 public void SetDomainFromModel(EditGameModel editGameModel, Game game)
 {
     game.GameId = editGameModel.GameId;
     game.HomeTeamId = editGameModel.HomeTeamId;
     game.AwayTeamId = editGameModel.AwayTeamId;
     game.HomeScore = editGameModel.HomeScore;
     game.AwayScore = editGameModel.AwayScore;
     game.GameDateTime = editGameModel.GameDate;
 }
Beispiel #3
0
        public void SaveEditGameModel(EditGameModel editGameModel)
        {
            if (editGameModel.GameId == 0)
            {
                Game game = new Game
                {
                    HomeTeamId = editGameModel.HomeTeamId,
                    AwayTeamId = editGameModel.AwayTeamId,
                    HomeScore = editGameModel.HomeScore,
                    AwayScore = editGameModel.AwayScore,
                    GameDateTime = editGameModel.GameDate
                };

                _gameRepository.InsertGame(game);
            }
            else
            {
                Game game = _gameRepository.GetGame(editGameModel.GameId);

                _mapper.SetDomainFromModel(editGameModel, game);

                _gameRepository.UpdateGame(game);
            }
        }