Example #1
0
        public WorkflowViewModel(Workflow workflow, bool workflowAssignedToCurrentUser, IWorkflowDescription workflowDescription, ICollection <Document> uniqueMissingLineageDocuments)
        {
            Requires.NonNull(workflow, nameof(workflow));

            Workflow = workflow;
            var questions = workflow.WorkflowUnliqudatedObjectsWorkflowQuestions.OrderBy(q => q.UnliqudatedWorkflowQuestionsId).ToList();

            WorkflowAssignedToCurrentUser = workflowAssignedToCurrentUser;
            bool allowDocumentEdits        = workflowAssignedToCurrentUser;
            var  expectedDateForCompletion = workflow.TargetUlo.ExpectedDateForCompletion;

            if (workflowDescription != null)
            {
                QuestionsViewModel           = new UloWfQuestionsViewModel(workflowDescription.GetJustificationByKey(), questions.Where(q => !q.Pending).ToList());
                WorkflowDescriptionViewModel =
                    new WorkflowDescriptionViewModel(
                        workflow.WorkflowId,
                        workflowDescription.WebActionWorkflowActivities.ToList(),
                        workflow.CurrentWorkflowActivityKey);

                var pending = questions.Count > 0 && questions.Last().Pending ? questions.Last() : null;
                AdvanceViewModel   = new AdvanceViewModel(WorkflowDescriptionViewModel.CurrentActivity.QuestionChoices, pending, workflow, expectedDateForCompletion, WorkflowDescriptionViewModel.CurrentActivity.ExpectedDateForCompletionEditable);
                allowDocumentEdits = workflowAssignedToCurrentUser && WorkflowDescriptionViewModel.CurrentActivity.AllowDocumentEdit;
            }
            //throw new NotImplementedException("old code in need for porting!");

            RequestForReassignment = Workflow.WorkflowRequestForReassignments.OrderByDescending(z => z.RequestForReassignmentID).FirstOrDefault();
            DocumentsViewModel     = new DocumentsViewModel(workflow.WorkflowDocuments.ToList(), allowDocumentEdits, workflow.TargetUlo.DocType, uniqueMissingLineageDocuments, workflow.WorkflowId);
        }
        private void PopulateWorkflowDescriptionIntoViewBag(IWorkflowDescription workflowDescription, Workflow wf, string docType, string mostRecentNonReassignmentAnswer, string mostRecentRealAnswer)
        {
            ViewBag.JustificationByKey  = workflowDescription.GetJustificationByKey();
            ViewBag.WorkflowDescription = workflowDescription;
            var wawa = workflowDescription.Activities.FirstOrDefault(a => a.WorkflowActivityKey == wf.CurrentWorkflowActivityKey) as WebActionWorkflowActivity;
            var d    = new Dictionary <string, QuestionChoice>();

            ViewBag.QuestionChoiceByQuestionChoiceValue = d;
            wawa?.QuestionChoices?.WhereMostApplicable(docType, mostRecentNonReassignmentAnswer, mostRecentRealAnswer).ForEach(z => d[z.Value] = z);
        }