public ActionResult AppraisalInfo(int orderId)
		{
			if (orderId == 0)
				throw new ApplicationException(" GET APPraisal orderId == 0");

			if (!IsTabAvailable(OrderCreationWizardTabOrder.AppraisalInfo, orderId))
			{
				OrderCreationWizardTabOrder lastCompletedStep = GetOrderCreationLastCompletedStep(orderId);
				return RedirectToStep(lastCompletedStep, orderId);
			}

			var dataSource = new AppraisalFormsDataSource();
			OrderAppraisalInfoViewModel viewModel;

			if (TempData[_appraisalInfoKey] != null)
			{
				viewModel = (OrderAppraisalInfoViewModel)TempData[_appraisalInfoKey];
			}
			else
			{
				viewModel = _orderService.GetAppraisalInfo(orderId);
			}
			viewModel.FileName = viewModel.FileId.HasValue
														? _documentService.GetDocumentInfo(viewModel.FileId.Value).Name
														: string.Empty;

			if (viewModel.LoanType.HasValue)
			{
				dataSource.AppraisalForm = new Dictionary<string, string>();
				dataSource.AppraisalForm.Add(string.Empty, Constants.Text.NoSelection);
				foreach (
					var keyValuePair in
						_appraisalFormsService.GetAppraisalFormsData(Model.Enums.OrderManagement.AppraisalType.Appraisal,
																												 viewModel.LoanType.Value, viewModel.PropertyType, viewModel.Occupancy)
					)
				{
					dataSource.AppraisalForm.Add(keyValuePair.Key, keyValuePair.Value);
				}

				dataSource.ReviewForm = new Dictionary<string, string>();
				dataSource.ReviewForm.Add(string.Empty, Constants.Text.NoSelection);

				foreach (
					var keyValuePair in
						_appraisalFormsService.GetAppraisalFormsData(Model.Enums.OrderManagement.AppraisalType.Review,
																												 viewModel.LoanType.Value, viewModel.PropertyType, viewModel.Occupancy)
					)
				{
					dataSource.ReviewForm.Add(keyValuePair.Key, keyValuePair.Value);
				}
			}
			else
			{
				dataSource.AppraisalForm = new Dictionary<string, string> { { string.Empty, Constants.Text.NoSelection } };
				dataSource.ReviewForm = new Dictionary<string, string> { { string.Empty, Constants.Text.NoSelection } };
			}
			AppraisalFormsDataSource.SetDataSource(dataSource, ViewBag);

			return View(NameHelper.OrderCreationWizard.AppraisalInfo, GetViewModel(viewModel));
		}
示例#2
0
		public static void SetDataSource(AppraisalFormsDataSource dataSource, dynamic viewBag)
		{
			viewBag.AppraisalFormsDataSource = dataSource;
		}