public ViewModel DataBind(RemoteAreaAddressParam param) { var list = _freightService.GetPagedListRemoteAreaAddress(new RemoteAreaAddressParam { Page = param.Page, PageSize = param.PageSize, ShippingMethodId = param.ShippingMethodId, CountryCode = param.CountryCode, State = !string.IsNullOrEmpty(param.State)? param.State.Trim():null, City = !string.IsNullOrEmpty(param.City)? param.City.Trim():null, Zip = param.Zip }); var pageCount = 0; var totalCount = 0; if (list != null && list.Any()) { var remoteAreaAddressExt = list.LastOrDefault(); if (remoteAreaAddressExt != null) { pageCount = remoteAreaAddressExt.PageInfoModel.PageCount; } var areaAddressExt = list.LastOrDefault(); if (areaAddressExt != null) { totalCount = areaAddressExt.PageInfoModel.TotalCount; } list.RemoveAt(list.Count - 1); //去除最后一条 } //构建分页强类型 var PagedList = new PagedList <RemoteAreaAddressExt>() { PageIndex = param.Page, PageSize = param.PageSize, TotalCount = totalCount, TotalPages = pageCount, InnerList = list }; var model = new ViewModel { FilterModel = param, PagedList = PagedList, }; //运输方式下拉框 model.ShippingMethodLists = GetShippingMethodSelectList(); model.Countrylists = GetCountrySelectList(); //显示国家全称 List <Country> listCountry = _countryService.GetCountryList(""); model.PagedList.InnerList.Each( p => { if (!string.IsNullOrEmpty(p.CountryCode)) { var getCountry = listCountry.Find(a => a.CountryCode.ToUpperInvariant().Contains(p.CountryCode.ToUpperInvariant())); if (getCountry != null) { p.EName = getCountry.Name; } } }); //显示运输方式名称 var listShippingMethodList = GetShippingMethodSelectList(); model.PagedList.InnerList.Each( p => { var getShippingMethod = listShippingMethodList.Find(a => a.Value == p.ShippingMethodId.ToString(CultureInfo.InvariantCulture)); if (getShippingMethod != null) { p.ShippingMethodName = getShippingMethod.Text; } }); model.ShowCategoryListModel = ShowCategoryListModel(); return(model); }
public ActionResult SearchInfo(ViewModel model) { return(View(DataBind(model.FilterModel))); }