Example #1
0
        public IActionResult Edit(EditWorkTaskViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            var presenter = _presenterFactory.Edit(MessageHandler, ErrorHandler);
            var request   = vm.ToRequest(CurrentUserId);

            try
            {
                var uc       = _useCaseFactory.Edit;
                var response = uc.Execute(request);
                return(RedirectToAction(nameof(Index), new { id = presenter.Present(response) }));
            }
            catch (InvalidRequestException ire)
            {
                presenter.PresentErrors(ire.Message, ire.Errors);
                return(View(presenter.Present(vm)));
            }
            catch (Exception e)
            {
                presenter.PresentMessage(MessageType.Error, e.Message);
                return(View(presenter.Present(vm)));
            }
        }
 public static EditWorkTaskRequest ToRequest(this EditWorkTaskViewModel vm, string userId)
 {
     return(new EditWorkTaskRequest(userId)
     {
         Name = vm.Name,
         ParentTask = string.IsNullOrWhiteSpace(vm.ParentTaskId) ? Identity.BlankIdentity : Identity.FromString(vm.ParentTaskId),
         Description = vm.Description,
         ChildTasks = vm.ChildTaskIds.Select(Identity.FromString),
         StoryPoints = vm.StoryPoints,
         Id = Identity.FromString(vm.Id),
         Steps = vm.Steps,
         Documents = vm.SelectedDocumentIds.Select(Identity.FromString),
     });
 }
Example #3
0
        public EditWorkTaskViewModel Present(EditWorkTaskViewModel vm)
        {
            var project = RepositoryProvider.Project.Read(Identity.FromString(vm.Project.Id));
            var backlog = RepositoryProvider.Project.ReadProductBacklog(project.Id);

            var possibleParents = GetTasksFromBacklog(
                backlog,
                status => status != ProductBacklog.WorkTaskStatus.Done,
                CreateParentTypeFilter(Parse(vm.Type)));

            var possibleChildren = GetTasksFromBacklog(
                backlog,
                status => status != ProductBacklog.WorkTaskStatus.Done,
                CreateChildTypeFilter(Parse(vm.Type)));

            AddTasksThatDontExist(possibleChildren, vm.OriginalChildTaskIds);

            vm.ParentTasks = ToSelectListWithBlankEntry(possibleParents);
            vm.ChildTasks  = ToSelectListWithBlankEntry(possibleChildren);
            vm.Documents   = Documents(project.Id);

            return(vm);
        }