public async Task <WorkflowVM> WorkflowByProjectIdAndTaskId(string projectId, Int32 taskId, string user) { if (string.IsNullOrEmpty(projectId)) { throw new ArgumentException("String is null or empty", "projectId"); } if (string.IsNullOrEmpty(user)) { throw new ArgumentException("String is null or empty", "user"); } ExistingWorkflows existingWorkflows = new ExistingWorkflows(_ampRepository.GetWorkflowMastersByProjectandTask(projectId, taskId)); WorkflowRequest workflowRequest = new WorkflowRequest(_personService); WorkflowResponse workflowResponse = new WorkflowResponse(_personService); WorkflowConfiguration configuration = new WorkflowConfiguration(); WorkflowObject workflowObj = new WorkflowObject(_ampRepository, taskId, _documentService); string projectStage = _ampRepository.GetProject(projectId).Stage; string userRole = ""; if (taskId == Constants.PlannedEndDate) // set up the message to workflow screen for planned end date { ProjectPlannedEndDate projectPlannedEndDate = _ampRepository.GetProjectPlannedEndDate(projectId); string message = WorkflowMessages.PlannedEndDatePendingApprovalMessage(projectPlannedEndDate.NewPlannedEndDate); workflowObj.WfMessage = message; } if (existingWorkflows.HasActiveWorkflow()) { workflowRequest.workflow = existingWorkflows.ActiveWorkflowRequest(); workflowResponse.CreateResponse(workflowRequest.workflow); userRole = SetUserRole(user, projectId, workflowRequest.workflow.Recipient); } else if (existingWorkflows.LastWorkflowWasRejected()) { workflowRequest.workflow = existingWorkflows.LastRejectedWorkflowRequest(); workflowResponse.workflow = existingWorkflows.LastRejectedWorkflowResponse(); userRole = SetUserRole(user, projectId, workflowRequest.workflow.Recipient); } else { workflowRequest.CreateRequest(projectId, taskId, user); workflowResponse.response = new WorkflowMaster(); userRole = SetUserRole(user, projectId, null); } await workflowObj.Construct(workflowRequest, workflowResponse, userRole); return(workflowObj); }