private void AddFeeToSession(FeeItemViewModel item)
		{
			item.IsEditable = false;
			item.ProductName = Singletones.ReferenceManager.GetProductNameById(item.ProductType);
			var oldItem = ModelWithFeeShedulingList.Fees.FeesItems.SingleOrDefault(e => e.Id == item.Id);
			if (oldItem != null)
			{
				int index = ModelWithFeeShedulingList.Fees.FeesItems.IndexOf(oldItem);
				ModelWithFeeShedulingList.Fees.FeesItems.Remove(oldItem);
				ModelWithFeeShedulingList.Fees.FeesItems.Insert(index, item);
			}
			else
			{
				ModelWithFeeShedulingList.Fees.FeesItems.Add(item);
			}
		}
		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);
		}
Esempio n. 3
0
		public FeesViewModel GetFeesViewModel(ICollection<AppraiserFee> fees)
		{
			var feesViewModel = new FeesViewModel();
			feesViewModel.FeesItems = new List<FeeItemViewModel>();

			foreach (var fee in fees)
			{
				var feeItemViewModel = new FeeItemViewModel();
				feeItemViewModel.Id = fee.Id.ToString();
				feeItemViewModel.ProductType = fee.ProductId;
				feeItemViewModel.Fee = fee.Amount;
				feeItemViewModel.ProductName = _refManager.GetProductNameById(fee.ProductId);
				feesViewModel.FeesItems.Add(feeItemViewModel);
			}
			return feesViewModel;
		}
Esempio n. 4
0
		public void SaveFeeItem(AppraiserUser currentUser, FeeItemViewModel currentFee)
		{
			if (currentUser == null)
				throw new ArgumentNullException("appraiser user");
			if (currentFee == null)
				throw new ArgumentNullException("currentFee");
			if (string.IsNullOrEmpty(_refManager.GetProductNameById(currentFee.ProductType)))
				throw new ArgumentException("fee product id");

			var fee = currentUser.Fees.SingleOrDefault(e => e.Id.ToString() == currentFee.Id);
			if (fee == null)
			{
				fee = new AppraiserFee();
				currentUser.Fees.Add(fee);
			}

			fee.Amount = currentFee.Fee.Value;
			fee.ProductId = currentFee.ProductType;
		}
Esempio n. 5
0
		private void SaveFeeItem(FeeItemViewModel item, int? userId = null)
		{
			_appraiserUserService.SaveAppraiserFeeItem(item, User.Identity.Name, userId);
			ViewBag.NotificationMessage = item.IsNew ? Constants.Notifications.FeeSaved : Constants.Notifications.FeeUpdated;
			CommitProviderInstance.Commit();
		}