public async Task <ActionResult <PagedList <DtoClient> > > GetAll([FromQuery] DtoFilterPagedList pagedListParams)
        {
            PagedList <DtoClient> listUsers = await _clientService.GetAllClients(pagedListParams);

            if (listUsers == null || !listUsers.Any())
            {
                return(NotFound());
            }

            return(Ok(listUsers));
        }
Exemplo n.º 2
0
        public async Task <Response <PagedList <OrderResource> > > Handle(GetCurrentUserOrdersQuery request, CancellationToken cancellationToken)
        {
            PagedList <Order> pagedOrder = await orderRepo.GetOrderPerPageAsync(request as OrderPaginationParams);

            if (pagedOrder.Any())
            {
                PagedList <OrderResource> poagedOrderResource = pagedConvertor.orderPagedToResource(pagedOrder);
                return(Response.Ok <PagedList <OrderResource> >(poagedOrderResource));
            }
            return(Response.Fail <PagedList <OrderResource> >("سفارشی یافت نشد", StatusCodeEnum.NOTFUOUND));
        }
Exemplo n.º 3
0
        public async Task <Response <PagedList <CommentResource> > > Handle(GetCurrentUserCommentsQuery request, CancellationToken cancellationToken)
        {
            PagedList <Comment> pagedComment = await commentRepo.GetCommentPerPage(request as CommentPaginationParams);

            if (pagedComment.Any())
            {
                PagedList <CommentResource> pagedCommentResource = pagedConvertor.CommentPagedToResource(pagedComment);
                return(Response.Ok <PagedList <CommentResource> >(pagedCommentResource));
            }
            return(Response.Fail <PagedList <CommentResource> >("هیچ کامنتی وجود ندارد", StatusCodeEnum.NOTFUOUND));
        }
        public async Task <Response <PagedList <BookResource> > > Handle(GetBooksPerPageQuery request, CancellationToken cancellationToken)
        {
            PagedList <Book> pagedBook = await bookRepo.GetBooksPerPage(request as BookPaginationParams);

            if (pagedBook.Any())
            {
                PagedList <BookResource> pagedBookResource = pagedConvertor.bookPagedToResource(pagedBook);
                return(Response.Ok <PagedList <BookResource> >(pagedBookResource));
            }
            else
            {
                return(Response.Fail <PagedList <BookResource> >("هیچ کتابی با این مشخصات وجود ندارد", StatusCodeEnum.NOTFUOUND));
            }
        }
        public HttpResponseMessage GetGroupList(TechnicianApiViewModel data)
        {
            try
            {
                var user = ((PtcIdentity)this.User.Identity).currentUser;

                var con = new Conditions <DataBase.TTechnicianGroup>(data.pageSize, data.page);

                con.Include(x => x.TTechnicianGroupClaims
                            .Select(y => y.TVenderTechnician));

                con.And(x => x.VendorCd == user.VenderCd &&
                        x.CompCd == user.CompCd);


                if (!string.IsNullOrEmpty(data.keyword))
                {
                    con.And(x => x.GroupName.Contains(data.keyword));
                }

                PagedList <TtechnicianGroup> list = _technicianGroupRepo.GetList(con);

                if (!list.Any())
                {
                    return(Request.CreateResponse(
                               HttpStatusCode.OK, new JsonResult <List <TechnicianGPResultApiViewModel> >()
                    {
                        isSuccess = true,
                        element = new List <TechnicianGPResultApiViewModel>(),
                        message = "無資料",
                        totalCount = 0,
                    }));
                }


                IEnumerable <TechnicianGPResultApiViewModel> result = list.Select(x => new TechnicianGPResultApiViewModel(x));

                return(Request.CreateResponse(
                           HttpStatusCode.OK,
                           new JsonResult <IEnumerable <TechnicianGPResultApiViewModel> >(result, "[廠商]廠商技師群組查詢成功", con.TotalCount, true)));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                   $"{ ex.GetType().Name}:Message:{ex.Message}"));
            }
        }
 static void AssertCheckResults(PagedList <User> users, UserParams userParams, bool useExpectedCount = false, int expectedCount = 0)
 {
     Console.WriteLine();
     Console.WriteLine($"Test Number: {++TestCount}");
     foreach (var user in users)
     {
         Console.WriteLine($"user.Id: {user.Id}");
     }
     if (useExpectedCount) // use expected count if there is a likee/liker filter
     {
         Console.WriteLine($"users.Count: {users.Count}, expectedCount: {expectedCount}");
         Assert.IsTrue(users.Count == expectedCount); // should be x users found based on parameters
     }
     else
     {
         Console.WriteLine($"users.Count: {users.Count}, userParams.PageSize: {userParams.PageSize}");
         Assert.IsTrue(users.Count == userParams.PageSize);     // should be x users found based on parameters
     }
     Assert.IsFalse(users.Any(u => u.Id == userParams.UserId)); // should not include self in results
 }
Exemplo n.º 7
0
        private void FetchAndIncludeReplies(CommentDbContext dbContext, PagedList <Comment> parentComments, CommentSearchCondition commentSearchCondition, bool fetchCountOnly)
        {
            if (parentComments == null || !parentComments.Any())
            {
                return;
            }
            var parentCommentIds = parentComments.Select(x => x.Id).ToArray();
            var childComments    = dbContext.Comments.Where(x => parentCommentIds.Contains(x.ParentId));

            foreach (var parent in parentComments)
            {
                if (fetchCountOnly)
                {
                    parent.Replies = childComments.Where(child => child.ParentId == parent.Id).OrderByDescending(p => p.CreatedOn).ToPagedList(true);
                }
                else
                {
                    parent.Replies = childComments.Where(child => child.ParentId == parent.Id).OrderByDescending(p => p.CreatedOn).ToPagedList(commentSearchCondition.PageNumber, commentSearchCondition.PageSize);
                    FetchAndIncludeReplies(dbContext, parent.Replies, commentSearchCondition, true);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 二手房的联络列表
        /// </summary>
        /// <param name="queryDto"></param>
        /// <returns></returns>
        public ContactByResaleHouseDto SearchByResaleHouseId(ContactByResaleHouseQueryDto queryDto)
        {
            var userQuery = db.GetUserQuery();
            var query     = from contact in db.MlsContactRecordLogQuery
                            join user in userQuery on contact.UserId equals user.UserId
                            where contact.ResourcesId == queryDto.HouseId && contact.Type == (int)EnumHosueCommonType.ResaleHouse
                            orderby contact.CreateTime descending
                            select new ResaleHouseContactListDto
            {
                UserInfo      = user,
                OperationType = (ContactEnum)contact.OperationType,
                CreateTime    = contact.CreateTime,
                //HowTimes = 10,
                Id = contact.Id
            };
            PagedList <ResaleHouseContactListDto> list = query.GetPagedList(queryDto.PageIndex, queryDto.PageSize);

            if (list.Any())
            {
                var sqlList = new List <string>();
                foreach (var item in list)
                {
                    sqlList.Add($"SELECT CONVERT(bigint,{item.Id}) AS ID ,COUNT(0) AS Value,NULL AS Code FROM  MlsContactRecordLog WHERE Id<={item.Id} AND UserId={item.UserInfo.UserId} AND OperationType={(int)item.OperationType}");
                }
                var sql = string.Join(" UNION ALL ", sqlList);
                foreach (var item in this.db.IDValueDto.FromSqlRaw(sql))
                {
                    list.Where(c => c.Id == (int)item.ID).First().HowTimes = item.Value;
                }
            }

            var data = new PagedList <ResaleHouseContactListDto>(list.CurrentPageIndex, list.PageSize, list.TotalItemCount);

            data.AddRange(list);

            var res = new ContactByResaleHouseDto()
            {
                ContactPage = data
            };

            res.HouseInfo = (from housenew in db.ChineseHouseNewQuery
                             join communities in db.ChineseCommunitiesQuery on housenew.CommunityId equals communities.Id
                             where housenew.Id == queryDto.HouseId
                             select new HouseByContactDto
            {
                Id = housenew.Id,
                Areas = housenew.Areas,
                RentPrice = housenew.RentPrice,
                TotalPrice = housenew.TotalPrice,
                ResaleHouseCommodityType = (EnumResaleHouseCommodityType)housenew.HouseSource,
                CommissionPartnerType = housenew.CommissionPartnerType.GetValueOrDefault(0),
                CommissionPartner = housenew.CommissionPartner.GetValueOrDefault(0),
                CommissionPartnerPercent = housenew.CommissionPartnerPercent.GetValueOrDefault(0),
                BedRoomsCount = housenew.BedRoomsCount.GetValueOrDefault(0),
                BathRoomsCount = housenew.BathRoomsCount.GetValueOrDefault(0),
                MainPhotoUrl = housenew.MainPhoto,
                CommunityName = housenew.CommunityName,
                AreaName = communities.AreaName,
                CityName = communities.CityName,
                IsMls = housenew.ShareToFdb == 2
            }).First();
            return(res);
        }
Exemplo n.º 9
0
        private void FetchAndIncludeReplies(CommentDbContext dbContext, PagedList<Comment> parentComments, CommentSearchCondition commentSearchCondition, bool fetchCountOnly)
        {
            if (parentComments == null || !parentComments.Any()) return;
            var parentCommentIds = parentComments.Select(x => x.Id).ToArray();
            var childComments = dbContext.Comments.Where(x => parentCommentIds.Contains(x.ParentId));

            foreach (var parent in parentComments)
            {
                if (fetchCountOnly)
                {
                    parent.Replies = childComments.Where(child => child.ParentId == parent.Id).OrderByDescending(p => p.CreatedOn).ToPagedList(true);
                }
                else
                {
                    parent.Replies = childComments.Where(child => child.ParentId == parent.Id).OrderByDescending(p => p.CreatedOn).ToPagedList(commentSearchCondition.PageNumber, commentSearchCondition.PageSize);
                    FetchAndIncludeReplies(dbContext, parent.Replies, commentSearchCondition, true);
                }
            }
        }
Exemplo n.º 10
0
        public static IHtmlString BuildFormTable(this HtmlHelper htmlHelper, PagedList <SQLDynamicRow> sQLDynamicRow, int page, string code)
        {
            if (!sQLDynamicRow.Any())
            {
                return(htmlHelper.BuildByKey("formEmpty"));
            }

            var dynamicDataservices = Common.Injection.Core.IoC.Container.Resolve <IDynamicDataservices>();
            var field = dynamicDataservices.GetDyncFieldByFormCode(code);

            var row  = sQLDynamicRow.FirstOrDefault().Row.ToList();
            var head = new List <string>();

            for (int i = 0; i < row.Count(); i++)
            {
                if (row[i].Name == "Id")
                {
                    continue;
                }

                var item = field.Where(t => t.Name == row[i].Name).FirstOrDefault();
                if (item.IsNull())
                {
                    continue;
                }

                head.Add(item.Lbl);
            }

            var tuple = new List <Tuple <IList <string>, Func <string> > >();

            for (int i = 0; i < sQLDynamicRow.Count; i++)
            {
                var content = new List <string>();
                var item    = sQLDynamicRow[i].Row.ToList();
                var id      = string.Empty;
                for (int j = 0; j < item.Count(); j++)
                {
                    if (item[j].Name == "Id")
                    {
                        id = item[j].Value;
                        continue;
                    }

                    var v = field.Where(t => t.Name == item[j].Name).FirstOrDefault();
                    if (v.IsNull())
                    {
                        continue;
                    }

                    if (v.SourceValue.IsNotNullOrEmpty() && (v.Type == "radio" || v.Type == "checkbox"))
                    {
                        content.Add(GetLabel(v, item[j]));
                    }
                    else
                    {
                        content.Add(item[j].Value);
                    }
                }
                tuple.Add(new Tuple <IList <string>, Func <string> >(content, () =>
                {
                    return(FormTemp.GetTempByKey("formInfoLink", id, code, page.ToString()));
                }));
            }

            return(htmlHelper.BuildByTable(new Tuple <IList <string>, IList <Tuple <IList <string>, Func <string> > >, bool>(head,
                                                                                                                             tuple, true)));
        }