Example #1
0
		public void GetDocumentsViewModel_should_return_DocumentsViewModel()
		{
			var documentsInput = new List<OrderDocumentInfo>() { };
			documentsInput.Add(new OrderDocumentInfo() { DocumentTypeId = 1, FileId = new Guid("11111111-1111-1111-1111-111111111111"), UserType = DocumentUserType.Lender });
			_documentService.GetDocumentInfo(new Guid("11111111-1111-1111-1111-111111111111")).Returns(new DocumentInfo() { AddedByUserId = 1, DateAdded = new DateTime(2012,8,8) });
			_orderDocumentsRepository.GetDocumentsForOrder(Arg.Any<int>()).ReturnsForAnyArgs( documentsInput );
			_referenceManagement.GetReference(Arg.Any<ReferenceType>(), Arg.Any<bool>()).ReturnsForAnyArgs(new Dictionary<int, string>() { { 1, "Other" } });
			_orderManager.GetOrderById(Arg.Any<int>()).ReturnsForAnyArgs(new Order());
			_userManagement.GetById(Arg.Any<int>()).ReturnsForAnyArgs(new User() { FirstName = "John", LastName = "Black", Email = "*****@*****.**" });

			var modelExpected = new DocumentsViewModel() { PropertyAppraisalReceiptFileId = Guid.Empty };
			modelExpected.AppraisalDocuments = new List<UploadDocument>();
			modelExpected.LenderDocuments = new List<UploadDocument>();
			modelExpected.LenderDocuments.Add(new UploadDocument() { UploadDate = new DateTime(2012, 8, 8), UploadUserName = "******", UploadUserEmail = "*****@*****.**", FileId = new Guid("11111111-1111-1111-1111-111111111111"), DocumentType = "Other" });
			var modelReturn = _target.GetDocumentsViewModel(Arg.Any<int>());

			modelReturn.AppraisalDocuments.Should().BeEquivalentTo(modelExpected.AppraisalDocuments);
			modelReturn.ContactFileId.Should().Be(modelExpected.ContactFileId);
			modelReturn.DocumentDescription.Should().BeEquivalentTo(modelExpected.DocumentDescription);
			modelReturn.DocumentType.Should().Be(modelExpected.DocumentType);
			modelReturn.FileName.Should().BeEquivalentTo(modelExpected.FileName);
			modelReturn.LenderDocuments[0].DocumentDescription.Should().BeEquivalentTo(modelExpected.LenderDocuments[0].DocumentDescription);
			modelReturn.LenderDocuments[0].DocumentType.Should().BeEquivalentTo(modelExpected.LenderDocuments[0].DocumentType);
			modelReturn.LenderDocuments[0].FileId.Should().Be(modelExpected.LenderDocuments[0].FileId);
			modelReturn.LenderDocuments[0].UploadDate.Should().Be(modelExpected.LenderDocuments[0].UploadDate);
			modelReturn.LenderDocuments[0].UploadUserEmail.Should().BeEquivalentTo(modelExpected.LenderDocuments[0].UploadUserEmail);
			modelReturn.LenderDocuments[0].UploadUserName.Should().BeEquivalentTo(modelExpected.LenderDocuments[0].UploadUserName);
			modelReturn.PropertyAppraisalReceiptFileId.Should().Be(modelExpected.PropertyAppraisalReceiptFileId);
		}
Example #2
0
		public DocumentsViewModel GetDocumentsViewModel(int orderId)
		{
			var model = new DocumentsViewModel();
			var documents = _orderDocumentsRepository.GetDocumentsForOrder(orderId);
			var documentTypes = _referenceManagement.GetReference(ReferenceType.DocumentType, true);

			foreach (var item in documents)
			{
				var documentInfo = _documentService.GetDocumentInfo(item.FileId.Value);
				var userInfo = GetUserShortInfo(documentInfo.AddedByUserId.Value);
				var uploadDocument = new UploadDocument()
				{
					DocumentType = documentTypes[item.DocumentTypeId],
					FileId = item.FileId.Value,
					DocumentDescription = item.DocumentDescription,
					UploadDate = documentInfo.DateAdded,
					UploadUserEmail = userInfo["Email"],
					UploadUserName = userInfo["FullName"]
				};

				if (item.UserType == DocumentUserType.Appraisal)
					model.AppraisalDocuments.Add(uploadDocument);
				else model.LenderDocuments.Add(uploadDocument);
			}

			model.OrderId = orderId;

			model.AppraisalDocuments = model.AppraisalDocuments.OrderByDescending(el => el.UploadDate).ToList();
			model.LenderDocuments = model.LenderDocuments.OrderByDescending(el => el.UploadDate).ToList();

			return model;
		}
Example #3
0
		public ActionResult Index(DocumentsViewModel model)
		{
			if (ModelState.IsValid)
			{
				if (model.DocumentType != (int)DocumentType.Other && !string.IsNullOrEmpty(model.DocumentDescription))
					return View(model);
				var appraiserOrderId = PluginResults.Find<OrderFulfillmentPluginResult>().AppraiserOrderId;
				var orderId = PluginResults.Find<OrderFulfillmentPluginResult>().OrderId;
				var userType = _orderDocumentService.AddOrderDocument(orderId, model.ContactFileId.Value, model.DocumentType, model.DocumentDescription);
				CommitProviderInstance.Commit();
				TempData["UserType"] = userType;
				TempData["AlertMessage"] = "File was successfully saved.";
				return RedirectToAction(NameHelper.OrderFulfillmentDocuments.Index, NameHelper.OrderFulfillmentDocuments.Controller, new { orderId, appraiserOrderId, area = "OrderFulfillment" });

			}
			return View(model);
		}