public ActionResult Edit(int id) { TipFormViewModel viewModel = TipFormViewModel.CreateTipFormViewModel(); viewModel.Tip = tipRepository.Get(id); viewModel.TaskId = viewModel.Tip.Task.Id; return(View(viewModel)); }
public ActionResult Create(int taskId) { TipFormViewModel viewModel = TipFormViewModel.CreateTipFormViewModel(); viewModel.Tip = new Tip { Name = "Новая подсказка", SuspendTime = 30 }; viewModel.TaskId = taskId; Task task = taskRepository.Get(taskId); viewModel.Tip.SuspendTime = task.Tips.Count * task.Game.TimePerTip; return(View(viewModel)); }
public ActionResult Create([TipBinder(Fetch = false)] Tip tip) { if (ViewData.ModelState.IsValid && tip.IsValid()) { taskRepository.Get(tip.Task.Id).Tips.Add(tip); tipRepository.SaveOrUpdate(tip); Message = "Подсказка успешно создана."; return(this.RedirectToAction <TasksController>(c => c.Edit(tip.Task.Id))); } TipFormViewModel viewModel = TipFormViewModel.CreateTipFormViewModel(); viewModel.Tip = tip; return(View(viewModel)); }
public ActionResult Edit([TipBinder(Fetch = true)] Tip tip) { Tip tipToUpdate = tipRepository.Get(tip.Id); TransferFormValuesTo(tipToUpdate, tip); if (ViewData.ModelState.IsValid && tip.IsValid()) { Message = "Подсказка успешно изменена."; return(this.RedirectToAction <TasksController>(c => c.Edit(tip.Task.Id))); } else { tipRepository.DbContext.RollbackTransaction(); TipFormViewModel viewModel = TipFormViewModel.CreateTipFormViewModel(); viewModel.Tip = tip; return(View(viewModel)); } }