public ActionResult Edit(int id) { GameFormViewModel viewModel = GameFormViewModel.CreateGameFormViewModel(); viewModel.Game = gameRepository.Get(id); this.SetBreadcrumbText(viewModel.Game.Name); return(View(viewModel)); }
public ActionResult Create(Game game) { if (ViewData.ModelState.IsValid && game.IsValid()) { gameRepository.SaveOrUpdate(game); Message = "Игра успешно создана."; return(this.RedirectToAction(c => c.Index())); } GameFormViewModel viewModel = GameFormViewModel.CreateGameFormViewModel(); viewModel.Game = game; return(View(viewModel)); }
public ActionResult Edit(Game game) { Game gameToUpdate = gameRepository.Get(game.Id); TransferFormValuesTo(gameToUpdate, game); if (ViewData.ModelState.IsValid && game.IsValid()) { Message = "Игра успешно изменена."; return(this.RedirectToAction(c => c.Index())); } gameRepository.DbContext.RollbackTransaction(); GameFormViewModel viewModel = GameFormViewModel.CreateGameFormViewModel(); viewModel.Game = game; return(View(viewModel)); }
public ActionResult Create() { GameFormViewModel viewModel = GameFormViewModel.CreateGameFormViewModel(); return(View(viewModel)); }