예제 #1
0
        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 }));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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 }));
        }