예제 #1
0
		public void CreateCompanyWithAppraisalCompanyAdminUser(AppraisalCompanySignUpViewModel viewModel, AddressViewModel companyAddressModel)
		{
			AppraisalCompanyProfileViewModel companyViewModel = new AppraisalCompanyProfileViewModel();
			companyViewModel.CompanyName = viewModel.CompanyName;
			companyViewModel.CompanyType = viewModel.CompanyType.HasValue && viewModel.CompanyType.Value != 0 ? viewModel.CompanyType : null;

			var dbCompany = _appraisalCompanyManagement.CreateAppraisalCompany(companyViewModel);
			dbCompany.Contact = new AppraisalCompanyContact();
			if (companyAddressModel != null)
			{
				dbCompany.Contact.PhysicalAddress = new Address()
																		{
																			City = companyAddressModel.City,
																			State = companyAddressModel.State.Substring(0,2),
																			Street = companyAddressModel.Street,
																			Street2 = companyAddressModel.Street2,
																			ZIP = companyAddressModel.ZIP,
																		};
			}
			else
			{
				dbCompany.Contact.PhysicalAddress = new Address() { State = viewModel.LocationState.Substring(0, 2) };
			}

			var user = _usersManagement.CreateUser(viewModel.AppraisalCompanyAdmin, RoleType.CompanyAdminAndAppraiser);
			AppraiserUser appraiserUser = new AppraiserUser();
			appraiserUser.Company = dbCompany;
			appraiserUser.User = user;
			appraiserUser.Status = AppraiserUserStatus.Applied;

			_appraisalCompanyAdminManagement.CreateUser(appraiserUser);
		}
예제 #2
0
		public void AppraisalCompanyManager_CreateAppraisalCompany_Should_populate_correspondent_dbentity_fields()
		{
			string companyName = "Test Company";
			AppraisalCompanyProfileViewModel companyViewModel = new AppraisalCompanyProfileViewModel();
			companyViewModel.CompanyName = companyName;
			//act
			Target.CreateAppraisalCompany(companyViewModel);
			AppraisalCompanyRepository.Received().Add(Arg.Is<AppraisalCompanyDetail>(ac =>
				string.Equals(ac.CompanyName, companyName) &&
				ac.Status == AppraisalCompanyStatus.Applied));
		}
예제 #3
0
		public AppraisalCompanyDetail CreateAppraisalCompany(AppraisalCompanyProfileViewModel viewModel)
		{
			if (viewModel == null)
				throw new ArgumentNullException("AppraisalCompany cannot be null");

			AppraisalCompanyDetail dbCompany = new AppraisalCompanyDetail();
			dbCompany.CompanyName = viewModel.CompanyName;
			dbCompany.Status = AppraisalCompanyStatus.Applied;
			dbCompany.CompanyId = GenerateCompanyId();
			dbCompany.CompanyTypeId = viewModel.CompanyType;

			_appraisalCompanyRepository.Add(dbCompany);

			return dbCompany;
		}
		public void profile_post_action_should_return_profile_view()
		{
			var viewContext = new ViewContext();
			viewContext.HttpContext = MockHttpContext.FakeHttpContext();
			IPrincipal user = new GenericPrincipal(new GenericIdentity("someUser"), null);
			viewContext.HttpContext.User.ReturnsForAnyArgs(user);

			AppraisalCompanyProfileService.GetAppraisalCompanyDetails(Arg.Any<int>()).Returns(new AppraisalCompanyDetailsViewModel());
			AppraisalCompanyProfileService.GetAppraisalCompanyProfile(Arg.Any<int>()).Returns(new AppraisalCompanyProfileViewModel());
			AppraiserManagement.GetByEmail(Arg.Any<string>()).Returns(new AppraiserUser { Company = new AppraisalCompanyDetail() });
			var viewModel = new AppraisalCompanyProfileViewModel();
			Target.SetFakeControllerContext(viewContext.HttpContext);

			var actionResult = Target.Profile(viewModel, 0);
			actionResult.Should().NotBeNull().And.BeOfType<RedirectToRouteResult>();
			((RedirectToRouteResult)actionResult).RouteValues.Should().HaveCount(1);
			((RedirectToRouteResult)actionResult).RouteValues["action"].Should().Be("Profile");
		}
		public void profile_should_redirect_to_profile_view_if_model_state_is_invalid()
		{
			var viewModel = new AppraisalCompanyProfileViewModel();
			Target.ModelState.AddModelError("test error", "test error");

			var actionResult = Target.Profile(viewModel, null);
			actionResult.Should().NotBeNull().And.BeOfType<RedirectToRouteResult>();
			((RedirectToRouteResult)actionResult).RouteValues.Should().HaveCount(1);
			((RedirectToRouteResult)actionResult).RouteValues["action"].Should().Be("Profile");
		}
		public ActionResult Profile(AppraisalCompanyProfileViewModel appraisalCompanyProfile, int? nextStep)
		{
			if (ModelState.IsValid)
			{
				var appraisalCompanyId = GetAppraisalCompanyId();
				_appraisalCompanyWizardService.UpdateAppraisalCompanyProfile(appraisalCompanyProfile, appraisalCompanyId);
				CommitProviderInstance.Commit();

				return RedirectToStep(nextStep);
			}

			TempData[AppraisalCompanyProfileKey] = appraisalCompanyProfile;
			return RedirectToAction(NameHelper.AppraisalCompanyProfile.Profile);
		}
		private ActionResult GetProfileView(AppraisalCompanyProfileViewModel appraisalCompanyProfile)
		{
			ViewBag.CurrentStep = (int)TabSteps.Profile;
			return View(NameHelper.AppraisalCompanyProfile.Profile, appraisalCompanyProfile);
		}
예제 #8
0
		public void UpdateAppraisalCompanyProfile(AppraisalCompanyProfileViewModel model, int companyId)
		{
			var company = _appraisalCompanyManagement.GetAppraisalCompanyById(companyId);
			company.CompanyName = model.CompanyName;
			if (!model.CompanyType.HasValue || model.CompanyType.Value.Equals(Constants.Text.NoSelectionKey))
			{
				company.CompanyTypeId = null;
			}
			else
			{
				company.CompanyTypeId = model.CompanyType;
			}
			if (company.Status != AppraisalCompanyStatus.Applied)
			{
				_appraisalCompanyManagement.SetCompanyStatus(companyId, model.Status);
			}
		}
예제 #9
0
		public AppraisalCompanyProfileViewModel GetAppraisalCompanyProfile(int appraisalCompanyId)
		{
			var appraisalCompany = _appraisalCompanyManagement.GetAppraisalCompanyById(appraisalCompanyId);

			var appraisalCompanyDetails = new AppraisalCompanyProfileViewModel()
			{
				CompanyName = appraisalCompany.CompanyName,
				CompanyID = appraisalCompany.CompanyId,
				Status = appraisalCompany.Status,
				StatusHistories = _statusHistoryManager.GetAppraisalCompanyStatusHistory(appraisalCompanyId),
				TIN = _cryptographicProvider.DecryptString(appraisalCompany.TIN).Value,
				TINType = appraisalCompany.TINTypeId,
				CompanyType = appraisalCompany.CompanyTypeId
			};

			return appraisalCompanyDetails;
		}