Exemple #1
0
		public ActionResult ContactAdd(ContactInfoViewModel viewModel)
		{
			if (ValidateContactsModel())
			{
				ModelState.Clear();

				var itemToValidate = viewModel.ListOfContact.SingleOrDefault(e => e.IsEditable);

				if (itemToValidate != null)
				{
					if (!viewModel.ListOfContact.Any(i => string.IsNullOrEmpty(i.Email) && string.IsNullOrEmpty(i.Phone)))
					{
						ViewBag.NotificationMessage = itemToValidate.IsNew ? Constants.Notifications.ContactSaved : Constants.Notifications.ContactUpdated;
						_contactInfoService.SaveContactItem(itemToValidate, viewModel.OrderId);
						itemToValidate.IsEditable = false;
						CommitProviderInstance.Commit();
					}
					else
					{
						viewModel.AlertMessage = Constants.ErrorMessages.OrderContactPhoneEmail;
					}
				}
				viewModel.ListOfContact.Add(new DVS.Logic.ViewModels.Orders.ContactItemInfoViewModel() { Id = Guid.NewGuid().ToString(), IsEditable = true });

			}

			return GetContactTable(viewModel);
		}
Exemple #2
0
		private PartialViewResult GetContactTable(ContactInfoViewModel contactList)
		{
			ViewBag.Area = NameHelper.OrderFulfillmentManagement.Area;
			ViewBag.CurrentControllerName = NameHelper.OrderFulfillmentManagement.ContactInfo.Controller;
			ViewBag.HeaderText = "Point of Contact";
			return PartialView("Controls/Contacts", contactList);
		}
		public ActionResult ContactDel(ContactInfoViewModel viewModel, string contactDel)
		{
			if (ValidateContactsModel())
			{
				ModelState.Clear();
				var item = viewModel.ListOfContact.SingleOrDefault(e => e.Id == contactDel);
				if (item == null)
				{
					throw new ApplicationException("contact not found");
				}
				var itemToValidate = viewModel.ListOfContact.SingleOrDefault(e => e.IsEditable);


				if (itemToValidate != null)
				{
					_orderService.SaveContactItem(itemToValidate, viewModel.OrderId);
				}

				ViewBag.NotificationMessage = Constants.Notifications.ContactDeleted;
				_orderService.DeleteContactItem(viewModel.OrderId, item);
				CommitProviderInstance.Commit();
				viewModel = _orderService.GetOrderContacts(viewModel.OrderId);
			}

			return GetContactTable(viewModel);
		}
		public ActionResult ContactCancel(ContactInfoViewModel viewModel, string contactCancel)
		{
			ModelState.Clear();
			viewModel = _orderService.GetOrderContacts(viewModel.OrderId);
			return GetContactTable(viewModel);
		}
		public ActionResult ContactEdit(ContactInfoViewModel viewModel, string contactEdit)
		{
			if (ValidateContactsModel())
			{
				ModelState.Clear();
				var item = viewModel.ListOfContact.SingleOrDefault(e => e.Id == contactEdit);
				if (item == null)
				{
					throw new ApplicationException("license not found");
				}

				var itemToValidate = viewModel.ListOfContact.SingleOrDefault(e => e.IsEditable);

				if (itemToValidate != null)
				{
					if (!viewModel.ListOfContact.Any(i => string.IsNullOrEmpty(i.Email) && string.IsNullOrEmpty(i.Phone)))
					{
						ViewBag.NotificationMessage = itemToValidate.IsNew
																						? Constants.Notifications.ContactSaved
																						: Constants.Notifications.ContactUpdated;
						_orderService.SaveContactItem(itemToValidate, viewModel.OrderId);
						CommitProviderInstance.Commit();
					}
					else
					{
						viewModel.AlertMessage = Constants.ErrorMessages.OrderContactPhoneEmail;
					}
				}
				item.IsEditable = true;
				item.AlertMessage = null;

			}
			return GetContactTable(viewModel);
		}
		private PartialViewResult GetContactTable(ContactInfoViewModel contactList)
		{
			ViewBag.Area = "OrderManagement";
			ViewBag.CurrentControllerName = NameHelper.OrderCreationWizard.Controller;
			return PartialView("Controls/Contacts", contactList);
		}
		public ActionResult LoanAndContactInfo(OrderLoanAndContactInfoViewModel viewModel,
																					 ContactInfoViewModel contactViewModel, int nextStep)
		{
			var nextTab = SafeConvert.ToEnum<OrderCreationWizardTabOrder>(nextStep).Value;
			if (ValidateContactsModel())
			{
				var itemToValidate = contactViewModel.ListOfContact.SingleOrDefault(e => e.IsEditable);

				if (itemToValidate != null)
				{
					if (!contactViewModel.ListOfContact.Any(i => string.IsNullOrEmpty(i.Email) && string.IsNullOrEmpty(i.Phone)))
					{
						ViewBag.NotificationMessage = itemToValidate.IsNew
																						? Constants.Notifications.ContactSaved
																						: Constants.Notifications.ContactUpdated;
						_orderService.SaveContactItem(itemToValidate, viewModel.OrderId);
						itemToValidate.IsEditable = false;
						CommitProviderInstance.Commit();
					}
					else
					{
						if (!nextTab.Equals(OrderCreationWizardTabOrder.AppraisalInfo))
						{
							contactViewModel.AlertMessage = Constants.ErrorMessages.OrderContactPhoneEmail;
							viewModel.ContactInfo = contactViewModel;
							TempData[_orderLoanAndContactInfoKey] = viewModel;
							return RedirectToStep(OrderCreationWizardTabOrder.LoanAndContactInfo, viewModel.OrderId);
						}
					}
				}
			}
			else
			{
				if (!nextTab.Equals(OrderCreationWizardTabOrder.AppraisalInfo))
				{
					viewModel.ContactInfo.ListOfContact = contactViewModel.ListOfContact;
					TempData[_orderLoanAndContactInfoKey] = viewModel;
					return RedirectToStep(OrderCreationWizardTabOrder.LoanAndContactInfo, viewModel.OrderId);
				}
			}

			if (nextStep <= (int)OrderCreationWizardTabOrder.LoanAndContactInfo || (ModelState.IsValid && contactViewModel.ListOfContact.Any()))
			{
				_orderService.SaveLoanAndContactInfo(viewModel);
				bool isSavePressed = IsSavePressed(nextTab, OrderCreationWizardTabOrder.LoanAndContactInfo);
				SetLastCompletedStepAndStatus(OrderCreationWizardTabOrder.LoanAndContactInfo, nextStep, viewModel.OrderId, isSavePressed);

				CommitProviderInstance.Commit();

				return isSavePressed ? RedirectToClientPipeline() : RedirectToStep(nextTab, viewModel.OrderId);

			}
			else
			{
				if (!contactViewModel.ListOfContact.Any())
				{
					viewModel.ContactInfo.AlertMessage = Constants.ErrorMessages.OrderLaonAndContactEmptyContacts;
				}
				viewModel.ContactInfo.ListOfContact = contactViewModel.ListOfContact;

				TempData[_orderLoanAndContactInfoKey] = viewModel;
				return RedirectToStep(OrderCreationWizardTabOrder.LoanAndContactInfo, viewModel.OrderId);
			}
		}
Exemple #8
0
		public ContactInfoViewModel GetOrderContacts(int orderId)
		{
			var order = _orderManager.GetOrderById(orderId);
			CheckOrderAccessForClients(order, isWizardOnly: false);
			var viewModel = new ContactInfoViewModel(order.LoanAndContactInfo.Contacts, orderId);
			viewModel.IsCancelPopupNeeded = !IsOrderDraft(order);
			viewModel.OrderNumber = GetOrderNumber(order);
			return viewModel;
		}
		public OrderLoanAndContactInfoViewModel()
		{
			CurrentStep = OrderCreationWizardTabOrder.LoanAndContactInfo;
			ContactInfo = new ContactInfoViewModel();
			ContactInfo.OrderId = base.OrderId;
		}
		public void LoanAndContactInfo_Action_Should_Redirect_To_AppraisalInfo()
		{
			var contactInfo = new ContactInfoViewModel();
			contactInfo.ListOfContact.Add(new ContactItemInfoViewModel());
			_orderService.GetOrderContacts(Arg.Any<int>()).Returns(contactInfo);
			var actionResult = _target.LoanAndContactInfo(new OrderLoanAndContactInfoViewModel(), contactInfo, (int)OrderCreationWizardTabOrder.AppraisalInfo);

			actionResult.Should().NotBeNull().And.BeOfType<RedirectToRouteResult>();
			((RedirectToRouteResult)actionResult).RouteValues.Should().HaveCount(2);
			((RedirectToRouteResult)actionResult).RouteValues["action"].Should().Be(NameHelper.OrderCreationWizard.AppraisalInfo);
		}
Exemple #11
0
		public ActionResult ContactSave(ContactInfoViewModel viewModel, string contactSave)
		{
			if (ValidateContactsModel())
			{
				ModelState.Clear();
				var newItem = viewModel.ListOfContact.SingleOrDefault(e => e.Id == contactSave);
				if (newItem == null)
				{
					throw new ApplicationException("contact not found");
				}
				if (!viewModel.ListOfContact.Any(i => string.IsNullOrEmpty(i.Email) && string.IsNullOrEmpty(i.Phone)))
				{
					ViewBag.NotificationMessage = newItem.IsNew ? Constants.Notifications.ContactSaved : Constants.Notifications.ContactUpdated;
					_contactInfoService.SaveContactItem(newItem, viewModel.OrderId);

					CommitProviderInstance.Commit();
					viewModel = _contactInfoService.GetOrderContacts(viewModel.OrderId);
				}
				else
				{
					viewModel.AlertMessage = Constants.ErrorMessages.OrderContactPhoneEmail;
				}
			}
			return GetContactTable(viewModel);
		}