Пример #1
0
        public List <Movie> GetAll(string userID = "", string query = "", int numToTake = 0, int?pageNum = 1)
        {
            var movieList = _getEntityListComponent.Execute(_repository).OrderBy(x => x.Title).ToList();

            if (!string.IsNullOrWhiteSpace(userID))
            {
                movieList = movieList.Where(x => x.UserID == userID).ToList();
            }

            if (!string.IsNullOrWhiteSpace(query))
            {
                var currentList = new List <Movie>();
                currentList.AddRange(movieList);
                movieList = currentList.Where(x =>
                                              x.Title.Equals(query, StringComparison.InvariantCultureIgnoreCase) ||
                                              x.Director.Equals(query, StringComparison.InvariantCultureIgnoreCase)).ToList();
                var partialMatches = currentList.Where(x => x.Title.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) != -1 || x.Director.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) != -1).ToList();
                movieList = movieList.Concat(partialMatches).Distinct().ToList();
            }

            if (numToTake > 0)
            {
                movieList = movieList.Skip(numToTake * (pageNum.GetValueOrDefault() - 1)).Take(numToTake).ToList();
            }

            return(movieList);
        }
Пример #2
0
        public List <Album> GetAll(string userID = "", string query = "", int numToTake = 0, int?pageNum = 1
                                   /*bool sortAscending, string sortPreference*/)
        {
            var albumList = new List <Album>();

            albumList = _getEntityListComponent.Execute(_repository).OrderBy(x => x.Artist).ThenBy(y => y.Title).ToList();

            if (!string.IsNullOrWhiteSpace(userID))
            {
                albumList = albumList.Where(x => x.UserID == userID).ToList();
            }

            if (!string.IsNullOrWhiteSpace(query))
            {
                var currentList = new List <Album>();
                currentList.AddRange(albumList);
                albumList = currentList.Where(x =>
                                              x.Artist.Equals(query, StringComparison.InvariantCultureIgnoreCase) ||
                                              x.Title.Equals(query, StringComparison.InvariantCultureIgnoreCase)).ToList();
                var partialMatches =
                    currentList.Where(
                        x =>
                        x.Artist.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                        x.Title.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) != -1).ToList();
                albumList = albumList.Concat(partialMatches).Distinct().ToList();
            }

            if (numToTake > 0)
            {
                albumList = albumList.Skip(numToTake * (pageNum.GetValueOrDefault() - 1)).Take(numToTake).ToList();
            }
            //if (sortPreference == "Name")
            //{
            //    if (sortAscending)
            //        cardList = cardList.OrderBy(x => x.Name).ToList();
            //    else
            //        cardList = cardList.OrderByDescending(x => x.Name).ToList();
            //}
            //else if (sortPreference == "Rank")
            //{
            //    if (sortAscending)
            //        cardList = cardList.OrderBy(x => x.Rank).ToList();
            //    else
            //        cardList = cardList.OrderByDescending(x => x.Rank).ToList();
            //}

            return(albumList);
        }
Пример #3
0
        public List <Wish> GetAll(string userID = "", string query = "", int numToTake = 0, int?pageNum = 1)
        {
            var num      = _user.UserNum;
            var wishList = _getEntityListComponent.Execute(_repository).OrderBy(x => x.Title).AsQueryable();

            if (!string.IsNullOrWhiteSpace(userID))
            {
                wishList = wishList.Where(x => x.UserID == userID);
            }

            if (!string.IsNullOrWhiteSpace(query))
            {
                var currentList = new List <Wish>();
                currentList.AddRange(wishList);

                wishList = currentList.Where(x => x.Title.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) != -1).AsQueryable();
            }
            if (numToTake > 0)
            {
                wishList = wishList.Skip(numToTake * (pageNum.GetValueOrDefault() - 1)).Take(numToTake);
            }

            return(wishList.ToList());
        }
Пример #4
0
        public List <FunkoPop> GetAll(string userID = "", string query = "", int numToTake = 0, int?pageNum = 1)
        {
            var pops = _getEntityListComponent.Execute(_repository).OrderBy(x => x.Title).ThenBy(y => y.Series).ThenBy(z => z.Number).AsQueryable();

            if (!string.IsNullOrWhiteSpace(userID))
            {
                pops = pops.Where(x => x.UserID == userID);
            }

            if (!string.IsNullOrWhiteSpace(query))
            {
                var currentList = new List <FunkoPop>();
                currentList.AddRange(pops);

                pops = currentList.Where(x => x.Title.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) != -1).AsQueryable();
            }

            if (numToTake > 0)
            {
                pops = pops.Skip(numToTake * (pageNum.GetValueOrDefault() - 1)).Take(numToTake);
            }

            return(pops.ToList());
        }
Пример #5
0
 public List <TestObj> GetAll() => _getEntityListComponent.Execute(_repo).ToList();