Пример #1
0
        private static TaskViewModel CreateFrom(TaskDto task)
        {
            var taskViewModel = new TaskViewModel
                                    {
                                        Id = task.Id,
                                        Reference = task.Reference,
                                        Title = task.Title,
                                        Description = task.Description,
                                        TaskAssignedTo = task.TaskAssignedTo.FullName,
                                        TaskCategory = task.TaskCategory.Category,
                                        IsDeleted = task.Deleted,
                                        IsReoccurring = task.IsReoccurring,
                                        TaskStatus = task.TaskStatusString.AddSpacesToName(),
                                        DerivedDisplayStatus = EnumHelper.GetEnumDescription(task.DerivedDisplayStatus),
                                        TaskReoccurringType = task.TaskReoccurringType,
                                        TaskReoccurringEndDate = task.TaskReoccurringEndDate,
                                        CreatedDate = task.CreatedDate,
                                        TaskCompletionDueDate = task.TaskCompletionDueDate,
                                        HasDocuments = task.Documents.Any(),
                                        HasCompletedDocuments = task.Documents.Any(d => d.DocumentOriginType == DocumentOriginType.TaskCompleted),
                                        TaskType = task.GetType().Name,
                                        TaskGuid = task.TaskGuid,
                                        CompletedBy = task.TaskCompletedBy != null ? task.TaskCompletedBy.FullName : string.Empty,
                                        CompletedOn = task.TaskCompletedDate.HasValue ? task.TaskCompletedDate.Value.ToLocalShortDateString() : string.Empty
                                    };

            if (taskViewModel.IsReviewTask())
            {
                var riskAssessmentReviewTaskDto = task as RiskAssessmentReviewTaskDto;
                
                taskViewModel.RiskAssessmentId = riskAssessmentReviewTaskDto != null && riskAssessmentReviewTaskDto.RiskAssessment != null
                                                     ? riskAssessmentReviewTaskDto.RiskAssessment.Id
                                                     : default(long);

                taskViewModel.Title = riskAssessmentReviewTaskDto.RiskAssessment.Title;
                taskViewModel.Reference = riskAssessmentReviewTaskDto.RiskAssessment.Reference;

            }

            return taskViewModel;
        }
Пример #2
0
        public void Given_task_is_a_review_When_IsReviewTask_Then_should_return_true()
        {
            //Given
            var user = new Mock<IPrincipal>();
            user.Setup(x => x.IsInRole(It.IsAny<string>())).Returns(true);

            var taskViewModel = new TaskViewModel()
            {
                TaskType = "RiskAssessmentReviewTaskDto"
            };

            //When
            var result = taskViewModel.IsReviewTask();

            //Then
            Assert.IsTrue(result);
        }