//[ResponseCache(Duration = 100, VaryByQueryKeys = new[] { "page", "searchstring" })] public async Task <IActionResult> Index(int?page, string searchstring, FilterByStatus FilterByStatus, VolumeRanges?Volume, [ModelBinder(typeof(DateTimeModelBinder))] DateTime?startDate, [ModelBinder(typeof(DateTimeModelBinder))] DateTime?endDate) { int pageSize = Int32.Parse(_configuration["DefaultPagesize"]); var carrierId = _carrierService.Carrier.Id; var model = new ClaimsViewModel { StartDate = startDate, EndDate = endDate, Cars = await _carrierService.GetCars(carrierId), Drivers = await _carrierService.GetDrivers(carrierId), CarrierId = carrierId, SearchString = searchstring, FilterByStatus = FilterByStatus, Volume = Volume }; var claimsResult = await _claimService.GetFilteredClaimsAsync(model); model.Claims = claimsResult.ToPagedList(page ?? 1, pageSize); ViewData["pagesize"] = pageSize; return(View(model)); }
//---------------------------------------------------------------------------------------------------- /// <summary> /// Проверяет возможность фильтрации по Статусу /// </summary> private bool FilterStatus(object obj) { bool result = true; GeneralPersonsInfo currentPerson = obj as GeneralPersonsInfo; if (!string.IsNullOrEmpty(FilterByStatus) && currentPerson != null && !currentPerson.Status.ToLower().Contains(FilterByStatus.ToLower())) { return(false); } return(result); }