public async Task <ActionResult> Edit(Guid id) { var objective = await _objectivesRepository.GetObjectiveById(id); var model = new UpdateObjectiveViewModel { Title = objective.Title, Id = objective.Id, Created = objective.Created }; return(View(model)); }
public async Task <ActionResult> Edit(Guid id, [FromForm] UpdateObjectiveFormModel formModel) { if (!ModelState.IsValid) { var viewModel = new UpdateObjectiveViewModel { Title = formModel.Title }; return(View(nameof(Edit), viewModel)); } var objective = await _objectivesRepository.GetObjectiveById(id); objective.Title = formModel.Title; objective.Touch(); await _objectivesRepository.SaveObjective(objective); return(RedirectToAction(nameof(Details), new { id })); }