public static ExistingDocumentsViewModel CreateFrom(IEnumerable<TaskDocumentDto> documents)
        {
            var viewModel = new ExistingDocumentsViewModel();

            foreach (var previouslyAddedDocument in documents.Where(document => !document.Deleted))
            {
                var previouslyAddedDocumentGridRowViewModel = new PreviouslyAddedDocumentGridRowViewModel
                {
                    Id = previouslyAddedDocument.Id,
                    DocumentLibraryId =previouslyAddedDocument.DocumentLibraryId,
                    Description =previouslyAddedDocument.Description,
                    Filename = previouslyAddedDocument.Filename,
                    DocumentOriginType =previouslyAddedDocument.DocumentOriginType,
                };

                if (previouslyAddedDocument.DocumentType != null)
                    previouslyAddedDocumentGridRowViewModel.DocumentTypeName = previouslyAddedDocument.DocumentType.Name;

                viewModel.PreviouslyAddedDocuments.Add(previouslyAddedDocumentGridRowViewModel);
            }

            return viewModel;
        }
        public void given_action_id_and_company_id_when_get_view_model_then_existing_documents_are_returned()
        {
            //given
            var companyId = 123L;
            var actionId = 1L;

            var target = GetTarget(); 
            
            var assignedTo = new EmployeeDto
                                 {
                                     Id = Guid.NewGuid(),
                                     FullName = "employee'"
                                 };

         
            var task = new ActionTaskDto
                           {
                               Id = 1L,
                               Title = "Title",
                               Description = "Description",
                               TaskAssignedTo = assignedTo                               
                           };

            var action = new ActionDto
                               {
                                   Id = actionId,
                                   ActionTasks = new List<ActionTaskDto>
                                                     {
                                                         task
                                                     },                                                     
                               };
            _actionService
                .Setup(x => x.GetByIdAndCompanyId( actionId, companyId ))
                .Returns(action);

            ExistingDocumentsViewModel existingDocumentsViewModel = new ExistingDocumentsViewModel();            

            existingDocumentsViewModel.PreviouslyAddedDocuments = new List<PreviouslyAddedDocumentGridRowViewModel>();

            PreviouslyAddedDocumentGridRowViewModel padGridRowViewModel = new PreviouslyAddedDocumentGridRowViewModel();            
            padGridRowViewModel.Id = 1234L;
            padGridRowViewModel.Filename = "somefilename.doc";
            padGridRowViewModel.Description = "";
            padGridRowViewModel.DocumentLibraryId = 765L;
            padGridRowViewModel.DocumentOriginType = DocumentOriginType.TaskUpdated;
            padGridRowViewModel.DocumentTypeName = "somedocumenttype";
            

            existingDocumentsViewModel.PreviouslyAddedDocuments.Add(padGridRowViewModel);         

            _existingDocumentsViewModelFactory
                .Setup(x => x.GetViewModel(It.IsAny<IEnumerable<TaskDocumentDto>>()))
                .Returns(existingDocumentsViewModel);

            var result = target
              .WithCompanyId(companyId)
              .WithActionId(actionId)
              .GetViewModel();

            // then
            Assert.IsNotNull(result.ExistingDocuments);
            Assert.IsNotNull(result.ExistingDocuments.PreviouslyAddedDocuments);
            Assert.AreEqual( 1, result.ExistingDocuments.PreviouslyAddedDocuments.Count);
            Assert.AreEqual(padGridRowViewModel.Id, result.ExistingDocuments.PreviouslyAddedDocuments[0].Id);
            //Assert.AreEqual( DocumentTypeEnum.Action, result.ExistingDocuments.PreviouslyAddedDocuments[0].DocumentTypeName);
            Assert.AreEqual(DocumentOriginType.TaskUpdated, result.ExistingDocuments.PreviouslyAddedDocuments[0].DocumentOriginType);
        }