Exemplo n.º 1
0
        private IEnumerable <ThreadModel> GetThreads(List <string> keywords, string searchOptions, string sortingOptions)
        {
            var threads = _threadService.GetAll().Where(thread => thread.AlbumId == 1).Where(thread => thread.Flagged == false);

            if (searchOptions.Equals("Keywords"))
            {
                foreach (var keyword in keywords) //Performs one step lookup further into the search. If the next keyword lookup produces an empty result, then skip it
                {
                    var oneStepLookup = threads.Where(thread => StringContains(thread.Title, keyword) || StringContains(thread.Description, keyword));
                    if (oneStepLookup.FirstOrDefault() != null)
                    {
                        threads = oneStepLookup;
                    }
                }
            }
            else if (searchOptions.Equals("Tags"))
            {
                var tags = _channelService.GetAllTags();
                foreach (var keyword in keywords)
                {
                    var oneStepLookup = tags
                                        .Where(tag => StringContains(tag.Name, keyword))
                                        .Where(tag => tag.ThreadId != 0);
                    if (oneStepLookup.FirstOrDefault() != null)
                    {
                        tags = oneStepLookup;
                    }
                }
                if (tags.Select(tag => _threadService.GetById(tag.ThreadId)).FirstOrDefault() != null)
                {
                    threads = tags.Select(tag => _threadService.GetById(tag.ThreadId)).Distinct();
                }
            }
            if (sortingOptions.Equals("Votes"))
            {
                threads = threads.OrderByDescending(thread => thread.Votes);
            }
            else
            {
                threads = threads.OrderByDescending(thread => thread.CreateDate);
            }
            return(threads.Select(thread => new ThreadModel
            {
                Id = thread.ID,
                Title = thread.Title,
                Rating = thread.Votes,
                Description = thread.Description,
                Picture = thread.Image,
                Created = thread.CreateDate
            }));
        }
Exemplo n.º 2
0
        public IActionResult Reported()
        {
            var threadModel = _service.GetAll().Select(threads => new ThreadModel
            {
                Id             = threads.ID,
                Title          = threads.Title,
                Created        = threads.CreateDate,
                Description    = threads.Description,
                Rating         = threads.Votes,
                AuthorUserName = threads.UserName,
                NoReports      = threads.NoReports
            })
                              .Where(x => x.NoReports >= 1)
                              .OrderByDescending(x => x.NoReports)
                              .ToList();

            var threadList = new ThreadList {
                ThreadLists = threadModel
            };

            return(View(threadList));
        }
Exemplo n.º 3
0
        public IActionResult Index()
        {
            var threadModel = _threadService.GetAll()
                              .Where(threads => threads.AlbumId == 1)
                              .Select(threads => new ThreadModel
            {
                Title          = threads.Title,
                Rating         = threads.Votes,
                Description    = threads.Description,
                Created        = threads.CreateDate,
                Picture        = threads.Image,
                Id             = threads.ID,
                AuthorUserName = threads.UserName,
                Flagged        = threads.Flagged
            });

            var threadList = new ThreadList {
                ThreadLists = threadModel
            };

            return(View(threadList));
        }