public async Task <ActionResult> Create(CreateObjectiveFormModel model) { var user = await _currentContext.GetCurrentUser(); var objective = new Objective(model.Title, user.UserId); await _objectivesRepository.CreateObjective(objective); return(RedirectToAction(nameof(Details), new { id = objective.Id })); }
private async Task <Objective> CreateOrGetObjective(Dictionary <string, Objective> objectiveLookup, ApplicationUser user, string o) { var title = o.Trim(); if (objectiveLookup.ContainsKey(title)) { return(objectiveLookup[title]); } var newObjective = new Objective(title, user.UserId); await _objectivesRepository.CreateObjective(newObjective); objectiveLookup.Add(title, newObjective); return(newObjective); }