public FuncResult GetListPagination([FromBody] SearchWorkerModel model) { try { model.page--; if (model.page < 0) { model.page = 0; } return(workerBll.GetListPagination(model)); } catch (Exception) { throw; } }
public FuncResult GetListPagination(SearchWorkerModel model) { FuncResult fr = new FuncResult() { IsSuccess = true, Message = "操作成功" }; try { var query = from w in context.ApdFctWorker join o in context.ApdDimOrg on w.OrgCode equals o.OrgCode select new { CreationDate = w.CreationDate, PeriodYear = w.PeriodYear, RecordId = w.RecordId, OrgName = o.OrgName, Town = o.Town, OrgCode = o.OrgCode, RegistrationType = o.RegistrationType, Address = o.Address, WorkerMonth = w.WorkerMonth, Remark = w.Remark }; query = query.Where(f => ( (string.IsNullOrWhiteSpace(model.orgcode) || f.OrgCode.Contains(model.orgcode)) && (string.IsNullOrWhiteSpace(model.orgname) || f.OrgName.Contains(model.orgname)) && (string.IsNullOrWhiteSpace(model.year) || f.PeriodYear.Equals(Convert.ToDecimal(model.year))) )); int count = query.Count(); if (model.limit * model.page >= count) { model.page = 0; } var pagination = query.Skip(model.limit * model.page).Take(model.limit); fr.Content = new { total = count, data = pagination }; return(fr); } catch (Exception) { throw; } }