public List <ExpenseDetailDto> GetList(ExpenseDetailPara para, out int total) { try { var count = 0; var p = PredicateBuilder.Default <ExpenseDetailDto>(); if (para.UserId.IsNotNullOrEmpty()) { p = p.And(m => m.UserId != null && m.UserId.Contains(para.UserId)); } if (para.Mobile.IsNotNullOrEmpty()) { p = p.And(m => m.Mobile != null && m.Mobile.Contains(para.Mobile)); } if (para.OperatorType != 0)//运营商类型 { p = p.And(m => m.OperatorType == para.OperatorType); } if (!string.IsNullOrEmpty(para.SalesMan)) { p = p.And(m => m.SalesMan.Contains(para.SalesMan)); } if (para.StartTime > new DateTime()) { p = p.And(m => m.CreateDate >= para.StartTime); } if (para.EndTime > new DateTime()) { p = p.And(m => m.CreateDate < para.EndTime); } // var expenseDetails = UnitOfWorkService.Execute(() => //{ // var list = _expenseDetailRepository.GetPaged(p, para.PageNumber, para.PageSize, out count, false, m => m.CreateDate); // return list?.Select(c => c.MapTo<ExpenseDetailDto>()).ToList(); //}); // if (expenseDetails == null) // { // total = 0; // return new List<ExpenseDetailDto>(); // } // total = count; // return expenseDetails; var expenseDetails = GetList(para.RoleId, para.OrgId); expenseDetails = expenseDetails.Where(p.Compile()).ToList(); total = expenseDetails.Count; return(expenseDetails.OrderByDescending(m => m.CreateDate).Skip(para.PageNumber * para.PageSize).Take(para.PageSize).ToList()); } catch (Exception ex) { Logger.Error("select * from expenseDetails error", ex); total = 0; return(new List <ExpenseDetailDto>()); } }
public async Task <JsonResult> GetList(ExpenseDetailPara para) { para.PageNumber = para.PageNumber - 1; para.UserId = LoginInfo.Id; return(await Task.Run(() => { var dtos = _expenseDetailService.GetList(para, out var count); var list = dtos.MapTo <List <ExpenseDetailModel> >(); return Json(new { rows = list, total = count }); })); }
public async Task <JsonResult> GetList(ExpenseDetailPara para, int page = 0, int rows = 20) { return(await Task.Run(() => { para.PageNumber = page - 1; //当前页 para.PageSize = rows; //每页显示条数 para.OrgId = LoginInfo.Org.Id; para.RoleId = LoginInfo.Role; var rlt = _expenseDetailService.GetList(para, out var count); var data = rlt.MapTo <List <ExpenseDetailModel> >(); return new JsonResult(new { total = count, rows = data }); })); }