public IActionResult Create(CreateSprintViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

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

            try
            {
                var uc       = _useCaseFactory.Create;
                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 ActionResult CreateSprint()
        {
            var SprintAccesses = _context.SprintAccesses.ToList();
            var SprintTypes    = _context.SprintTypes.ToList();
            var viewModel      = new CreateSprintViewModel
            {
                SprintAccess = SprintAccesses,
                SprintType   = SprintTypes
            };

            return(View(viewModel));
        }
Exemple #3
0
 public static CreateSprintRequest ToRequest(this CreateSprintViewModel vm, string userId)
 {
     return(new CreateSprintRequest(userId)
     {
         Goal = vm.Goal,
         Name = vm.Name,
         ProjectId = Identity.FromString(vm.Project.Id),
         TimeSpan = new Tuple <DateTime, DateTime>(
             DateTime.ParseExact(vm.StartDate, "yyyy-MM-dd", CultureInfo.InvariantCulture),
             DateTime.ParseExact(vm.EndDate, "yyyy-MM-dd", CultureInfo.InvariantCulture)),
         Stories = vm.SelectedStories.Select(Identity.FromString),
         Documents = vm.SelectedDocumentIds.Select(Identity.FromString),
     });
 }
Exemple #4
0
 public CreateSprintViewModel Present(CreateSprintViewModel vm)
 {
     vm.Stories   = Stories(Identity.FromString(vm.Project.Id));
     vm.Documents = Documents(Identity.FromString(vm.Project.Id));
     return(vm);
 }