Exemplo n.º 1
0
        public IEnumerable <IFound> Search(SearchArguments searchArguments)
        {
            var result = new List <UserFound>();

            IEnumerable <string> searchWords = searchArguments.SearchQuery.SplitSearchString();

            using (IUnitOfWork unitOfWork = WorkFactory.GetUnitOfWork())
            {
                if (searchArguments.IsSearchUsersByName)
                {
                    IEnumerable <UserFound> found = SearchByCondition(searchWords,
                                                                      model =>
                                                                      searchWords.Any(
                                                                          searchWord =>
                                                                          model.FirstName.Contains(searchWord) || model.LastName.Contains(searchWord)),
                                                                      GetRelevanceByName, unitOfWork);

                    result.AddRange(found);
                }

                if (searchArguments.IsSearchUserByDepartment)
                {
                    IEnumerable <UserFound> found = SearchByCondition(searchWords,
                                                                      model => searchWords.Any(searchWord => model.Department.Contains(searchWord)),
                                                                      GetRelevanceByDepartment,
                                                                      unitOfWork);

                    result.AddRange(found);
                }
            }

            return(Group(result));
        }
Exemplo n.º 2
0
        public IEnumerable <IFound> Search(SearchArguments searchArguments)
        {
            var result = new List <PhotoFound>();

            IEnumerable <string> searchWords = searchArguments.SearchQuery.SplitSearchString();

            using (IUnitOfWork unitOfWork = WorkFactory.GetUnitOfWork())
            {
                IEnumerable <AlbumModel> avialableAlbums = _secureService.GetAvailableAlbums(searchArguments.UserId,
                                                                                             unitOfWork);

                if (searchArguments.IsSearchPhotosByDescription)
                {
                    IEnumerable <PhotoFound> found = SearchByDescription(avialableAlbums, searchWords);

                    result.AddRange(found);
                }

                if (searchArguments.IsSearchPhotosByTags)
                {
                    IEnumerable <PhotoFound> found = SearchByTags(avialableAlbums, searchWords);

                    result.AddRange(found);
                }
            }

            return(Group(result));
        }
Exemplo n.º 3
0
        public IEnumerable <IFound> Search(SearchArguments searchArguments)
        {
            IEnumerable <string> searchWords = searchArguments.SearchQuery.SplitSearchString();

            using (IUnitOfWork unitOfWork = WorkFactory.GetUnitOfWork())
            {
                IEnumerable <AlbumModel> avialableAlbums = secureService.GetAvailableAlbums(searchArguments.UserId,
                                                                                            unitOfWork);

                return(Group(SearchByText(avialableAlbums, searchWords)));
            }
        }
Exemplo n.º 4
0
        public SearchResult Search(SearchArguments searchArguments)
        {
            var result = new List <IFound>();

            string resultToken = searchArguments.SearchCacheToken;

            if (searchCacheTask.ContainsToken(resultToken))
            {
                SearchCache searchCache = searchCacheTask.GetCache(resultToken);

                result.AddRange(searchCache.Value);
            }
            else
            {
                if (searchArguments.IsSearchByPhotos)
                {
                    result.AddRange(photoSearchService.Search(searchArguments));
                }

                if (searchArguments.IsSearchByUsers)
                {
                    result.AddRange(userSearchService.Search(searchArguments));
                }

                if (searchArguments.IsSearchByAlbums)
                {
                    result.AddRange(albumSearchService.Search(searchArguments));
                }

                if (searchArguments.IsSearchByComments)
                {
                    result.AddRange(commentSearchService.Search(searchArguments));
                }

                result = result.OrderByDescending(found => found.Relevance).ToList();

                resultToken = searchCacheTask.AddCache(result);
            }

            return(new SearchResult
            {
                Value = result.Skip(searchArguments.Skip).Take(searchArguments.Take),
                SearchCacheToken = resultToken
            });
        }
Exemplo n.º 5
0
        public IEnumerable <IFound> Search(SearchArguments searchArguments)
        {
            var result = new List <AlbumFound>();

            IEnumerable <string> searchWords = searchArguments.SearchQuery.SplitSearchString();

            using (IUnitOfWork unitOfWork = WorkFactory.GetUnitOfWork())
            {
                IEnumerable <AlbumModel> avialableAlbums = secureService.GetAvailableAlbums(searchArguments.UserId,
                                                                                            unitOfWork);

                if (searchArguments.IsSearchAlbumsByName)
                {
                    IEnumerable <AlbumFound> found = SearchByCondition(searchWords, avialableAlbums,
                                                                       model => searchWords.Any(searchWord => model.Name.Contains(searchWord)),
                                                                       CalculateRelevanceByName);

                    result.AddRange(found);
                }

                if (searchArguments.IsSearchAlbumsByDescription)
                {
                    IEnumerable <AlbumFound> found = SearchByCondition(searchWords, avialableAlbums,
                                                                       model => searchWords.Any(searchWord => model.Description.Contains(searchWord)),
                                                                       CalculateRelevaceByDescription);

                    result.AddRange(found);
                }

                if (searchArguments.IsSearchAlbumsByTags)
                {
                    IEnumerable <AlbumFound> found = SearchByTags(avialableAlbums, searchWords);

                    result.AddRange(found);
                }
            }

            return(Group(result));
        }