Ejemplo n.º 1
0
        public async Task <WorkflowVM> WorkflowByWorkflowId(Int32 workflowId, string user)
        {
            string userRole;
            Int32  taskId;
            string projectId;

            ExistingWorkflows existingWorkflows = new ExistingWorkflows(_ampRepository.GetWorkflowMasters(workflowId));

            if (existingWorkflows.HasWorkflows())
            {
                WorkflowRequest       request       = new WorkflowRequest(_personService);
                WorkflowResponse      response      = new WorkflowResponse(_personService);
                WorkflowConfiguration configuration = new WorkflowConfiguration();
                WorkflowObject        workflowObj;
                request.workflow  = existingWorkflows.WorkflowRequest(workflowId);
                response.workflow = existingWorkflows.WorkflowResponse(workflowId);

                taskId    = request.workflow.TaskID;
                projectId = request.workflow.ProjectID;
                string projectStage = _ampRepository.GetProject(projectId).Stage;

                workflowObj = new WorkflowObject(_ampRepository, request.workflow.TaskID, _documentService);
                userRole    = SetUserRole(user, request.workflow.ProjectID, request.workflow.Recipient);

                await workflowObj.Construct(request, response, userRole);

                if (taskId == Constants.PlannedEndDate && response.workflow.StageID != 3)// set up the message to workflow screen for planned end date only if approved
                {
                    ProjectPlannedEndDate projectPlannedEndDate = _ampRepository.GetProjectPlannedEndDatForWorkflowHistory(workflowId);
                    string message = WorkflowMessages.PlannedEndDateWorkflowHistoryMessage(projectPlannedEndDate.CurrentPlannedEndDate, projectPlannedEndDate.NewPlannedEndDate);
                    workflowObj.WfMessage = message;
                }



                return(workflowObj);
            }

            return(null);
        }