public async Task <ActionResult> Add(Guid objectiveId, [FromForm] SaveKeyResultFormModel formModel) { var objective = await _objectivesRepository.GetObjectiveById(objectiveId); var keyResult = new KeyResult { Description = formModel.Description }; objective.AddKeyResult(keyResult); await _objectivesRepository.SaveObjective(objective); return(RedirectToAction("Details", "Objective", new { id = objectiveId })); }
private async Task CreateOrGetKeyResult(Objective objective, ApplicationUser user, string k) { var description = k.Trim(); if (objective.KeyResults.Any(x => x.Description == description)) { return; } objective.AddKeyResult(new KeyResult { Description = description }); await _objectivesRepository.SaveObjective(objective); }
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 })); }