public ObsoletePageModel <ProductEvaluation> GetProductEvaluationTwo(CommentQuery query) { int total = 0; IQueryable <OrderItemInfo> order = Context.OrderItemInfo.FindBy(a => a.OrderInfo.UserId == query.UserID && a.OrderInfo.OrderStatus == Himall.Model.OrderInfo.OrderOperateStatus.Finish); var orderBy = order.GetOrderBy(d => d.OrderByDescending(o => o.Id)); if ((!string.IsNullOrWhiteSpace(query.Sort)) && query.Sort.Equals("PComment")) { orderBy = order.GetOrderBy(d => d.OrderBy(a => Context.OrderCommentInfo.Any(b => b.OrderId == a.OrderId && b.UserId == query.UserID))); } order = order.GetPage(out total, query.PageNo, query.PageSize, orderBy); var model = order.Select(a => new ProductEvaluation { ProductId = a.ProductId, ThumbnailsUrl = a.ThumbnailsUrl, ProductName = a.ProductName, BuyTime = Context.ProductCommentInfo.Where(c => c.ProductId == a.ProductId && c.SubOrderId == a.Id).FirstOrDefault() != null ? Context.ProductCommentInfo.Where(c => c.ProductId == a.ProductId && c.SubOrderId == a.Id).FirstOrDefault().ReviewDate : DateTime.MinValue, EvaluationStatus = Context.ProductCommentInfo.Any(b => b.ProductId == a.ProductId && b.UserId == query.UserID && b.SubOrderId == a.Id), Id = a.Id, OrderId = a.OrderId }); ObsoletePageModel <ProductEvaluation> pageModel = new ObsoletePageModel <ProductEvaluation>() { Models = model, Total = total }; return(pageModel); }
public async Task <IEnumerable <MetaAdaptivReconComment> > GetComments(IQueryCommentServiceRepository <MetaAdaptivReconComment> repository) { var query = new CommentQuery(); var handler = new CommentHandlerFactory(repository).Build(query); return(await handler.Get()); }
public IEnumerable <CommentDTO> Execute(CommentQuery request) { var query = Context.Comments.AsQueryable(); query.Include(c => c.Ad); if (request.Text != null) { query = query.Where(c => c.Text .ToLower() .Contains(request.Text.ToLower())); } return(query.Select(c => new CommentDTO { Id = c.Id, Text = c.Text, Ad = new AdDTO { Id = c.Id, Title = c.Ad.Title, Body = c.Ad.Body, Price = c.Ad.Price, IsShipping = c.Ad.IsShipping } })); }
public async Task <IPaged <CommentViewModel> > Paged(int pageIndex = 1, int pageSize = 10, CommentQueryParameter param = null) { var result = await CommentQuery.PagedAsync(pageIndex, pageSize, param); var paged = result.MapPaged <CommentViewModel>(); return(paged); }
public async Task <IEnumerable <CommentViewModel> > CommentList(CommentQueryParameter param) { var items = await CommentQuery.SelectAsync(param); var result = items.MapList <CommentViewModel>(); return(result); }
public async Task <CommentViewModel> CommentGet(Guid id) { var item = await CommentQuery.FindAsync(id); var result = item.Map <CommentViewModel>(); return(result); }
public async Task <Paged <Comment> > SearchAsync(CommentQuery query) { ArgumentGuard.NotNull(query, nameof(query)); var commentDbQuery = ToDbQuery(query); return(await _commentRepository.SearchAsync(commentDbQuery)); }
public Comment VoteDown(int id) { var selected = new CommentQuery().QueryById(_context, id); selected?.DecrementScore(); _context.SaveChanges(); return(selected); }
public QueryPageModel <ProductCommentInfo> GetComments(CommentQuery query) { var db = WhereBuilder(query); var data = db.ToPagedList(query.PageNo, query.PageSize); return(new QueryPageModel <ProductCommentInfo>() { Models = data, Total = data.TotalRecordCount }); }
private IQueryable <Comment> Where(CommentQuery queries) { if (!string.IsNullOrEmpty(queries.TaskId)) { var taskId = Guid.Parse(queries.TaskId); return(Where(x => x.TaskId == taskId && x.EntityStatus == EntityStatus.Activated)); } return(Where(x => x.EntityStatus == EntityStatus.Activated)); }
private CommentDbQuery ToDbQuery(CommentQuery query) { return(new CommentDbQuery { PageNumber = query.PageNumber, PageSize = query.PageSize, PostId = query.PostId, CommentId = query.CommentId }); }
public JsonResult List(int page, int rows, string Keywords, int shopid = 0, bool?isReply = null) { IOrderService orderService = ServiceHelper.Create <IOrderService>(); CommentQuery commentQuery = new CommentQuery() { PageNo = page, PageSize = rows, KeyWords = Keywords, ShopID = shopid, IsReply = isReply }; PageModel <ProductCommentInfo> comments = ServiceHelper.Create <ICommentService>().GetComments(commentQuery); IEnumerable <ProductCommentModel> list = ( from item in comments.Models select new ProductCommentModel() { CommentContent = item.ReviewContent, CommentDate = item.ReviewDate, ReplyContent = item.ReplyContent, CommentMark = item.ReviewMark, ReplyDate = item.ReplyDate, Id = item.Id, ProductName = item.ProductInfo.ProductName, ProductId = item.ProductId, ImagePath = item.Himall_OrderItems.ThumbnailsUrl, UserName = item.UserName, OderItemId = item.SubOrderId, Color = "", Version = "", Size = "" }).ToList(); foreach (ProductCommentModel color in list) { if (!color.OderItemId.HasValue) { continue; } OrderItemInfo orderItem = orderService.GetOrderItem(color.OderItemId.Value); if (orderItem == null) { continue; } color.Color = orderItem.Color; color.Size = orderItem.Size; color.Version = orderItem.Version; } DataGridModel <ProductCommentModel> dataGridModel = new DataGridModel <ProductCommentModel>() { rows = list, total = comments.Total }; return(Json(dataGridModel)); }
public static int GetCommentCountByProduct(long product) { //TODO:FG 此方法调用需要优化 var query = new CommentQuery { ProductID = product, IsHidden = false, }; return(Service.GetCommentCount(query)); }
public IActionResult Get(int id) { var existingComment = new CommentQuery().QueryById(_context, id); if (existingComment == null) { return(NotFound()); } return(new ObjectResult(existingComment)); }
public IEnumerable <Comment> Fetch(CommentQuery query) { try { return(DoFetch(query)); } catch (Exception ex) { Log(MessageType.Error, "Fetch", ex.ToMessageWithType(), ex); throw new GraphException(StringConsts.GS_FETCH_RATING_ERROR.Args(query.G_TargetNode), ex); } }
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)); }
// // GET: /Comment/ public ActionResult Index(long id) { var query = new CommentQuery() { OwnerID = OwnerID, ProductID = id, Includes = new[] { "Product" }, Take = PageSize, }; var comments = Service.SelectOrEmpty(query); ViewData["Pagination"] = Pagination.FromQuery(query); return(View(comments.ToArray())); }
private void viewComments() { if (lbNodes.SelectedItem != null) { GraphNode gn = (GraphNode)lbNodes.SelectedItem; var qry = CommentQuery.MakeNew(gn.GDID, DIMENSION, CommentOrderType.ByDate, false, DateTime.UtcNow, 0); var comments = m_CommentClient.Fetch(qry); lbComments.Items.Clear(); comments.ForEach(comment => lbComments.Items.Add(comment)); } else { MessageBox.Show("Select graph node", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public async Task <BacklogResponse <Comment[]> > GetCommentsAsync(CommentQuery query = null) { if (Id < 0) { throw new InvalidOperationException("ticket retrieved not from the server"); } query = query ?? new CommentQuery(); var response = await _client.GetAsync($"/api/v2/issues/{Id}/comments", query.Build()).ConfigureAwait(false); return(await _client.CreateResponseAsync <Comment[], List <_Comment> >( response, HttpStatusCode.OK, data => data.Select(x => new Comment(x, this)).ToArray()).ConfigureAwait(false)); }
public IActionResult Get([FromQuery] CommentQuery query) { try { return(Ok(getComments.Execute(query))); } catch (Exception e) { return(StatusCode(500, new { Errors = new List <string> { e.Message } })); } }
// GET: Comments public ActionResult Index([FromQuery] CommentQuery query) { try { return(View(executor.ExecuteQuery(getComments, query))); } catch (EntityNotAllowedException) { return(RedirectToAction("PageNotFound", "Redirections")); } catch (Exception e) { TempData["error"] = e.Message; } return(RedirectToAction("Home", "Index")); }
public async Task <QueryResult <Comment> > GetComments(int id, CommentQuery commentQuery) { var comments = _context.Comments .Where(c => c.BlogPostId == id).AsQueryable(); var count = comments.Count(); comments = comments.OrderByDescending(c => c.Id); comments = comments.Skip((commentQuery.CurrentCount - 1) * 5) .Take(5); var queryResult = new QueryResult <Comment>(); queryResult.TotalItems = count; queryResult.BlogPosts = await comments.ToListAsync(); return(queryResult); }
public PageModel <ProductCommentInfo> GetComments(CommentQuery query) { int num = 0; IQueryable <ProductCommentInfo> shopID = context.ProductCommentInfo.Include <ProductCommentInfo, ProductInfo>((ProductCommentInfo a) => a.ProductInfo).AsQueryable <ProductCommentInfo>(); if (query.IsReply.HasValue) { shopID = from item in shopID where (query.IsReply.Value ? item.ReplyDate.HasValue : !item.ReplyDate.HasValue) 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; } if (!string.IsNullOrWhiteSpace(query.KeyWords)) { shopID = from item in shopID where item.ReviewContent.Contains(query.KeyWords) select item; } shopID = shopID.GetPage(out num, query.PageNo, query.PageSize, null); return(new PageModel <ProductCommentInfo>() { Models = shopID, Total = num }); }
/// <summary> /// Display <see cref="Comments"/> objects in current app. /// </summary> /// <param name="app">The app</param> /// <param name="query">An object with query parameters for search, paging etc.</param> public override ActionResult Get(Comments app, Query query) { var commentsQuery = new CommentQuery(query) { Parent = app }; commentsQuery.Top = PageSizes[0] / 5; // NOTE: reduced number of items/page for better perf. app.SearchResult = CommentService.Search(commentsQuery); if (Request.IsAjaxRequest()) { // infinite scroll, return partial view return(PartialView("_CommentSearchResult", app.SearchResult)); } // REVIEW: can we do this automagically? return(View(app)); }
public ActionResult Index(int pageSize = 10, int pageNo = 1) { CommentQuery commentQuery = new CommentQuery() { UserID = base.CurrentUser.Id, PageSize = pageSize, PageNo = pageNo, Sort = "PComment" }; PageModel <ProductEvaluation> productEvaluation = ServiceHelper.Create <ICommentService>().GetProductEvaluation(commentQuery); PagingInfo pagingInfo = new PagingInfo() { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = productEvaluation.Total }; ViewBag.pageInfo = pagingInfo; return(View(productEvaluation.Models)); }
public async Task <IHttpActionResult> Get([FromUri] CommentQuery query) { IHttpActionResult res = BadRequest(); var serviceRes = await _commentService.GetList(new CommentGetListRequest() { Query = query ?? new CommentQuery() }); if (serviceRes.Access == ResponseAccess.Deny) { res = Unauthorized(serviceRes.Message); } if (serviceRes.Access == ResponseAccess.Granted) { res = Ok(serviceRes); } return(res); }
public ActionResult GetComments(CommentQuery query) { if (!query.AnswerID.HasValue) { return(Json(new { Code = -400, Msg = "参数不能为空", Data = "" })); } if (!query.PageIndex.HasValue) { query.PageIndex = 1; } if (!query.PageSize.HasValue) { query.PageSize = 10; } query.UserID = this.UserData.UserID; PageVM <BBSCommentVM> pgVM = new BBSCommentService().GetComments(query); if (pgVM == null || pgVM.Data == null || pgVM.Data.Count == 0) { return(Json(new { Code = -200, Msg = "暂无数据", Data = "" })); } return(Json(new { Code = 200, Msg = "获取成功", Data = pgVM })); }
public IHttpActionResult GetRevision(long revision) { RevisionDetailViewModel viewModel = null; UnitOfWork unitOfWork = null; try { unitOfWork = new UnitOfWork(); var commitDiff = new SourceControl().GetRevision(revision); var commentQuery = new CommentQuery(unitOfWork.Context.Comments) { Revision = revision }; var comments = commentQuery.Execute(); // merge data to view model efficiently Commit commit = unitOfWork.Context.Commits.FirstOrDefault(c => c.Revision == revision); viewModel = RevisionDetailViewModel.Create(commit, commitDiff, comments); } catch (Exception ex) { System.Diagnostics.Trace.TraceError("GetRevision: " + ex); return(InternalServerError(ex)); } finally { if (unitOfWork != null) { unitOfWork.Dispose(); } } return(Ok(viewModel)); }
public PageModel <ProductEvaluation> GetProductEvaluation(CommentQuery query) { int num = 0; IQueryable <OrderItemInfo> page = context.OrderItemInfo.FindBy((OrderItemInfo a) => a.OrderInfo.UserId == query.UserID && (int)a.OrderInfo.OrderStatus == 5); Func <IQueryable <OrderItemInfo>, IOrderedQueryable <OrderItemInfo> > orderBy = page.GetOrderBy <OrderItemInfo>((IQueryable <OrderItemInfo> d) => from o in d orderby o.Id descending select o); if (!string.IsNullOrWhiteSpace(query.Sort) && query.Sort.Equals("PComment")) { orderBy = page.GetOrderBy <OrderItemInfo>((IQueryable <OrderItemInfo> d) => from a in d orderby context.OrderCommentInfo.Any((OrderCommentInfo b) => b.OrderId == a.OrderId && b.UserId == query.UserID) descending select a); } page = page.GetPage(out num, query.PageNo, query.PageSize, orderBy); IQueryable <ProductEvaluation> productEvaluation = from a in page orderby context.OrderInfo.Where((OrderInfo q) => q.Id == a.OrderId).FirstOrDefault() == null ? "" : (context.OrderInfo.Where((OrderInfo q) => q.Id == a.OrderId).FirstOrDefault().FinishDate == null ? "" : context.OrderInfo.Where((OrderInfo q) => q.Id == a.OrderId).FirstOrDefault().FinishDate.ToString()) descending select new ProductEvaluation() { ProductId = a.ProductId, ThumbnailsUrl = a.ThumbnailsUrl, ProductName = a.ProductName, BuyTime = (context.OrderCommentInfo.Any((OrderCommentInfo c) => c.OrderId == a.OrderId) ? context.OrderCommentInfo.Where((OrderCommentInfo c) => c.OrderId == a.OrderId).FirstOrDefault().CommentDate : DateTime.MinValue), EvaluationStatus = context.OrderCommentInfo.Any((OrderCommentInfo b) => b.OrderId == a.OrderId && b.UserId == query.UserID), Id = a.Id, CommentId = context.ProductCommentInfo.Where((ProductCommentInfo c) => c.ChemCloud_OrderItems.OrderId == a.OrderId).FirstOrDefault().Id, OrderId = a.OrderId, FinishDate = context.OrderInfo.Where((OrderInfo q) => q.Id == a.OrderId).FirstOrDefault() == null ? "" : (context.OrderInfo.Where((OrderInfo q) => q.Id == a.OrderId).FirstOrDefault().FinishDate == null ? "" : context.OrderInfo.Where((OrderInfo q) => q.Id == a.OrderId).FirstOrDefault().FinishDate.ToString()), ShopName = context.ShopInfo.Where((ShopInfo q) => q.Id == a.ShopId).FirstOrDefault() == null ? "" : context.ShopInfo.Where((ShopInfo q) => q.Id == a.ShopId).FirstOrDefault().ShopName }; return(new PageModel <ProductEvaluation>() { Models = productEvaluation, Total = num }); }
public void By_Revision() { using (var database = new DbCodeReview()) { database.Comments.AddRange(new Comment[] { new Comment() { Revision = 1111, LineId = "1212", User = "******", Text = "1111Comment1" }, new Comment() { Revision = 1111, LineId = "1212", User = "******", Text = "1111Comment2" }, new Comment() { Revision = 3333, LineId = "1212", User = "******", Text = "333Comment1" }, new Comment() { Revision = 11111, LineId = "1212", User = "******", Text = "1111Comment1" }, }); database.SaveChanges(); } using (var database = new DbCodeReview()) { var sut = new CommentQuery(database.Comments) { Revision = 1111 }; var result = sut.Execute(); Assert.AreEqual(2, result.Count <Comment>()); Assert.AreEqual(2, result.Where(c => c.Revision == 1111).Count <Comment>()); } }