public ActionResult Edit(int id) { BonusTaskFormViewModel viewModel = BonusTaskFormViewModel.CreateBonusTaskFormViewModel(); viewModel.BonusTask = bonusTaskRepository.Get(id); this.SetBreadcrumbText(viewModel.BonusTask.Name); return(View(viewModel)); }
public ActionResult Create() { BonusTaskFormViewModel viewModel = BonusTaskFormViewModel.CreateBonusTaskFormViewModel(); if (User != null) { viewModel.StartTime = User.Game.GameDate.AddMinutes(60); viewModel.FinishTime = User.Game.GameDate.AddMinutes(User.Game.TotalTime); } return(View(viewModel)); }
public ActionResult Create([BonusTaskBinder(Fetch = false)] BonusTask bonusTask) { if (ViewData.ModelState.IsValid && bonusTask.IsValid()) { bonusTask.Game = User.Game; bonusTaskRepository.SaveOrUpdate(bonusTask); TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "Бонусное задание успешно создано."; return(this.RedirectToAction <GamesController>(c => c.Edit(bonusTask.Game.Id))); } BonusTaskFormViewModel viewModel = BonusTaskFormViewModel.CreateBonusTaskFormViewModel(); viewModel.BonusTask = bonusTask; return(View(viewModel)); }
public ActionResult Edit([BonusTaskBinder(Fetch = true)] BonusTask bonusTask) { BonusTask bonusTaskToUpdate = bonusTaskRepository.Get(bonusTask.Id); TransferFormValuesTo(bonusTaskToUpdate, bonusTask); if (ViewData.ModelState.IsValid && bonusTask.IsValid()) { Message = "Бонусное задание успешно изменено."; return(this.RedirectToAction <GamesController>(c => c.Edit(bonusTaskToUpdate.Game.Id))); } else { bonusTaskRepository.DbContext.RollbackTransaction(); BonusTaskFormViewModel viewModel = BonusTaskFormViewModel.CreateBonusTaskFormViewModel(); viewModel.BonusTask = bonusTask; return(View(viewModel)); } }
/// <summary> /// Creation method for creating the view model. Services may be passed to the creation /// method to instantiate items such as lists for drop down boxes. /// </summary> public static BonusTaskFormViewModel CreateBonusTaskFormViewModel() { BonusTaskFormViewModel viewModel = new BonusTaskFormViewModel(); return(viewModel); }