public virtual async Task <PageListResultDto <NewsListDto> > GetNewss(GetPageListRequstDto dto) { var query = _newsRepository.GetAll(); var count = await query.GroupJoin(_newsProjectRepository.GetAll(), left => left.Id, right => right.NewsId, (left, right) => new { News = left, NewsProjects = right }).CountAsync(t => t.News.AllProjects || t.NewsProjects.FirstOrDefault().ProjectId == _frontSession.ProjectId); var list = await query.GroupJoin(_newsProjectRepository.GetAll(), left => left.Id, right => right.NewsId, (left, right) => new { News = left, NewsProjects = right }) .Where( t => t.News.AllProjects || t.NewsProjects.FirstOrDefault().ProjectId == _frontSession.ProjectId) .OrderBy(t => t.News.Sort) .PageBy(dto) .ToListAsync(); var list1 = list.Select(t => t.News).ToList(); var pageList = list1.MapTo <List <NewsListDto> >(); return(new PageListResultDto <NewsListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <SubstationListDto> > GetSubstations(GetPageListRequstDto dto) { var query = _substationRepository.GetAll(); var where = FilterExpression.FindByGroup <Substation>(dto.Filter); var count = await query.Where(where).CountAsync(); var list = await query.Where(where).OrderByDescending(t => t.Sort).PageBy(dto).ToListAsync(); var pageList = list.MapTo <List <SubstationListDto> >(); return(new PageListResultDto <SubstationListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <ForumPostListDto> > GetForumPosts(GetPageListRequstDto dto) { var query = _forumPostRepository.GetAll(); var where = FilterExpression.FindByGroup <ForumPost>(dto.Filter); var queryCount = query.Where(where) .GroupJoin(_memberRepository.GetAll(), left => left.MemberId, right => right.Id, (left, right) => new { Posts = left, Member = right }) .GroupJoin(_plateRepository.GetAll(), left => left.Posts.PlateId, right => right.Id, (left, right) => new { Posts = left.Posts, Member = left.Member, Plate = right }); int count = await queryCount.CountAsync(); var queryList = query.Where(where) .GroupJoin(_memberRepository.GetAll(), left => left.MemberId, right => right.Id, (left, right) => new { Posts = left, Member = right }) .GroupJoin(_plateRepository.GetAll(), left => left.Posts.PlateId, right => right.Id, (left, right) => new { Posts = left.Posts, Member = left.Member, Plate = right }); var list = await queryList.OrderByDescending(t => t.Posts.LastCommentTime).PageBy(dto).ToListAsync(); var posts = list.Select(item => new ForumPostListDto() { Id = item.Posts.Id, CommentCount = item.Posts.CommentCount, CreationTime = item.Posts.CreationTime, LastCommentTime = item.Posts.LastCommentTime, MemberName = item.Member.FirstOrDefault()?.Name, PlateName = item.Plate.FirstOrDefault()?.Name, ReadCount = item.Posts.ReadCount, Title = item.Posts.Title }).ToList(); return(new PageListResultDto <ForumPostListDto>(count, posts, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <ProjectListDto> > GetProjects(GetPageListRequstDto dto) { var query = _projectRepository.GetAll(); var where = FilterExpression.FindByGroup <Project>(dto.Filter); var count = await query.Where(where).CountAsync(); var list = await query.Where(where).OrderBy(t => t.Code).PageBy(dto).ToListAsync(); var pageList = list.MapTo <List <ProjectListDto> >(); return(new PageListResultDto <ProjectListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <GrouponListDto> > GetGroupons(GetPageListRequstDto dto) { var query = _grouponRepository.GetAll(); var where = FilterExpression.FindByGroup <Groupon>(dto.Filter); var queryCount = query.Where(where) .GroupJoin(_productRepository.GetAll(), left => left.ProductId, right => right.Id, (left, right) => new { Groupon = left, Product = right }); //if (FilterExpression.HasValue(dto.Filter, "userName")) //{ // string value = FilterExpression.GetValue(input.Filter, "userName"); // queryCount = queryCount.Where(t => t.User.FirstOrDefault().Name.Contains(value)); //} int count = await queryCount.CountAsync(); var queryList = query.Where(where) .GroupJoin(_productRepository.GetAll(), left => left.ProductId, right => right.Id, (left, right) => new { Groupon = left, Product = right }); //var list = queryList.OrderByDescending(t => t.Groupon.CreationTime).PageBy(dto).ToListAsync(); var tts = await queryList.Select(t => new GrouponAndProduct() { Groupon = t.Groupon, Product = t.Product.FirstOrDefault() }).OrderByDescending(t => t.Groupon.CreationTime).PageBy(dto).ToListAsync(); var grouponListDtos = tts.Select( result => { var auditLogListDto = result.Groupon.MapTo <GrouponListDto>(); auditLogListDto.Name = result.Product?.Name; auditLogListDto.Thumbnail = result.Product?.Thumbnail; return(auditLogListDto); }).ToList(); var pageList = grouponListDtos.MapTo <List <GrouponListDto> >(); return(new PageListResultDto <GrouponListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <NoticeListDto> > GetNotices(GetPageListRequstDto dto) { var query = _noticeRepository.GetAll(); var where = FilterExpression.FindByGroup <Notice>(dto.Filter); var count = await query.Where(where).CountAsync(); var list = await query .Where(where) .OrderByDescending(t => t.Sort) .PageBy(dto).ToListAsync(); var pageList = list.MapTo <List <NoticeListDto> >(); #region 包装项目名称 foreach (var listDto in pageList) { if (listDto.AllProjects) { continue; } var q1 = _noticeProjectRepository.GetAll().Where(t => t.NoticeId == listDto.Id) .GroupJoin(_projectRepository.GetAll(), left => left.ProjectId, right => right.Id, (left, right) => new { NoticeProjects = left, Project = right }); var projects = await q1.ToListAsync(); var pnames = projects.Select(t => { var firstOrDefault = t.Project.FirstOrDefault(); if (firstOrDefault != null) { return(firstOrDefault.Name); } else { return(""); } }).ToList(); listDto.ProjectNames = pnames; } #endregion return(new PageListResultDto <NoticeListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <RefundOrderListDto> > GetRefundOrders(GetPageListRequstDto dto) { var query = _refundOrderRepository.GetAll(); var where = FilterExpression.FindByGroup <RefundOrder>(dto.Filter); var queryCount = query.Where(where); int count = await queryCount.CountAsync(); var queryList = query.Where(where); var tts = await queryList.OrderByDescending(t => t.CreationTime).PageBy(dto).ToListAsync(); var pageList = tts.MapTo <List <RefundOrderListDto> >(); return(new PageListResultDto <RefundOrderListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <MallSlideImageListDto> > GetMallSlideImages(GetPageListRequstDto dto) { var query = _mallslideimageRepository.GetAll(); var where = FilterExpression.FindByGroup <MallSlideImage>(dto.Filter); var count = await query.Where(where).CountAsync(); var list = await query.Where(where).OrderBy(t => t.Sort).PageBy(dto).ToListAsync(); var pageList = list.MapTo <List <MallSlideImageListDto> >(); return(new PageListResultDto <MallSlideImageListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <RentsaleinfoImageListDto> > GetRentsaleinfoImages(GetPageListRequstDto dto) { var query = _rentsaleinfoimageRepository.GetAll(); var where = FilterExpression.FindByGroup <RentsaleinfoImage>(dto.Filter); var count = await query.Where(where).CountAsync(); var list = await query.Where(where).OrderByDescending(t => t.CreationTime).PageBy(dto).ToListAsync(); var pageList = list.MapTo <List <RentsaleinfoImageListDto> >(); return(new PageListResultDto <RentsaleinfoImageListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
protected GetPageListRequstDto BuildPageListRequstDto() { GetPageListRequstDto dto = new GetPageListRequstDto(); dto.PageSize = 10;//固定 dto.CurrentPage = this.Request["p"].ParseTo(1); //分析查询参数 string q = this.Request["q"] ?? ""; var paras = q.Split('|'); foreach (string para in paras) { var item = para.Split(':'); if (item.Length != 2) { continue; } string field = item[0]; var kvs = item[1].Split(','); if (kvs.Length != 5 && kvs.Length != 6) { continue; } FilterCondition condition = new FilterCondition(); condition.Field = field; condition.ignore = kvs[0] == "1"; condition.logic = (kvs[1] == "1" ? "OR" : "AND"); string type = "like"; switch (kvs[2]) { case "0": type = "text"; break; case "1": type = "list"; break; case "2": type = "date"; break; } condition.type = type; if (condition.type == "date" && kvs.Length != 6) { continue; } if (condition.type != "date" && kvs.Length != 5) { continue; } string @operator = "like"; switch (kvs[3]) { case "0": @operator = "like"; break; case "1": @operator = "equal"; break; case "2": @operator = "range"; break; } condition.@operator = @operator; if (condition.type != "date") { condition.value = kvs[4]; } else { condition.minValue = kvs[4]; condition.maxValue = kvs[5]; } dto.Filter.Add(condition); } ViewData["___searchparas"] = q; return(dto); }
public virtual async Task <PageListResultDto <RentsaleinfoListDto> > GetMyRentsaleinfos(string memberId, int type, GetPageListRequstDto dto) { var query = _rentsaleinfoRepository.GetAll(); var where = FilterExpression.FindByGroup <Rentsaleinfo>(dto.Filter); where = where.And(t => t.MemberId == memberId); switch (type) { case 0: where = where.And(t => !t.IsShow); break; case 1: where = where.And(t => t.IsShow && t.IsSale); break; case 2: where = where.And(t => t.IsShow && !t.IsSale); break; } var count = await query.Where(where).CountAsync(); var list = await query.Where(where).OrderByDescending(t => t.CreationTime).PageBy(dto).ToListAsync(); var pageList = list.MapTo <List <RentsaleinfoListDto> >(); return(new PageListResultDto <RentsaleinfoListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <ActivityPersonListDto> > GetActivityPersons(long activityId, GetPageListRequstDto dto) { var query = _activityPersonRepository.GetAll(); var where = FilterExpression.FindByGroup <ActivityPerson>(dto.Filter); where = where.And(t => t.ActivityId == activityId); var count = await query.Where(where).CountAsync(); var list = await query.Where(where).OrderByDescending(t => t.CreationTime).PageBy(dto).ToListAsync(); var pageList = list.MapTo <List <ActivityPersonListDto> >(); return(new PageListResultDto <ActivityPersonListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public virtual async Task <PageListResultDto <LifeInfoListDto> > GetLifeInfoList(GetPageListRequstDto dto, long lifeInfoTypeId) { var query = _lifeInfoRepository.GetAll(); var count = await query.GroupJoin(_lifeInfoProjectRepository.GetAll(), left => left.Id, right => right.LifeInfoId, (left, right) => new { LifeInfo = left, LifeInfoProjects = right }).CountAsync(t => ((t.LifeInfo.AllProjects || t.LifeInfoProjects.FirstOrDefault().ProjectId == _frontSession.ProjectId) && t.LifeInfo.LifeInfoTypeId == lifeInfoTypeId)); var list = await query.GroupJoin(_lifeInfoProjectRepository.GetAll(), left => left.Id, right => right.LifeInfoId, (left, right) => new { LifeInfo = left, LifeInfoProjects = right }) .Where( t => ((t.LifeInfo.AllProjects || t.LifeInfoProjects.FirstOrDefault().ProjectId == _frontSession.ProjectId) && t.LifeInfo.LifeInfoTypeId == lifeInfoTypeId)) .OrderBy(t => t.LifeInfo.Sort) .PageBy(dto) .ToListAsync(); var list1 = list.Select(t => t.LifeInfo).ToList(); var pageList = list1.MapTo <List <LifeInfoListDto> >(); return(new PageListResultDto <LifeInfoListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public virtual async Task <PageListResultDto <RentsaleinfoListDto> > GetRentsaleinfos(int mode, GetPageListRequstDto dto) { var query = _rentsaleinfoRepository.GetAll(); var where = FilterExpression.FindByGroup <Rentsaleinfo>(dto.Filter); where = where.And(t => t.IsSale && t.IsShow); if (mode != 0) { where = where.And(t => t.RentsaleinfoTypeId == mode); } var count = await query.Where(where).CountAsync(); var list = await query.Where(where).OrderByDescending(t => t.CreationTime).PageBy(dto).ToListAsync(); var pageList = list.MapTo <List <RentsaleinfoListDto> >(); return(new PageListResultDto <RentsaleinfoListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <CommentListItem> > GetCommentList(int postId, GetPageListRequstDto dto) { var query = _forumCommentRepository.GetAll(); var where = FilterExpression.FindByGroup <ForumComment>(dto.Filter); var queryCount = query.Where(where) .GroupJoin(_memberRepository.GetAll(), left => left.MemberId, right => right.Id, (left, right) => new { PostComment = left, Member = right }); queryCount = queryCount.Where(t => t.PostComment.ForumPostId == postId); int count = await queryCount.CountAsync(); var queryList = query.Where(where).GroupJoin(_memberRepository.GetAll(), left => left.MemberId, right => right.Id, (left, right) => new { PostComment = left, Member = right }); queryList = queryList.Where(t => t.PostComment.ForumPostId == postId); var list = await queryList.OrderByDescending(t => t.PostComment.CreationTime).PageBy(dto).ToListAsync(); List <CommentListItem> comments = new List <CommentListItem>(); foreach (var comment in list) { comments.Add(new CommentListItem() { Id = comment.PostComment.Id, Images = new List <string>(), Content = comment.PostComment.Content, CreationTime = comment.PostComment.CreationTime, Floor = comment.PostComment.Floor, MemberName = comment.Member.FirstOrDefault()?.Name, MemberBindRooms = comment.Member.FirstOrDefault()?.BindRooms, MemberThumbnail = comment.Member.FirstOrDefault()?.Thumbnail }); } foreach (var comment in comments) { var iamges1 = await _forumImageRepository.GetAll() .Where(t => t.OwnerId == comment.Id && t.Type == ForumImageType.Comment) .OrderBy(t => t.Id) .ToListAsync(); foreach (var iamge in iamges1) { comment.Images.Add(iamge.Image); } } return(new PageListResultDto <CommentListItem>(count, comments, dto.CurrentPage, dto.PageSize)); }
public virtual async Task <PageListResultDto <ActivityListDto> > GetMyActivitys(string memberId, GetPageListRequstDto dto) { //获取用户参加的活动 var count = await _activityRepository.GetAll() .Join(_activityPersonRepository.GetAll(), left => left.Id, right => right.ActivityId, (left, right) => new { Activity = left, ActivityPerson = right }) .Where(t => t.ActivityPerson.MemberId == memberId).CountAsync(); var list = await _activityRepository.GetAll() .Join(_activityPersonRepository.GetAll(), left => left.Id, right => right.ActivityId, (left, right) => new { Activity = left, ActivityPerson = right }) .Where(t => t.ActivityPerson.MemberId == memberId) .OrderByDescending(t => t.Activity.Sort) .PageBy(dto) .ToListAsync(); var items = list.Select(t => t.Activity).MapTo <List <ActivityListDto> >(); PageListResultDto <ActivityListDto> result = new PageListResultDto <ActivityListDto>(count, items.ToArray(), dto.PageSize, dto.CurrentPage); return(result); }
public async Task <PageListResultDto <OrderListDto> > GetOrders(GetPageListRequstDto dto) { var query = _orderRepository.GetAll(); var where = FilterExpression.FindByGroup <Order>(dto.Filter); var queryCount = query.Where(where) .GroupJoin(_orderProductRepository.GetAll(), left => left.Id, right => right.OrderId, (left, right) => new { Order = left, OrderProduct = right }) .GroupJoin(_memberRepository.GetAll(), left => left.Order.MemberId, right => right.Id, (left, right) => new { Order = left.Order, OrderProduct = left.OrderProduct, Member = right }); int count = await queryCount.CountAsync(); var queryList = query.Where(where) .GroupJoin(_orderProductRepository.GetAll(), left => left.Id, right => right.OrderId, (left, right) => new { Order = left, OrderProduct = right }).GroupJoin(_memberRepository.GetAll(), left => left.Order.MemberId, right => right.Id, (left, right) => new { Order = left.Order, OrderProduct = left.OrderProduct, Member = right }); var tts = await queryList.OrderByDescending(t => t.Order.CreationTime).PageBy(dto).ToListAsync(); var pageList = new List <OrderListDto>(); foreach (var tt in tts) { pageList.Add(new OrderListDto() { Id = tt.Order.Id, Amount = tt.Order.Amount, GrouponStatus = tt.Order.GrouponStatus, OrderId = tt.Order.Id, ProductName = tt.OrderProduct.FirstOrDefault()?.Name, Status = tt.Order.Status, Type = tt.Order.Type, Thumbnail = tt.OrderProduct.FirstOrDefault()?.Thumbnail, OrderNo = tt.Order.OrderNo, Address = tt.Order.Address, Contact = tt.Order.Contact, Mobile = tt.Order.Mobile, CreationTime = tt.Order.CreationTime, MemberName = tt.Member.FirstOrDefault()?.Name, RefundStatus = tt.Order.RefundStatus }); } return(new PageListResultDto <OrderListDto>(count, pageList, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <PostListItem> > GetMyCommentList(long memberId, GetPageListRequstDto dto) { var query = _forumPostRepository.GetAll(); var where = FilterExpression.FindByGroup <ForumPost>(dto.Filter); var queryCount = query.Where(where) .GroupJoin(_memberRepository.GetAll(), left => left.MemberId, right => right.Id, (left, right) => new { Posts = left, Member = right }) .GroupJoin(_plateRepository.GetAll(), left => left.Posts.PlateId, right => right.Id, (left, right) => new { Posts = left.Posts, Member = left.Member, Plate = right }) .Join(_forumCommentRepository.GetAll(), left => left.Posts.Id, right => right.ForumPostId, (left, right) => new { Posts = left.Posts, Member = left.Member, Plate = left.Plate, Comments = right }); queryCount = queryCount.Where(t => t.Comments.MemberId == memberId); int count = await queryCount.CountAsync(); var queryList = query.Where(where) .GroupJoin(_memberRepository.GetAll(), left => left.MemberId, right => right.Id, (left, right) => new { Posts = left, Member = right }) .GroupJoin(_plateRepository.GetAll(), left => left.Posts.PlateId, right => right.Id, (left, right) => new { Posts = left.Posts, Member = left.Member, Plate = right }).Join(_forumCommentRepository.GetAll(), left => left.Posts.Id, right => right.ForumPostId, (left, right) => new { Posts = left.Posts, Member = left.Member, Plate = left.Plate, Comments = right }); queryList = queryList.Where(t => t.Comments.MemberId == memberId); var list = await queryList.OrderByDescending(t => t.Posts.LastCommentTime).PageBy(dto).ToListAsync(); var posts = new List <PostListItem>(); foreach (var item in list) { if (posts.Any(t => t.Id == item.Posts.Id)) { continue; } posts.Add(new PostListItem() { Id = item.Posts.Id, CommentCount = item.Posts.CommentCount, CreationTime = item.Posts.CreationTime, MemberBindRooms = item.Member.FirstOrDefault()?.BindRooms, MemberName = item.Member.FirstOrDefault()?.Name, MemberThumbnail = item.Member.FirstOrDefault()?.Thumbnail, Images = new List <string>(), PlateName = item.Plate.FirstOrDefault()?.Name, ReadCount = item.Posts.ReadCount, Title = item.Posts.Title, Summary = item.Posts.Summary }); } //var posts = list.Select(item => new PostListItem() //{ // Id = item.Posts.Id, // CommentCount = item.Posts.CommentCount, // CreationTime = item.Posts.CreationTime, // MemberBindRooms = item.Member.FirstOrDefault()?.BindRooms, // MemberName = item.Member.FirstOrDefault()?.Name, // MemberThumbnail = item.Member.FirstOrDefault()?.Thumbnail, // Images = new List<string>(), // PlateName = item.Plate.FirstOrDefault()?.Name, // ReadCount = item.Posts.ReadCount, // Title = item.Posts.Title, // Summary = item.Posts.Summary //}).ToList(); foreach (var post in posts) { var iamges = await _forumImageRepository.GetAll() .Where(t => t.OwnerId == post.Id && t.Type == ForumImageType.Posts) .OrderBy(t => t.Id) .Take(3) .ToListAsync(); foreach (var iamge in iamges) { post.Images.Add(iamge.Image); } } return(new PageListResultDto <PostListItem>(count, posts, dto.CurrentPage, dto.PageSize)); }
public async Task <PageListResultDto <ProductCommentListDto> > GetProductComments(GetPageListRequstDto dto) { var query = _productCommentRepository.GetAll(); var where = FilterExpression.FindByGroup <ProductComment>(dto.Filter); var queryCount = query.Where(where) .GroupJoin(_memberRepository.GetAll(), left => left.MemberId, right => right.Id, (left, right) => new { ProductComment = left, Member = right }) .GroupJoin(_productRepository.GetAll(), left => left.ProductComment.ProductId, right => right.Id, (left, right) => new { ProductComment = left.ProductComment, Member = left.Member, Product = right }); int count = await queryCount.CountAsync(); var queryList = query.Where(where) .GroupJoin(_memberRepository.GetAll(), left => left.MemberId, right => right.Id, (left, right) => new { ProductComment = left, Member = right }) .GroupJoin(_productRepository.GetAll(), left => left.ProductComment.ProductId, right => right.Id, (left, right) => new { ProductComment = left.ProductComment, Member = left.Member, Product = right }); var comments = await queryList.OrderByDescending(t => t.ProductComment.CreationTime).PageBy(dto).ToListAsync(); List <ProductCommentListDto> Comments = comments.Select(comment => new ProductCommentListDto() { Id = comment.ProductComment.Id, ProductName = comment.Product.FirstOrDefault()?.Name, MemberName = comment.Member.FirstOrDefault()?.Name, Content = comment.ProductComment.Content, CreationTime = comment.ProductComment.CreationTime }).ToList(); return(new PageListResultDto <ProductCommentListDto>(count, Comments, dto.CurrentPage, dto.PageSize)); }