public void FeeAdd_should_add_editable_fee_to_model()
		{
			var controller = new AppraisalCompanyFeesController(Substitute.For<IAppraisalCompanyService>(), Substitute.For<IAppraiserManagement>());
			var result = new List<RefFeeProductType>();
			result.Add(new RefFeeProductType() { DisplayName = "Test", Id = 1 });
			_refRepository.GetFeeProductTypes().Returns(result);
			var model = new AppraisalCompanyFeesViewModel();
			var actionResult = controller.FeeAdd(model);
			actionResult.Should().NotBeNull().And.BeOfType<PartialViewResult>();
			((PartialViewResult)actionResult).ViewName.Should().Be("Tables/AppraisalCompanyFees");
			model.Fees.FeesItems.Count.Should().Be(1);
			model.Fees.FeesItems[0].IsEditable.Should().BeTrue();

		}
		public void FeeAdd_should_not_add_fee_if_fees_for_all_products_are_specified()
		{
			var controller = new AppraisalCompanyFeesController(Substitute.For<IAppraisalCompanyService>(), Substitute.For<IAppraiserManagement>());
			var model = new AppraisalCompanyFeesViewModel();
			foreach (var product in Singletones.ReferenceManager.GetReference(ReferenceType.FeeProducts, false))
			{
				var fee = new FeeItemViewModel();
				fee.ProductType = product.Key;
				model.Fees.FeesItems.Add(fee);
			}
			var actionResult = controller.FeeAdd(model);
			actionResult.Should().NotBeNull().And.BeOfType<PartialViewResult>();
			((PartialViewResult)actionResult).ViewName.Should().Be("Tables/AppraisalCompanyFees");
			((string)((PartialViewResult)actionResult).ViewBag.NotificationMessage).Should().BeEquivalentTo("You have already specified Fee for each available Product Type.");
			model.Fees.FeesItems.Count.Should().Be(model.Fees.FeesItems.Count);
		}
		public ActionResult FeeAdd(AppraisalCompanyFeesViewModel model)
		{
			if (ModelState.IsValid)
			{
				ModelState.Clear();
				var editedItem = model.Fees.FeesItems.SingleOrDefault(e => e.IsEditable);
				if (editedItem != null)
				{
					AddFeeToSession(editedItem);
				}
				if (model.Fees.FeesItems.Count != Singletones.ReferenceManager.GetReference(ReferenceType.FeeProducts, false).Count)
				{
					model.Fees.FeesItems.Add(new FeeItemViewModel() { Id = Guid.NewGuid().ToString(), IsEditable = true });
				}
				else
				{
					ViewBag.IsAllFeesMessage = true;
					ViewBag.NotificationMessage = Constants.ErrorMessages.FeesAllAvailableSpecified;
				}
			}
			return PartialView("Tables/AppraisalCompanyFees", model);
		}
		public ActionResult FeeSave(AppraisalCompanyFeesViewModel model, string FeeSave)
		{
			if (ModelState.IsValid)
			{
				ModelState.Clear();
				var newItem = model.Fees.FeesItems.SingleOrDefault(e => e.Id == FeeSave);
				if (newItem == null)
				{
					throw new ApplicationException("fee not found");
				}
				AddFeeToSession(newItem);
			}
			return PartialView("Tables/AppraisalCompanyFees", model);
		}
		public ActionResult FeeDel(AppraisalCompanyFeesViewModel model, string FeeDel)
		{
			ModelState.Clear();
			var item = model.Fees.FeesItems.SingleOrDefault(e => e.Id == FeeDel);
			if (item == null)
			{
				throw new ApplicationException("fee not found");
			}
			var editdItem = model.Fees.FeesItems.SingleOrDefault(e => e.IsEditable);
			if (editdItem != null)
			{
				AddFeeToSession(editdItem);
			}
			model.Fees.FeesItems.Remove(item);
			return PartialView("Tables/AppraisalCompanyFees", model);
		}
		public ActionResult FeeCancel(AppraisalCompanyFeesViewModel model, string FeeCancel)
		{
			ModelState.Clear();
			var item = model.Fees.FeesItems.SingleOrDefault(e => e.Id == FeeCancel);
			if (item == null)
			{
				throw new ApplicationException("license not found");
			}
			var oldItem = ModelWithFeeShedulingList.Fees.FeesItems.SingleOrDefault(e => e.Id == FeeCancel);
			if (oldItem == null)
			{
				model.Fees.FeesItems.Remove(item);
				return PartialView("Tables/AppraisalCompanyFees", model);
			}
			int index = model.Fees.FeesItems.IndexOf(item);
			model.Fees.FeesItems.Remove(item);
			model.Fees.FeesItems.Insert(index, oldItem);
			return PartialView("Tables/AppraisalCompanyFees", model);
		}
Esempio n. 7
0
		public AppraisalCompanyFeesViewModel GetAppraisalCompanyFees(int appraisalCompanyId)
		{
			var appraisalCompany = _appraisalCompanyManagement.GetAppraisalCompanyById(appraisalCompanyId);

			var appraisalCompanyFees = new AppraisalCompanyFeesViewModel();
			if (appraisalCompany.Fees != null)
			{
				appraisalCompanyFees.Fees = _feeManager.GetFeesViewModel(appraisalCompany.Fees);
			}
			else
			{
				appraisalCompanyFees.Fees = new FeesViewModel();
			}
			return appraisalCompanyFees;
		}
Esempio n. 8
0
		public void SaveAppraisalCompanyFees(int appraisalCompanyId, AppraisalCompanyFeesViewModel appraisalCompanyFees)
		{
			var appraisalCompany = _appraisalCompanyManagement.GetAppraisalCompanyById(appraisalCompanyId);

			if (appraisalCompany.Fees == null)
			{
				appraisalCompany.Fees = new List<AppraiserFee>();
			}
			_feeManager.FillFees(appraisalCompany.Fees, appraisalCompanyFees.Fees);
		}
		public void FeeAdd_should_save_editable_fee()
		{
			var viewContext = new ViewContext();
			viewContext.HttpContext = MockHttpContext.FakeHttpContext();
			IPrincipal user = new GenericPrincipal(new GenericIdentity("someUser"), null);
			viewContext.HttpContext.User.ReturnsForAnyArgs<IPrincipal>(user);
			var appraisalCompanyAdminManagement = Substitute.For<IAppraiserManagement>();
			var appraisalCompanyWizardService = Substitute.For<IAppraisalCompanyService>();
			appraisalCompanyAdminManagement.GetByEmail(Arg.Any<string>()).Returns(new AppraiserUser() { Company = new AppraisalCompanyDetail() { Id = 0 } });
			appraisalCompanyWizardService.GetAppraisalCompanyFees(Arg.Any<int>()).Returns(new AppraisalCompanyFeesViewModel());

			var controller = new AppraisalCompanyFeesController(appraisalCompanyWizardService, appraisalCompanyAdminManagement);
			controller.SetFakeControllerContext(viewContext.HttpContext);
			var model = new AppraisalCompanyFeesViewModel();
			var feesList = new List<FeeItemViewModel>();
			feesList.Add(new FeeItemViewModel() { Id = "1", IsEditable = true });
			model.Fees.FeesItems = feesList;
			var actionResult = controller.FeeAdd(model);
			actionResult.Should().NotBeNull().And.BeOfType<PartialViewResult>();
			((PartialViewResult)actionResult).ViewName.Should().Be("Tables/AppraisalCompanyFees");
			model.Fees.FeesItems.Count.Should().Be(2);
			model.Fees.FeesItems[0].IsEditable.Should().BeFalse();
			model.Fees.FeesItems[1].IsEditable.Should().BeTrue();
		}
		public void FeeDel_should_throw_exception_if_trying_to_delete_nonexistent_fee()
		{
			var target = new AppraisalCompanyFeesController(Substitute.For<IAppraisalCompanyService>(), Substitute.For<IAppraiserManagement>());
			var model = new AppraisalCompanyFeesViewModel();
			var feesList = new List<FeeItemViewModel>();
			feesList.Add(new FeeItemViewModel() { Id = "1" });
			model.Fees.FeesItems = feesList;
			target.Invoking(t => t.FeeDel(model, "false id")).ShouldThrow<ApplicationException>().And.Message.Should().Contain("not found");
		}