public IPagedList <CustomerModel> GetModels(CustomerCndModel cnd) { var query = from a in _customerRepository.Table.Where(x => x.Type != CustomerTypeEnum.SuperAdmin) select new CustomerModel { Id = a.Id, Name = a.Name, Email = a.Email, Active = a.Active, Type = a.Type, CreatedTime = a.CreatedTime }; if (cnd.Id > 0) { query = query.Where(x => x.Id == cnd.Id); } if (!string.IsNullOrEmpty(cnd.Name)) { query = query.Where(x => x.Name == cnd.Name.Trim()); } if (!string.IsNullOrEmpty(cnd.Email)) { query = query.Where(x => x.Email == cnd.Email.Trim()); } if (cnd.Active.HasValue) { query = query.Where(x => x.Active == cnd.Active.Value); } if (cnd.Type.HasValue) { query = query.Where(x => x.Type == cnd.Type.Value); } if (cnd.Start.HasValue) { var start = cnd.Start.Value.Date; query = query.Where(x => x.CreatedTime >= start); } if (cnd.End.HasValue) { query = query.Where(x => x.CreatedTime <= cnd.End.Value); } return(new PagedList <CustomerModel>(query = query.OrderByDescending(x => x.Id), cnd.PageIndex, cnd.PageSize)); }
public ActionResult AjaxGetUserList(CustomerCndModel cnd) { var data = _customerSerice.GetModels(cnd); return(Json(new { rows = data, total = data.TotalCount })); }