Пример #1
0
		public Order SaveGeneralInfo(OrderGeneralInfoViewModel viewModel)
		{
			var companyId = string.IsNullOrWhiteSpace(viewModel.DefaultLenderCompanyId) ? default(int?) : int.Parse(viewModel.DefaultLenderCompanyId);
			var branchId = string.IsNullOrWhiteSpace(viewModel.DefaultLenderBranchId) ? default(int?) : int.Parse(viewModel.DefaultLenderBranchId);

			var order = viewModel.IsNew ? _orderManager.CreateNewOrder(_securityContext.CurrentUser.Id, companyId, branchId) : _orderManager.GetOrderById(viewModel.OrderId);
			CheckOrderAccessForClients(order);

			order.ClientCompanyId = companyId;
			order.ClientCompanyBrancheId = branchId;

			var orderGeneralInfo = order.GeneralInfo == null ? new OrderGeneralInfo() : order.GeneralInfo;
			order.GeneralInfo = orderGeneralInfo;

			orderGeneralInfo.BorrowerFirstName = viewModel.BorrowerFirstName;
			orderGeneralInfo.BorrowerLastName = viewModel.BorrowerLastName;
			orderGeneralInfo.LoanNumber = viewModel.LoanNumber;

			if (orderGeneralInfo.PropertyAddress == null)
				orderGeneralInfo.PropertyAddress = new Address();

			_addressManager.FillAddressWithCounty(orderGeneralInfo.PropertyAddress, viewModel.Address);

			var geocodingAddress = new GeocodingArg(viewModel.Address.Street, viewModel.Address.City, viewModel.Address.State, viewModel.Address.ZIP);
			_geocodingDataService.ResolveData(geocodingAddress, (location, containResult) =>
			{
				double latitube;
				double longitude;
				Double.TryParse(location.Latitude, out latitube);
				Double.TryParse(location.Longitude, out longitude);
				order.Latitude = latitube;
				order.Longitude = longitude;
				order.GeocodingCounty = location.County;
			});

			return order;
		}
Пример #2
0
		public ActionResult GeneralInfo(OrderGeneralInfoViewModel viewModel, int nextStep)
		{
			int? orderId = viewModel.IsNew ? null : (int?)viewModel.OrderId;
			var nextTab = SafeConvert.ToEnum<OrderCreationWizardTabOrder>(nextStep).Value;

			if (nextStep <= (int)OrderCreationWizardTabOrder.GeneralInfo || ModelState.IsValid)
			{
				var order = _orderService.SaveGeneralInfo(viewModel);
				CommitProviderInstance.Commit();


#warning need to refactoring
				int maxIterations = 1000;
				while (order.Id == default(int))
				{
					Thread.Sleep(100);
					if (maxIterations-- == 0)
						throw new ApplicationException("Iterations = 1000");
				}

				orderId = order.Id;

				bool isSavePressed = IsSavePressed(nextTab, OrderCreationWizardTabOrder.GeneralInfo);
				SetLastCompletedStepAndStatus(OrderCreationWizardTabOrder.GeneralInfo, nextStep, orderId.Value, isSavePressed);

				if (viewModel.IsNew)
				{
					_orderHistoryManager.AddOrderCreatedNote(orderId.Value);
				}

				CommitProviderInstance.Commit();

				if (orderId == 0)
					throw new ApplicationException("POST gen info orderId == 0");
				return isSavePressed ? RedirectToClientPipeline() : RedirectToStep(nextTab, orderId);
			}
			else
			{
				TempData[_orderGeneralInfoKey] = viewModel;
				return RedirectToStep(OrderCreationWizardTabOrder.GeneralInfo, orderId);
			}
		}
Пример #3
0
		public OrderGeneralInfoViewModel LoadGeneralInfo(int? orderId)
		{
			var viewModel = new OrderGeneralInfoViewModel();
			viewModel.Address = new AddressWithCountyViewModel();
			viewModel.IsCancelPopupNeeded = true;
			if (orderId.HasValue)
			{
				var order = _orderManager.GetOrderById(orderId.Value);
				CheckOrderAccessForClients(order);
				var state = _referenceManager.FindState(order.GeneralInfo.PropertyAddress.State);
				viewModel = new OrderGeneralInfoViewModel(order.GeneralInfo, state);
				viewModel.DefaultLenderCompanyId = order.ClientCompanyId.HasValue ? order.ClientCompanyId.Value.ToString() : string.Empty;
				viewModel.DefaultLenderBranchId = order.ClientCompanyBrancheId.HasValue ? order.ClientCompanyBrancheId.Value.ToString() : string.Empty;
				viewModel.IsCancelPopupNeeded = !IsOrderDraft(order);
				viewModel.OrderNumber = GetOrderNumber(order);
			}
			else
			{
				var user = _securityContext.CurrentClientUser;
				if (user.Company.Settings != null)
				{
					viewModel.DefaultLenderCompanyId = user.Company.Settings.DefaultLenderCompanyId.HasValue ? user.Company.Settings.DefaultLenderCompanyId.Value.ToString() : string.Empty;
					viewModel.DefaultLenderBranchId = user.Company.Settings.DefaultLenderBranchId.HasValue ? user.Company.Settings.DefaultLenderBranchId.Value.ToString() : string.Empty;
				}
			}

			return viewModel;

		}