public ActionResult ApplyFilter(AppraisalCompanyPipelineViewModel model)
		{
			var filter = model.Filter;
			filter.IsApply = true;
			filter.CurrentPage = DefaultCurrentPage;

			TempData["AppraisalCompanyFilter"] = filter;
			return RedirectToAction(NameHelper.AppraisalCompaniesPipeline.Companies);
		}
		public ActionResult Sort(string nameOfColumn, bool sortOrder, AppraisalCompanyPipelineViewModel model)
		{
			var filter = model.Filter;
			filter.IsAscending = filter.NameOfSortColumn == nameOfColumn ? sortOrder : true;
			filter.NameOfSortColumn = nameOfColumn;
			filter.CurrentPage = DefaultCurrentPage;

			TempData["AppraisalCompanyFilter"] = filter;
			return RedirectToAction(NameHelper.AppraisalCompaniesPipeline.Companies);
		}
		public ActionResult Companies(AppraisalCompanyPipelineViewModel model)
		{
			var filter = model.Filter;
			if (!filter.IsApply)
			{
				filter = GetEmptyFilter();
				filter.ItemsOnPage = model.Filter.ItemsOnPage;
				filter.CurrentPage = DefaultCurrentPage;
			}

			TempData["AppraisalCompanyFilter"] = filter;
			return RedirectToAction(NameHelper.AppraisalCompaniesPipeline.Companies);
		}
		public void Companies_should_not_be_null_if_model_not_null_and_redirect_to_companies_get_action()
		{
			//arrange
			var appraisalCompanyService = Substitute.For<IAppraisalCompanyService>();
			var appraisalCompanyManager = Substitute.For<IAppraisalCompanyManagement>();
			var referenceManagement = Substitute.For<IReferenceManagement>();
			var target = new AppraisalCompaniesPipelineController(appraisalCompanyService, appraisalCompanyManager, referenceManagement);
			var model = new AppraisalCompanyPipelineViewModel();
			model.Filter = new AppraisalCompanyFilter();
			ActionResult actual;
			//act
			actual = target.Companies(model);
			//assert
			target.Should().NotBeNull();
			((RedirectToRouteResult)actual).RouteValues.Should().HaveCount(1);
			((RedirectToRouteResult)actual).RouteValues["action"].Should().Be("Companies");
		}
Ejemplo n.º 5
0
		public void CheckCompanyName_action_should_return_true_if_company_exists()
		{
			var companies = new AppraisalCompanyPipelineViewModel();
			companies.AppraisalCompanies = new List<AppraisalCompanyPipelineDetailsViewModel>
				(new[] { new AppraisalCompanyPipelineDetailsViewModel() });
			AppraisalCompanyService.GetAppraisalCompaniesListByFilter(Arg.Any<AppraisalCompanyFilter>()).Returns(companies);
			//act
			JsonResult result = Target.CheckCompanyName("test");
			result.JsonRequestBehavior.Should().Be(JsonRequestBehavior.AllowGet);
			((bool)result.Data).Should().BeTrue();
		}
Ejemplo n.º 6
0
		public AppraisalCompanyPipelineViewModel GetAppraisalCompaniesListByFilter(AppraisalCompanyFilter filter)
		{
			var appraisalCompanies = _appraisalCompanyManagement.GetAppraisalCompaniesListByFilter(filter);

			var model = new AppraisalCompanyPipelineViewModel();
			if (appraisalCompanies != null)
			{
				foreach (var item in appraisalCompanies)
				{
					var companyModel = new AppraisalCompanyPipelineDetailsViewModel();
					companyModel.Id = item.Id;
					companyModel.CompanyId = item.CompanyId;
					companyModel.CompanyName = item.CompanyName;
					companyModel.Status = item.Status;
					if (item.Contact != null)
						companyModel.CompanyAddress = _addressManager.GetAddressViewModel<AddressViewModel>(item.Contact.PhysicalAddress);
					model.AppraisalCompanies.Add(companyModel);
				}
			}

			model.Filter = filter;

			return model;
		}
		public ActionResult Paging(int page, AppraisalCompanyPipelineViewModel model)
		{
			var filter = model.Filter;
			if (!filter.IsApply)
			{
				filter = GetEmptyFilter(model.Filter.ItemsOnPage.Value);
			}
			filter.CurrentPage = page;

			TempData["AppraisalCompanyFilter"] = filter;
			return RedirectToAction(NameHelper.AppraisalCompaniesPipeline.Companies);
		}