public ActionResult ShowUploadButton(bool? error, string errorMessage, int documentOriginTypeId = 0, bool canEditDocumentType = false, AttachDocumentReturnView returnView = AttachDocumentReturnView.GeneralRiskAssessmentDocuments, int documentTypeId = 0)
        {
            var viewModel = new DocumentUploadButtonViewModel() { DocumentOriginTypeId = documentOriginTypeId, CanEditDocumentType = canEditDocumentType, ReturnView = returnView, DocumentTypeId = documentTypeId };

            if (error.HasValue && error.Value)
            {
                viewModel.Error = true;
                viewModel.ErrorMessage = "An error occured.";
            }

            return View("~/Areas/Documents/Views/Document/DocumentUploadButton.cshtml", viewModel);
        }
        public ActionResult UploadDocument(DocumentUploadButtonViewModel viewModel)
        {
            try
            {
                viewModel.LastUploadedDocumentLibraryId = _documentLibraryUploader.Upload(viewModel.File.FileName, viewModel.File.InputStream);
                viewModel.LastUploadedDocumentFilename = viewModel.File.FileName;
                viewModel.DocumentUploaded = true;
            }
            catch (Exception ex)
            {
                viewModel.Error = true;
                viewModel.ErrorMessage = ex.Message;
                _peninsulaLog.Add(ex);
                LogExceptionInElmah(ex);
                _peninsulaLog.Add(viewModel);// help us to find out what part of the view model is null
            }

            return View("~/Areas/Documents/Views/Document/DocumentUploadButton.cshtml", viewModel);
        }
        public override void Setup()
        {
            base.Setup();

            _documentLibraryUploader
                .Setup(x => x.Upload(It.IsAny<string>(), It.IsAny<Stream>()))
                .Returns(_returnedDocLibraryId);

            _uploadedFile = new Mock<HttpPostedFileBase>();
            _uploadedFile.Setup(x => x.FileName).Returns(_uploadedFileName);

            _viewModel = new DocumentUploadButtonViewModel()
            {
                CanEditDocumentType = true,
                DocumentOriginTypeId = 1,
                DocumentTypeId = 2,
                LastUploadedDocumentFilename = "",
                File = _uploadedFile.Object
            };
        }