private PagedList<Contract> QueryListData(ContractSearch searchModel) { int recordCount = 0; int pageSize = ConstantManager.PageSize; ContractService service = new ContractService(); string Group = searchModel.IsAsc ? searchModel.SortBy : searchModel.SortBy + " Descending"; IList<Contract> allEntities = service.QueryByPage(this.GetSearchFilter(searchModel), Group, pageSize, searchModel.PageIndex + 1, out recordCount); var formCondition = "var condition=" + JsonConvert.SerializeObject(searchModel); return new PagedList<Contract>(allEntities, searchModel.PageIndex, pageSize, recordCount, "Id", "Id", formCondition); }
private void LoadSearchViewBag(ContractSearch searchModel) { #region sort ViewBag.IsAsc = !searchModel.IsAsc; ViewBag.SortBy = searchModel.SortBy; #endregion var datadictionaryService = new DataDictionaryService(); if (!searchModel.ContractTypeId.HasValue) { ViewBag.ContractTypeId = new SelectList(datadictionaryService.Query(p => p.IsActive=="1"), "Id", "Name"); } else { ViewBag.ContractTypeId = new SelectList(datadictionaryService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.ContractTypeId); } if (!searchModel.AgreementTypeId.HasValue) { ViewBag.AgreementTypeId = new SelectList(datadictionaryService.Query(p => p.IsActive=="1"), "Id", "Name"); } else { ViewBag.AgreementTypeId = new SelectList(datadictionaryService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.AgreementTypeId); } if (!searchModel.ContractRelationId.HasValue) { ViewBag.ContractRelationId = new SelectList(datadictionaryService.Query(p => p.IsActive=="1"), "Id", "Name"); } else { ViewBag.ContractRelationId = new SelectList(datadictionaryService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.ContractRelationId); } }
public ActionResult SearchListPartialView(ContractSearch searchModel) { #region sort ViewBag.IsAsc = !searchModel.IsAsc; ViewBag.SortBy = searchModel.SortBy; #endregion return PartialView("SearchListPartialView",this.QueryListData(searchModel)); }
private Expression<Func<Contract, bool>> GetSearchFilter(ContractSearch searchModel) { Expression<Func<Contract, bool>> filter = p => p.IsActive=="1" ; if (searchModel.ContractTypeId.HasValue) { filter = filter.And(q => q.ContractTypeId == searchModel.ContractTypeId.Value); } if (searchModel.AgreementTypeId.HasValue) { filter = filter.And(q => q.AgreementTypeId == searchModel.AgreementTypeId.Value); } if (searchModel.ContractRelationId.HasValue) { filter = filter.And(q => q.ContractRelationId == searchModel.ContractRelationId.Value); } return filter; }
// // GET: /Contract/ //[PermissionFilter] public ViewResult Index(ContractSearch searchModel) { this.LoadSearchViewBag(searchModel); return View(this.QueryListData(searchModel)); }