Пример #1
0
		public ActionResult SaveNote(ClientCompanyAdminViewModel model)
		{
			var user = _securityContext.CurrentUser;
			var clientCompany = _clientCompanyManagement.GetClientCompanyByCompanyId(model.CompanyId);
			_clientCompanyAdminNotesService.SaveNote(clientCompany, user, model.NoteText);
			CommitProviderInstance.Commit();
			var notes = _clientCompanyAdminNotesService.GetNotesByCompanyId(model.CompanyId);
			return PartialView("AdminNotesTable", notes);
		}
Пример #2
0
		public ActionResult Index(ClientCompanyAdminViewModel model)
		{
			if (ModelState.IsValid)
			{
				_clientCompanyAdminSettingsService.SaveClientCompanyAdminSettingsFromViewModel(model);
				CommitProviderInstance.Commit();
				return PluginResults.Plugins<CurrentMenuPluginResule>().GetRedirectToTab();
			}
			return View();
		}
		public void SaveClientCompanyAdminSettingsFromViewModel(ClientCompanyAdminViewModel viewModel)
		{
			var clientCompany = _clientCompanyManagement.GetClientCompanyByCompanyId(viewModel.CompanyId);
			if (clientCompany == null)
			{
				throw new ApplicationException("client company is not found");
			}
			if (clientCompany.AdminSetting == null)
			{
				clientCompany.AdminSetting = new ClientCompanyAdminSetting();
			}
			clientCompany.AdminSetting = UpdateEntityFromViewModel(viewModel, clientCompany.AdminSetting);
			_clientCompanyManagement.Update(clientCompany);
		}
		public ClientCompanyAdminViewModel GetViewModel(string companyId)
		{
			ClientCompanyAdminViewModel viewModel;
			var clientCompany = _clientCompanyManagement.GetClientCompanyByCompanyId(companyId);
			if (clientCompany.AdminSetting != null)
			{
				viewModel = GetViewModelFromEntity(clientCompany.AdminSetting);
			}
			else
			{
				viewModel = new ClientCompanyAdminViewModel { CompanyId = companyId };
			}
			return viewModel;
		}
		public ClientCompanyAdminSetting UpdateEntityFromViewModel(ClientCompanyAdminViewModel viewModel, ClientCompanyAdminSetting entity)
		{
			entity.CompanyId = viewModel.CompanyId;
			entity.OrderCA = viewModel.OrderCA.Value;
			entity.OrderCABillTo = viewModel.OrderCABillTo.Value;
			entity.UnderwriterAssist = viewModel.UnderwriterAssist.Value;
			entity.UnderwriterAssistBillTo = viewModel.UnderwriterAssistBillTo.Value;
			entity.UCDPUpload = viewModel.UCDPUpload.Value;
			entity.UCDPUploadBillTo = viewModel.UCDPUploadBillTo.Value;
			entity.AutomatedQC = viewModel.AutomatedQC.Value;
			entity.AutomatedQCBillTo = viewModel.AutomatedQCBillTo.Value;
			entity.ManualQC = viewModel.ManualQC.Value;
			entity.ManualQCBillTo = viewModel.ManualQCBillTo.Value;
			entity.SoftPlatformBillTo = viewModel.SoftFeeBillTo.Value;
			entity.PlatformUtilizationFee = viewModel.PlatformUtilizationFee;
			entity.UaAvmFee = viewModel.UaAvmFee;
			entity.AppraisalQcUcdpFee = viewModel.AppraisalQcUcdpFee;
			return entity;
		}
		public ClientCompanyAdminViewModel GetViewModelFromEntity(ClientCompanyAdminSetting entity)
		{
			var viewModel = new ClientCompanyAdminViewModel
			{
				AutomatedQC = entity.AutomatedQC,
				AutomatedQCBillTo = entity.AutomatedQCBillTo,
				ManualQC = entity.ManualQC,
				ManualQCBillTo = entity.ManualQCBillTo,
				UCDPUpload = entity.UCDPUpload,
				UCDPUploadBillTo = entity.UCDPUploadBillTo,
				UnderwriterAssist = entity.UnderwriterAssist,
				UnderwriterAssistBillTo = entity.UnderwriterAssistBillTo,
				OrderCA = entity.OrderCA,
				OrderCABillTo = entity.OrderCABillTo,
				SoftFeeBillTo = entity.SoftPlatformBillTo,
				AppraisalQcUcdpFee = entity.AppraisalQcUcdpFee,
				UaAvmFee = entity.UaAvmFee,
				PlatformUtilizationFee = entity.PlatformUtilizationFee,
				CompanyId = entity.CompanyId,
				TotalFee = (decimal?)entity.TotalFee
			};
			return viewModel;
		}
		public void MethodUpdateEntityFromViewModelShouldUpdateEntity()
		{
			var random = new Random();
			var entity = new ClientCompanyAdminSetting();
			var viewModel = new ClientCompanyAdminViewModel
			{
				AutomatedQC = random.Next(int.MinValue, int.MaxValue),
				AutomatedQCBillTo = random.Next(int.MinValue, int.MaxValue),
				ManualQC = random.Next(int.MinValue, int.MaxValue),
				ManualQCBillTo = random.Next(int.MinValue, int.MaxValue),
				UCDPUpload = random.Next(int.MinValue, int.MaxValue),
				UCDPUploadBillTo = random.Next(int.MinValue, int.MaxValue),
				UnderwriterAssist = random.Next(int.MinValue, int.MaxValue),
				UnderwriterAssistBillTo = random.Next(int.MinValue, int.MaxValue),
				OrderCA = random.Next(int.MinValue, int.MaxValue),
				OrderCABillTo = random.Next(int.MinValue, int.MaxValue),
				SoftFeeBillTo = random.Next(int.MinValue, int.MaxValue),
				AppraisalQcUcdpFee = random.NextDouble(),
				UaAvmFee = random.NextDouble(),
				PlatformUtilizationFee = random.NextDouble(),
				CompanyId = TestCompanyId
			};
			var result = ClientCompanyAdminSettingsService.UpdateEntityFromViewModel(viewModel, entity);
		    result.CompanyId.Should().Be(viewModel.CompanyId);
			result.AutomatedQC.Should().Be(viewModel.AutomatedQC.Value);
			result.AutomatedQCBillTo.Should().Be(viewModel.AutomatedQCBillTo.Value);
		    result.UCDPUpload.Should().Be(viewModel.UCDPUpload.Value);
		    result.UCDPUploadBillTo.Should().Be(viewModel.UCDPUploadBillTo.Value);
		    result.ManualQC.Should().Be(viewModel.ManualQC.Value);
		    result.ManualQCBillTo.Should().Be(viewModel.ManualQCBillTo.Value);
		    result.UnderwriterAssist.Should().Be(viewModel.UnderwriterAssist.Value);
		    result.UnderwriterAssistBillTo.Should().Be(viewModel.UnderwriterAssistBillTo.Value);
		    result.OrderCA.Should().Be(viewModel.OrderCA.Value);
		    result.OrderCABillTo.Should().Be(viewModel.OrderCABillTo.Value);
		    result.SoftPlatformBillTo.Should().Be(viewModel.SoftFeeBillTo.Value);
		    (result.AppraisalQcUcdpFee.Value - viewModel.AppraisalQcUcdpFee.Value).Should().BeLessOrEqualTo(0.01);
            (result.UaAvmFee.Value - viewModel.UaAvmFee.Value).Should().BeLessOrEqualTo(0.01);
            (result.PlatformUtilizationFee.Value - viewModel.PlatformUtilizationFee.Value).Should().BeLessOrEqualTo(0.01);
		}