public async Task <IActionResult> GetRolesAllAsync([FromQuery] PageParameters pageParameters) { //var id = Convert.ToInt32(User.Identity.Name); IQueryable <Roles> source = context.Roles.Where(m => m.IsDel == 0); //角色名称查询 if (!string.IsNullOrEmpty(pageParameters.RoleName)) { source = source.Where(m => m.Name.Contains(pageParameters.RoleName) && m.IsDel == 0); } if (pageParameters.CreateTimeByFind != null) { source = source.Where(m => m.CreateTime >= pageParameters.CreateTimeByFind); } var pagelist = await PageList <Roles> .CreatePageList(source, pageParameters.Page, pageParameters.Limit); var roleShowDtos = mapper.Map <List <RolesShowDto> >(pagelist.Source); //var list = await context.Roles.ToListAsync(); //return Ok(new { code = 0, data = list }); return(Ok(new { code = 0, data = roleShowDtos, msg = "", count = pagelist.Count })); }
// GET: Films public ActionResult Index(int page = 1) { var items = db.Films.OrderBy(p => p.Id); var model = PageList <Film> .CreatePageList(items.ToList(), _pageSize, page); return(View(model)); }
public async Task <IActionResult> GetPageListByCustomerByNoReal([FromQuery] PageParameters pageParameters) { var id = Convert.ToInt32(User.Identity.Name); IQueryable <Customers> source; #region 查询逻辑 if (pageParameters.EmployeeIDByFind != 0) //如果查询的员工ID不为0 { source = context.Customers.Where(m => m.IsReal == pageParameters.Status && m.IsDel == 0 && m.EmployeesID == pageParameters.EmployeeIDByFind); } else //如果为0就查询自己的 { source = context.Customers.Where(m => m.IsReal == pageParameters.Status && m.IsDel == 0 && m.EmployeesID == id); } //分类类别的查询 if (pageParameters.CustomerSegmentationIDByFind != 0) { source = source.Where(m => m.CustomerSegmentationID == pageParameters.CustomerSegmentationIDByFind); } //客户名称查询 if (!string.IsNullOrEmpty(pageParameters.CustomerNameByFind)) { source = source.Where(m => m.Name.Contains(pageParameters.CustomerNameByFind)); } //时间判断 //开始时间 if (pageParameters.StartTimeByFind != null) { source = source.Where(m => m.CreateTime >= pageParameters.StartTimeByFind); } //结束时间 if (pageParameters.EndTimeByFind != null) { source = source.Where(m => m.CreateTime <= pageParameters.EndTimeByFind); } //中间时间 if (pageParameters.StartTimeByFind != null && pageParameters.EndTimeByFind != null) { source = source.Where(m => m.CreateTime >= pageParameters.StartTimeByFind && m.CreateTime <= pageParameters.EndTimeByFind); } #endregion var pagelist = await PageList <Customers> .CreatePageList(source, pageParameters.Page, pageParameters.Limit); //Auto映射 var customerShowDtos = mapper.Map <List <CustomerShowDto> >(pagelist.Source); //返回符合Layui的数据格式 return(Ok(new { code = 0, msg = "", data = customerShowDtos, count = pagelist.Count })); }
public async Task <ActionResult <PageList <WishDto> > > GetWishDtosAsync(int index, int size) { int userId = Convert.ToInt32(User.Identity.Name); var data = await _repositoryWrapper.WishRepository.GetWishDtosAsync(userId); PageList <WishDto> pageList = await PageList <WishDto> .CreatePageList(data.OrderByDescending(m => m.CreateTime).AsQueryable(), index, size); return(pageList); }
public async Task <PageList <Product> > GetProductAllByAdmin(int index = 1, int size = 10, string name = "") { var data = await repositoryWrapper.ProductRepository.GetAllAsync(); if (!string.IsNullOrEmpty(name)) { data = data.Where(m => m.Title.Contains(name)); } var source = await PageList <Product> .CreatePageList(data, index, size); return(source); }
public async Task <IActionResult> GetPageListByEmployee_Roles([FromQuery] PageParameters pageParameters, string employee_RoleIDByFind) { var id = Convert.ToInt32(User.Identity.Name); IQueryable <Employees_Roles> source; source = context.Employees_Roles.Where(m => m.IsDel == 0); //角色名称查询 if (!string.IsNullOrEmpty(employee_RoleIDByFind)) { var ent = Convert.ToInt32(employee_RoleIDByFind); source = source.Where(m => m.RoleID.Equals(ent) && m.IsDel == 0); } if (!string.IsNullOrEmpty(pageParameters.CustomerNameByFind)) { source = source.Where(m => m.EmployeeName.Contains(pageParameters.CustomerNameByFind) && m.IsDel == 0); } var pagelist = await PageList <Employees_Roles> .CreatePageList(source, pageParameters.Page, pageParameters.Limit); var employee_roleShowDto = mapper.Map <List <Employees_RolesShowDto> >(pagelist.Source); //返回符合Layui的数据格式 return(Ok(new { code = 0, msg = "", data = employee_roleShowDto, count = pagelist.Count })); }
public async Task <PageList <Product> > GetPageListsAsync(PageParameters pageParameters, int typeId) { IQueryable <Product> source = context.Set <Product>().Where(m => m.Product_CategoryId == typeId && m.Status.Equals(0) && m.Stock > 0); if (typeId == 0) { source = context.Set <Product>().Where(m => m.Status.Equals(0) && m.Stock > 0); } if (!string.IsNullOrEmpty(pageParameters.Name)) { source = source.Where(m => m.Title.Contains(pageParameters.Name) && m.Status.Equals(0) && m.Stock > 0); } //价格区间 if (pageParameters.BottomPrice != 0 && pageParameters.TopPrice != 0) { source = source.Where(m => m.Price > pageParameters.BottomPrice && m.Price < pageParameters.TopPrice && m.Status.Equals(0) && m.Stock > 0); } //价格区间 //价格排序 if (pageParameters.IsPriceSort != null) { if ((bool)pageParameters.IsPriceSort) //价格升序 { source = source.Where(m => m.Status.Equals(0) && m.Stock > 0).OrderBy <Product, decimal>(m => m.Price); } else //价格倒序 { source = source.Where(m => m.Status.Equals(0) && m.Stock > 0).OrderByDescending <Product, decimal>(m => m.Price); } }//价格排序 //销量排序 if (pageParameters.IsPurchaseSort != null) { if ((bool)pageParameters.IsPurchaseSort) //销量升序 { source = source.Where(m => m.Status.Equals(0) && m.Stock > 0).OrderBy <Product, int>(m => m.Purchase); } else //销量倒序 { source = source.Where(m => m.Status.Equals(0) && m.Stock > 0).OrderByDescending <Product, int>(m => m.Purchase); } }//销量排序 //日期排序 if (pageParameters.IsTimeSort != null) { if ((bool)pageParameters.IsTimeSort) //日期升序 { source = source.Where(m => m.Status.Equals(0) && m.Stock > 0).OrderBy <Product, DateTime>(m => m.CreateTime); } else //日期倒序 { source = source.Where(m => m.Status.Equals(0) && m.Stock > 0).OrderByDescending <Product, DateTime>(m => m.CreateTime); } }//日期排序 return(await PageList <Product> .CreatePageList(source, pageParameters.PageIndex, pageParameters.PageSize));; }