Beispiel #1
0
        public async Task <List <PostMiniDto> > GetPostsMiniAsync()
        {
            List <PostMiniDto> list = new List <PostMiniDto>();
            await Context1.Find(post => true).SortByDescending(post => post.Date).ForEachAsync(post => list.Add(new PostMiniDto()
            {
                Date        = post.Date,
                Title       = post.Title,
                Tags        = post.Tags,
                Views       = post.Views,
                Comments    = post.Comments.HierarchyCount(),
                Likes       = post.Likes.LongCount(),
                Descreption = post.Descreption,
                Id          = post.Id
            }));

            return(list);


            return(await Context1.AsQueryable().Select(post => new PostMiniDto()
            {
                Date = post.Date,
                Title = post.Title,
                Tags = post.Tags,
                Views = post.Views,
                Comments = post.Comments.HierarchyCount(),
                Likes = post.Likes.LongCount(),
                Descreption = post.Descreption,
                Id = post.Id
            }).ToListAsync());
        }
Beispiel #2
0
        public async Task <List <PostDto> > GetPostsSearchAsync(string text)
        {
            List <PostDto> list = new List <PostDto>();

            var AllPost = await Context1.AsQueryable().ToListAsync();

            var  QueryTuple = AllPost.Select(x => (x.Id, x.Descreption ?? "")).ToList();
            var  Ids        = JolijoberExtensions.FuzzySearchLinq(text, QueryTuple, 0.7).Select(x => x.Item1);
            bool ifff       = Ids.Any();

            list = AllPost.Where(x => ifff?Ids.Contains(x.Id): x.Descreption?.Contains(text) ?? false).OrderByDescending(post => post.Date).Select(post => new PostDto()
            {
                Id             = post.Id,
                Date           = post.Date,
                Title          = post.Title,
                Tags           = post.Tags,
                Views          = post.Views,
                AccountId      = post.AccountId,
                PostType       = post.PostType,
                AccountName    = post.AccountName,
                AccountType    = post.AccountType,
                Availabilty    = post.Availabilty,
                Categories     = post.Categories,
                Comments       = post.Comments,
                Descreption    = post.Descreption,
                Hours          = post.Hours,
                KindPay        = post.KindPay,
                Likes          = post.Likes,
                Region         = post.Region,
                Sallaries      = post.Sallaries,
                Skills         = post.Skills,
                Specifications = post.Specifications
            }).ToList();
            return(list);
        }