Beispiel #1
0
        private CompletionTaskContext CreateContext(ApprovalTaskViewModel viewModel)
        {
            var task         = unitOfWork.GetRepository <ApprovalTask>().GetById(viewModel.Id);
            var relatedTasks =
                unitOfWork.GetRepository <ApprovalTask>()
                .Get(x => x.CreditApplicationId == task.CreditApplicationId && x.Id != task.Id);
            var context = new CompletionTaskContext
            {
                TaskForComplete = task,
                RelatedTasks    = relatedTasks,
                ViewModel       = viewModel,
            };

            return(context);
        }
Beispiel #2
0
        public void CompleteApprovalTask(ApprovalTaskViewModel viewModel)
        {
            Contract.NotEmptyGuid(viewModel.Id);
            Contract.NotNull(viewModel, "ApprovalTaskViewModel cannot be null");
            Contract.NotNull(viewModel.OutcomeViewModel, "OutcomeViewModel cannot be null");
            Contract.NotNull(viewModel.OutcomeViewModel.SelectedOutcome, "SelectedOutcome cannot be null");
            Contract.NotNull(viewModel.RejectionReasonViewModel, "RejectionReasonViewModel cannot be null");
            if (viewModel.OutcomeViewModel.SelectedOutcome == Outcome.Reject)
            {
                Contract.NotNull(viewModel.RejectionReasonViewModel.SelectedRejectionReason, "SelectedRejectionReason cannot be null");
            }

            var context   = CreateContext(viewModel);
            var processor = completeTaskProcessorResolver.Find(context.TaskForComplete.ApprovalType);

            processor.Run(context);
        }
Beispiel #3
0
 public ActionResult Work([Bind(Include = "Id, OutcomeViewModel, RejectionReasonViewModel")] ApprovalTaskViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         ApplicationUserManager userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
         viewModel.UserRoles = userManager.GetRoles(User.Identity.GetUserId());
         viewModel.UserId    = User.Identity.GetUserId();
         try
         {
             taskManager.CompleteApprovalTask(viewModel);
         }
         catch (BusinessException e)
         {
             TempData["ErrorMessage"] = e.Message;
             return(RedirectToAction("Work", new { id = viewModel.Id }));
         }
     }
     return(RedirectToAction("Index"));
 }