public DocumentsViewModel GetViewModel()
        {
            var existingDocumentsViewModel = new ExistingDocumentsViewModel { CanDeleteDocuments = true, CanEditDocumentType = true, DocumentTypeId = (int)_documentType };
            
            var attachedDocuments = _riskAssessmentAttachmentService.GetRiskAssessmentAttachedDocuments(_riskAssessmentId, _companyId);
            foreach (var attachedDocument in attachedDocuments.Where(document => !document.Deleted))
            {
                existingDocumentsViewModel.PreviouslyAddedDocuments.Add(new PreviouslyAddedDocumentGridRowViewModel()
                {
                    Description = attachedDocument.Description,
                    DocumentTypeName = attachedDocument.DocumentType.Name,
                    Id = attachedDocument.Id,
                    DocumentLibraryId = attachedDocument.DocumentLibraryId,
                    Filename = attachedDocument.Filename,
                });
            };
            
            var model = new DocumentsViewModel()
            {
                CompanyId = _companyId,
                RiskAssessmentId = _riskAssessmentId,
                ExistingDocumentsViewModel = existingDocumentsViewModel,
                DocumentDisplayMessages = _displayMessages.Select(x => new HtmlString(x))
            };

            return model;
        }
Exemplo n.º 2
0
        public void When_get_index_Then_should_call_appropiate_methods()
        {
            // Given
            var controller = GetTarget();

            var viewModel = new DocumentsViewModel();
            _viewModelFactory
                .Setup(x => x.GetViewModel())
                .Returns(viewModel);

            // When
            controller.Index(_riskAssessmentId, _companyId);

            // Then
            _viewModelFactory.VerifyAll();
        }
Exemplo n.º 3
0
        public void When_get_index_Then_should_return_correct_view()
        {
            // Given
            var controller = GetTarget();

            _viewModelFactory
                .Setup(x => x.WithRiskAssessmentId(_riskAssessmentId))
                .Returns(_viewModelFactory.Object);

            var viewModel = new DocumentsViewModel();
            _viewModelFactory
                .Setup(x => x.GetViewModel())
                .Returns(viewModel);

            // When
            var result = controller.Index(_riskAssessmentId, _companyId) as ViewResult;

            // Then
            Assert.That(result.ViewName, Is.EqualTo("Index"));
        }
Exemplo n.º 4
0
 public OverviewViewModel()
 {
     Documents = new DocumentsViewModel();
     Documents.ExistingDocumentsViewModel = new ExistingDocumentsViewModel();
     AccidentRecordNotificationMemberEmails = new List<AccidentRecordNotificationMemberEmail>();
 }        
Exemplo n.º 5
0
        public void When_get_index_Then_should_return_correct_viewmodel_type()
        {
            // Given
            var controller = GetTarget();

            var viewModel = new DocumentsViewModel();
            _viewModelFactory
                .Setup(x => x.GetViewModel())
                .Returns(viewModel);

            // When
            var result = controller.Index(_riskAssessmentId, _companyId) as ViewResult;

            // Then
            Assert.That(result.Model, Is.TypeOf<DocumentsViewModel>());
        }