private async Task <PagedSortedViewModel <PersonResultItem> > GetPagedSortedResultsAsViewModel(int draw, int start, int length, string orderColumn, bool orderAscending) { var result = await _pagedSortedRepository.GetPagedSortedResults(start, length, orderColumn, orderAscending); return(new PagedSortedViewModel <PersonResultItem> { Draw = draw, Start = start, Length = length, OrderAscending = orderAscending, OrderColumn = orderColumn, RecordsFiltered = result.recordsFiltered, RecordsTotal = result.recordsTotal, Data = result.data, }); }
public async Task Index_GetsDataAndReturnsView() { var pagedSortedResult = new PagedSortedResult <OrganisationResultItem>() { recordsFiltered = 50, recordsTotal = 100, data = new List <OrganisationResultItem>(), }; _pagedSortedRepository.GetPagedSortedResults(0, 10, "Name", true).Returns(pagedSortedResult); var result = await _controller.Index(); Assert.IsTrue(result is ViewResult); Assert.AreEqual(pagedSortedResult.recordsTotal, ((result as ViewResult).Model as PagedSortedViewModel <OrganisationResultItem>).RecordsTotal); Assert.AreEqual(pagedSortedResult.recordsFiltered, ((result as ViewResult).Model as PagedSortedViewModel <OrganisationResultItem>).RecordsFiltered); Assert.AreSame(pagedSortedResult.data, ((result as ViewResult).Model as PagedSortedViewModel <OrganisationResultItem>).Data); }
public async Task <IActionResult> Index(int start = 0, int length = 10, string orderColumn = "Name", bool orderAscending = true) { var result = await _pagedSortedRepository.GetPagedSortedResults(start, length, orderColumn, orderAscending); var services = await _partyRespository.GetCustomServices(); var model = new HomeViewModel() { Start = start, Length = length, OrderAscending = orderAscending, OrderColumn = orderColumn, RecordsFiltered = result.recordsFiltered, RecordsTotal = result.recordsTotal, Data = result.data, Services = services, }; return(View(model)); }
public async Task Index_GetsDataAndReturnsView() { var pagedSortedResult = new PagedSortedResult <PartyWithRegistrationsResultItem>() { recordsFiltered = 50, recordsTotal = 100, data = new List <PartyWithRegistrationsResultItem>(), }; var services = new List <CustomService>(); _pagedSortedRepository.GetPagedSortedResults(0, 10, "Name", true).Returns(pagedSortedResult); _partyRespository.GetCustomServices().Returns(services); var result = await _controller.Index(); Assert.IsTrue(result is ViewResult); Assert.AreEqual(pagedSortedResult.recordsTotal, ((result as ViewResult).Model as HomeViewModel).RecordsTotal); Assert.AreEqual(pagedSortedResult.recordsFiltered, ((result as ViewResult).Model as HomeViewModel).RecordsFiltered); Assert.AreSame(pagedSortedResult.data, ((result as ViewResult).Model as HomeViewModel).Data); Assert.AreSame(services, ((result as ViewResult).Model as HomeViewModel).Services); }