private ResultDTO <List <QrTypeDTO> > GetQrCodeTypeListExt(WeChatQRCodeSearchDTO search) { IEnumerable <WeChatQrCodeType> query = WeChatQrCodeType.ObjectSet().AsQueryable(); //if (!search.IsShowCatering) //{ // query = WeChatQrCodeType.ObjectSet().Where(c => c.UseTye != 1); //} List <QrTypeDTO> resultData = query.Select(c => new QrTypeDTO { Type = c.Type, Description = c.Description }).ToList(); return(new ResultDTO <List <QrTypeDTO> > { isSuccess = true, Message = "success", Data = resultData }); }
private ResultDTO <ListResult <WeChatQRCodeShowDTO> > GetWechatQrCodeListExt(WeChatQRCodeSearchDTO search) { var result = new ListResult <WeChatQRCodeShowDTO>(); //var query = BE.WeChatQRCode.ObjectSet().Where(c => c.IsDel != 1 && c.AppId == search.AppId); var query = from code in WeChatQRCode.ObjectSet() join type in WeChatQrCodeType.ObjectSet() on code.QRType.Value equals type.Type where code.IsDel != 1 && code.AppId == search.AppId select new { Id = code.Id, WeChatPublicCode = code.WeChatPublicCode, AppId = code.AppId, QRNo = code.QRNo, WeChatTicket = code.WeChatTicket, StoreId = code.StoreId, IsDel = code.IsDel, IsUse = code.IsUse, SpreadInfoId = code.SpreadInfoId, Description = code.Description, QRType = code.QRType, SubTime = code.SubTime, QRTypeDesc = type.Description, QRTypeUseType = type.UseTye, Name = code.Name }; if (search.QRType.HasValue) { query = query.Where(q => q.QRType.Value == search.QRType.Value); } //else if (!search.IsShowCatering) //{ // query = query.Where(c => c.QRTypeUseType != 1); //} if (!string.IsNullOrEmpty(search.WeChatPublicCode)) { query = query.Where(q => q.WeChatPublicCode == search.WeChatPublicCode); } if (search.IsUse.HasValue) { query = query.Where(q => q.IsUse == search.IsUse.Value); } result.Count = query.Count(); result.List = query.OrderByDescending(q => q.SubTime). Skip((search.PageIndex - 1) * search.PageSize). Take(search.PageSize). Select(q => new WeChatQRCodeShowDTO { Id = q.Id, WeChatPublicCode = q.WeChatPublicCode, AppId = q.AppId, QRNo = q.QRNo, WeChatTicket = q.WeChatTicket, StoreId = q.StoreId, IsDel = q.IsDel, IsUse = q.IsUse, SpreadInfoId = q.SpreadInfoId, Description = q.Description, QRType = q.QRType.Value, SubTime = q.SubTime, QrTypeDesc = q.QRTypeDesc, Name = q.Name }). ToList(); if (result.List.Any()) { foreach (var weChatQrCodeShowDTO in result.List) { if (string.IsNullOrEmpty(weChatQrCodeShowDTO.Name)) { weChatQrCodeShowDTO.Name = weChatQrCodeShowDTO.QRNo.ToString(CultureInfo.InvariantCulture); } } } return(new ResultDTO <ListResult <WeChatQRCodeShowDTO> >() { isSuccess = true, Data = result }); }