public JsonResult List(int page, int rows, string Keywords, bool?isReply = null) { ConsultationQuery consultationQuery = new ConsultationQuery() { PageNo = page, PageSize = rows, KeyWords = Keywords, ShopID = base.CurrentSellerManager.ShopId, IsReply = isReply }; PageModel <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(consultationQuery); IEnumerable <ProductConsultationModel> list = from item in consultations.Models.ToList() select new ProductConsultationModel() { Id = item.Id, ConsultationContent = ProductConsultationController.HTMLEncode(item.ConsultationContent), ConsultationDate = item.ConsultationDate, ConsultationDateStr = item.ConsultationDate.ToString("yyyy-MM-dd HH:mm"), ProductName = item.ProductInfo.ProductName, ProductPic = item.ProductInfo.ImagePath, ProductId = item.ProductId, UserName = item.UserName, ReplyContent = ProductConsultationController.HTMLEncode(item.ReplyContent), ImagePath = item.ProductInfo.ImagePath, ReplyDate = item.ReplyDate }; DataGridModel <ProductConsultationModel> dataGridModel = new DataGridModel <ProductConsultationModel>() { rows = list, total = consultations.Total }; return(Json(dataGridModel)); }
public ActionResult Index(int pageNo = 1, int pageSize = 20) { ConsultationQuery consultationQuery = new ConsultationQuery() { UserID = base.CurrentUser.Id, PageNo = pageNo, PageSize = pageSize }; PageModel <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(consultationQuery); IEnumerable <ProductConsultationModel> list = from item in consultations.Models.ToList() select new ProductConsultationModel() { Id = item.Id, ConsultationContent = item.ConsultationContent, ConsultationDate = item.ConsultationDate, ProductName = item.ProductInfo.ProductName, ProductPic = item.ProductInfo.ImagePath, ProductId = item.ProductId, UserName = item.UserName, ReplyContent = item.ReplyContent, ReplyDate = item.ReplyDate }; PagingInfo pagingInfo = new PagingInfo() { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = consultations.Total }; ViewBag.pageInfo = pagingInfo; return(View(list)); }
public JsonResult List(int page, int rows, string Keywords, int shopid = 0, bool?isReply = null) { var query = new ConsultationQuery { PageNo = page, PageSize = rows, KeyWords = Keywords, ShopID = shopid, IsReply = isReply }; var result = _iConsultationService.GetConsultations(query); IEnumerable <ProductConsultationModel> consultation = result.Models.ToArray().Select(item => new ProductConsultationModel() { Id = item.Id, ConsultationContent = HTMLEncode(item.ConsultationContent), Date = item.ConsultationDate.ToString("yyyy-MM-dd HH:mm:ss"), ProductName = item.ProductInfo.ProductName, ProductId = item.ProductId, UserName = item.UserName, ReplyContent = HTMLEncode(item.ReplyContent), ImagePath = item.ProductInfo.GetImage(ImageSize.Size_50), ReplyDate = item.ReplyDate, }); DataGridModel <ProductConsultationModel> model = new DataGridModel <ProductConsultationModel>() { rows = consultation, total = result.Total }; return(Json(model)); }
public JsonResult List(int page, int rows, string Keywords, int shopid = 0, bool?isReply = null) { var query = new ConsultationQuery { PageNo = page, PageSize = rows, KeyWords = Keywords, ShopID = shopid, IsReply = isReply }; var data = _iConsultationService.GetConsultations(query); var products = ProductManagerApplication.GetProductByIds(data.Models.Select(p => p.ProductId)); var list = data.Models.Select(item => { var product = products.FirstOrDefault(p => p.Id == item.ProductId); return(new ProductConsultationModel() { Id = item.Id, ConsultationContent = HTMLEncode(item.ConsultationContent), Date = item.ConsultationDate.ToString("yyyy-MM-dd HH:mm:ss"), ProductName = (product == null) ? "" : product.ProductName, ProductId = item.ProductId, UserName = item.UserName, ReplyContent = HTMLEncode(item.ReplyContent), ImagePath = (product == null) ? "" : product.GetImage(ImageSize.Size_50), ReplyDate = item.ReplyDate, }); }); var model = new DataGridModel <ProductConsultationModel>() { rows = list, total = data.Total }; return(Json(model)); }
// GET: Web/Register public ActionResult Index(int pageNo = 1, int pageSize = 20) { ConsultationQuery query = new ConsultationQuery(); query.UserID = CurrentUser.Id; query.PageNo = pageNo; query.PageSize = pageSize; var model = _iConsultationService.GetConsultations(query); IEnumerable <ProductConsultationModel> consultation = model.Models.ToList().Select(item => new ProductConsultationModel() { Id = item.Id, ConsultationContent = item.ConsultationContent, ConsultationDate = item.ConsultationDate, ProductName = item.ProductInfo.ProductName, ProductPic = item.ProductInfo.ImagePath, ProductId = item.ProductId, UserName = item.UserName, ReplyContent = item.ReplyContent, ReplyDate = item.ReplyDate, }); #region 分页控制 PagingInfo info = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = model.Total }; ViewBag.pageInfo = info; #endregion return(View(consultation)); }
public JsonResult List(int page, int rows, string Keywords, int shopid = 0, bool?isReply = null) { ConsultationQuery consultationQuery = new ConsultationQuery() { PageNo = page, PageSize = rows, KeyWords = Keywords, ShopID = shopid, IsReply = isReply }; PageModel <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(consultationQuery); IEnumerable <ProductConsultationModel> array = from item in consultations.Models.ToArray() select new ProductConsultationModel() { Id = item.Id, ConsultationContent = ProductConsultationController.HTMLEncode(item.ConsultationContent), Date = item.ConsultationDate.ToString("yyyy-MM-dd HH:mm:ss"), ProductName = item.ProductInfo.ProductName, ProductId = item.ProductId, UserName = item.UserName, ReplyContent = ProductConsultationController.HTMLEncode(item.ReplyContent), ImagePath = item.ProductInfo.GetImage(ProductInfo.ImageSize.Size_50, 1), ReplyDate = item.ReplyDate }; DataGridModel <ProductConsultationModel> dataGridModel = new DataGridModel <ProductConsultationModel>() { rows = array, total = consultations.Total }; return(Json(dataGridModel)); }
public QueryPageModel <ProductConsultationInfo> GetConsultations(ConsultationQuery query) { var consultation = WhereBuilder(query); var data = consultation.OrderByDescending(o => o.Id).ToPagedList(query.PageNo, query.PageSize); return(new QueryPageModel <ProductConsultationInfo>() { Models = data, Total = data.TotalRecordCount }); }
public void TestMethod1() { var IConsultation = Instance <IConsultationService> .Create; var query = new ConsultationQuery { PageNo = 1, PageSize = 3, KeyWords = "", ShopID = 1, IsReply = true }; var result = IConsultation.GetConsultations(query).Models.Select(A => new { productNAME = A.ProductInfo.ProductName, ReplyText = A.ReplyContent }); //Assert.Equals( "小米1"); }
public JsonResult GetsellerAdminMessage() { CommentQuery commentQuery = new CommentQuery() { PageNo = 1, PageSize = 100001, ShopID = base.CurrentSellerManager.ShopId, IsReply = new bool?(false) }; CommentQuery commentQuery1 = commentQuery; int num = ServiceHelper.Create <ICommentService>().GetComments(commentQuery1).Models.Count(); ConsultationQuery consultationQuery = new ConsultationQuery() { PageNo = 1, PageSize = 10000, ShopID = base.CurrentSellerManager.ShopId, IsReply = new bool?(false) }; ConsultationQuery consultationQuery1 = consultationQuery; int num1 = ServiceHelper.Create <IConsultationService>().GetConsultations(consultationQuery1).Models.Count(); IOrderService orderService = ServiceHelper.Create <IOrderService>(); OrderQuery orderQuery = new OrderQuery() { PageNo = 1, PageSize = 10000, Status = new OrderInfo.OrderOperateStatus?(OrderInfo.OrderOperateStatus.WaitPay), ShopId = new long?(base.CurrentSellerManager.ShopId) }; int num2 = orderService.GetOrders <OrderInfo>(orderQuery, null).Models.Count(); IOrderService orderService1 = ServiceHelper.Create <IOrderService>(); OrderQuery orderQuery1 = new OrderQuery() { PageNo = 1, PageSize = 10000, Status = new OrderInfo.OrderOperateStatus?(OrderInfo.OrderOperateStatus.WaitDelivery), ShopId = new long?(base.CurrentSellerManager.ShopId) }; int num3 = orderService1.GetOrders <OrderInfo>(orderQuery1, null).Models.Count(); IComplaintService complaintService = ServiceHelper.Create <IComplaintService>(); ComplaintQuery complaintQuery = new ComplaintQuery() { PageNo = 1, PageSize = 10000, ShopId = new long?(base.CurrentSellerManager.ShopId), Status = new OrderComplaintInfo.ComplaintStatus?(OrderComplaintInfo.ComplaintStatus.WaitDeal) }; int num4 = complaintService.GetOrderComplaints(complaintQuery).Models.Count(); int num5 = num1 + num + num2 + num4 + num3; return(Json(new { UnReplyConsultations = num1, UnReplyComments = num, UnPayOrder = num2, UnComplaints = num4, UnDeliveryOrder = num3, AllMessageCount = num5 }, JsonRequestBehavior.AllowGet)); }
public PageModel <ProductConsultationInfo> GetConsultations(ConsultationQuery query) { int num = 0; IQueryable <ProductConsultationInfo> shopID = context.ProductConsultationInfo.Include <ProductConsultationInfo, ProductInfo>((ProductConsultationInfo a) => a.ProductInfo).AsQueryable <ProductConsultationInfo>(); if (query.IsReply.HasValue) { shopID = from item in shopID where (query.IsReply.Value ? item.ReplyDate.HasValue : !item.ReplyDate.HasValue) select item; } if (!string.IsNullOrWhiteSpace(query.KeyWords)) { shopID = from item in shopID where item.ConsultationContent.Contains(query.KeyWords) select item; } if (query.ShopID > 0) { shopID = from item in shopID where query.ShopID == item.ShopId select item; } if (query.ProductID > 0) { shopID = from item in shopID where query.ProductID == item.ProductId select item; } if (query.UserID > 0) { shopID = from item in shopID where query.UserID == item.UserId select item; } shopID = shopID.GetPage(out num, query.PageNo, query.PageSize, null); return(new PageModel <ProductConsultationInfo>() { Models = shopID, Total = num }); }
// GET: Web/Register public ActionResult Index(int pageNo = 1, int pageSize = 20) { var query = new ConsultationQuery { UserID = CurrentUser.Id, PageNo = pageNo, PageSize = pageSize }; var model = _iConsultationService.GetConsultations(query); var products = ProductManagerApplication.GetProductByIds(model.Models.Select(p => p.ProductId)); var consultation = model.Models.Select(item => { var product = products.FirstOrDefault(p => p.Id == item.ProductId); return(new ProductConsultationModel() { Id = item.Id, ConsultationContent = item.ConsultationContent, ConsultationDate = item.ConsultationDate, ProductName = product.ProductName, ProductPic = product.ImagePath, ProductId = item.ProductId, UserName = item.UserName, ReplyContent = item.ReplyContent, ReplyDate = item.ReplyDate, }); }); #region 分页控制 PagingInfo info = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = model.Total }; ViewBag.pageInfo = info; #endregion ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View(consultation)); }
private GetBuilder <ProductConsultationInfo> WhereBuilder(ConsultationQuery query) { var db = DbFactory.Default.Get <ProductConsultationInfo>(); if (query.IsReply.HasValue) { if (query.IsReply.Value) { db.Where(item => item.ReplyDate.ExIsNotNull()); } else { db.Where(item => item.ReplyDate.ExIsNull()); } } if (!string.IsNullOrWhiteSpace(query.KeyWords)) { db.Where(item => item.ConsultationContent.Contains(query.KeyWords)); } if (query.ShopID > 0) { db.Where(item => query.ShopID == item.ShopId); } if (query.ProductID > 0) { db.Where(item => query.ProductID == item.ProductId); } if (query.UserID > 0) { db.Where(item => query.UserID == item.UserId); } return(db); }
public ObsoletePageModel <ProductConsultationInfo> GetConsultations(ConsultationQuery query) { int total = 0; IQueryable <ProductConsultationInfo> consultation = Context.ProductConsultationInfo.Include(a => a.ProductInfo).AsQueryable(); #region 条件组合 if (query.IsReply.HasValue) { consultation = consultation.Where(item => (query.IsReply.Value ? item.ReplyDate.HasValue : !item.ReplyDate.HasValue)); } if (!string.IsNullOrWhiteSpace(query.KeyWords)) { consultation = consultation.Where(item => item.ConsultationContent.Contains(query.KeyWords)); } if (query.ShopID > 0) { consultation = consultation.Where(item => query.ShopID == item.ShopId); } if (query.ProductID > 0) { consultation = consultation.Where(item => query.ProductID == item.ProductId); } if (query.UserID > 0) { consultation = consultation.Where(item => query.UserID == item.UserId); } #endregion consultation = consultation.GetPage(out total, query.PageNo, query.PageSize); ObsoletePageModel <ProductConsultationInfo> pageModel = new ObsoletePageModel <ProductConsultationInfo>() { Models = consultation, Total = total }; return(pageModel); }
/// <summary> /// 获取咨询数据 /// </summary> /// <param name="query"></param> /// <returns></returns> public static QueryPageModel <ProductConsultationInfo> GetConsultations(ConsultationQuery query) { return(Service.GetConsultations(query)); }
/// <summary> /// 获取咨询数 /// </summary> /// <param name="query"></param> /// <returns></returns> public static int GetConsultationCount(ConsultationQuery query) { return(Service.GetConsultationCount(query)); }
public int GetConsultationCount(ConsultationQuery query) { var db = WhereBuilder(query); return(db.Count()); }