public IActionResult DecompInfo(HotelRequestPayload payload) { using (_dbContext) { var query = _dbContext.HotelRoom.Where(x => x.HotelUuid.ToString() == payload.Kw && x.IsDelete == 0); query = query.OrderByDescending(x => x.Id); 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(HotelRequestPayload payload) { using (_dbContext) { var query = from p in _dbContext.Hotel orderby p.CreateTime descending select new { p.HotelUuid, p.Name, p.Phone, p.Address, p.Price, ShopId = p.ShopId == null ? -1 : p.ShopId, p.IsDelete, CreateTime = p.CreateTime.Value.ToString("yyyy-MM-dd"), p.State }; if (!string.IsNullOrEmpty(payload.Kw)) { query = query.Where(x => x.Name.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)); } }