public IActionResult List(FoodRequestPayload payload) { using (_dbContext) { var query = from p in _dbContext.Food orderby p.CreateTime descending select new { p.FoodUuid, p.FoodName, p.Title, p.Address, ShopId = p.ShopId == null ? -1 : p.ShopId, CreateTime = p.CreateTime.Value.ToString("yyyy-MM-dd"), PlayType = p.PlayType == "1" ? "古镇游" : "周边游", FoodorTechan = p.FoodorTechan == 0 ? "美食" : "特产", p.Price, p.IsDelete, p.State }; if (!string.IsNullOrEmpty(payload.Kw)) { query = query.Where(x => x.FoodName.Contains(payload.Kw.Trim()) || x.Address.Contains(payload.Kw.Trim())); } if (payload.State > -1) { query = query.Where(x => x.State == payload.State); } if (payload.IsDeleted > CommonEnum.IsDeleted.All) { query = query.Where(x => x.IsDelete == Convert.ToInt32(((CommonEnum.IsDeleted)payload.IsDeleted))); } var list = query.Paged(payload.CurrentPage, payload.PageSize).ToList(); var totalCount = query.Count(); var response = ResponseModelFactory.CreateResultInstance; response.SetData(list, totalCount); ToLog.AddLog("查询", "成功:查询:美食特产列表数据", _dbContext); return(Ok(response)); } }
public IActionResult List(FoodRequestPayload payload) { using (_dbContext) { var query = from p in _dbContext.Bus orderby p.CreateTime descending select new { p.BusUuid, p.Name, p.PassSite, p.BegainSite, p.EndSite, CreateTime = p.CreateTime.Value.ToString("yyyy-MM-dd"), p.IsDelete, p.State }; if (!string.IsNullOrEmpty(payload.Kw)) { query = query.Where(x => x.BegainSite.Contains(payload.Kw.Trim())); } if (payload.State > -1) { query = query.Where(x => x.State == payload.State); } if (payload.IsDeleted > CommonEnum.IsDeleted.All) { query = query.Where(x => x.IsDelete == Convert.ToInt32(((CommonEnum.IsDeleted)payload.IsDeleted))); } var list = query.Paged(payload.CurrentPage, payload.PageSize).ToList(); var totalCount = query.Count(); var response = ResponseModelFactory.CreateResultInstance; response.SetData(list, totalCount); ToLog.AddLog("查询", "成功:查询:公交路线管理列表数据", _dbContext); return(Ok(response)); } }