Exemple #1
0
        // GET: Reviews
        public async Task <IActionResult> Index(string productName, string sellerName, string picture, string link, string productDescription, float price, string productId, int?pageNumber)
        {
            ViewBag.productName        = productName;
            ViewBag.sellerName         = sellerName;
            ViewBag.picture            = picture;
            ViewBag.link               = link;
            ViewBag.productDescription = productDescription;
            ViewBag.price              = price;
            ViewBag.productId          = productId;
            int pageSize      = 10;
            var paged_reviews = (await _context.Reviews.Where(r => r.ProductId == productId).ToListAsync()).OrderByDescending(r => r.Id);
            var totalReviews  = paged_reviews.Count();

            ViewBag.total_reviews = totalReviews;

            var product = _context.Products.FirstOrDefault(p => p.Id.Equals(productId));

            if (product != null)
            {
                ViewBag.average_rating = product.AverageRating;
            }

            ViewBag.keyword    = HttpContext.Session.GetString("keyword");
            ViewBag.reviewFrom = HttpContext.Session.GetString("reviewFrom");

            return(View(PaginatedList <Reviews> .CreatePage(paged_reviews, pageNumber ?? 1, pageSize)));
        }
Exemple #2
0
        public PaginatedList <PermissionEntity> GetList(int currentPage, int pageSize, Expression <Func <PermissionEntity, bool> > predicate)
        {
            var query = from o in _repository.GetAll()
                        join d in _menuRepository.GetAll()
                        on o.MenuId equals d.Id
                        select new PermissionEntity()
            {
                Id          = o.Id,
                Name        = o.Name,
                ActionCode  = o.ActionCode,
                MenuId      = o.MenuId,
                MenuName    = d.Name,
                CreatedTime = o.CreatedTime,
                Status      = o.Status
            };


            if (predicate != null)
            {
                query = query.Where(predicate);
            }
            var tt = PaginatedList <PermissionEntity> .CreatePage(query, currentPage, pageSize);

            //var result = _repository.FindListPage(currentPage, pageSize, _repository.GetAll());
            return(tt);
        }
Exemple #3
0
        // GET: Wishlists
        public async Task <IActionResult> Index(int?pageNumber)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            var user = await _userManager.GetUserAsync(User);

            var prj666_192a03Context = _context.Wishlists.Include(w => w.User)
                                       .Where(x => x.UserId == user.Id);
            List <Wishlists> items = new List <Wishlists>(await prj666_192a03Context.ToListAsync());
            int pageSize           = 5;

            List <int>    ratings = new List <int>();
            List <string> ids     = new List <string>();

            foreach (var item in items)
            {
                var product = _context.Products.FirstOrDefault(p => p.Id.Equals(item.ProductId));
                if (product != null)
                {
                    ratings.Add(product.AverageRating ?? 0);
                    ids.Add(item.ProductId);
                }
            }
            ViewBag.ratings = ratings;
            ViewBag.ids     = ids;
            HttpContext.Session.SetString("reviewFrom", "wishlist");

            return(View(PaginatedList <Wishlists> .CreatePage(items.OrderBy(p => p.Price), pageNumber ?? 1, pageSize)));
        }
        public async Task <IActionResult> ProductList(int?pageNumber, string sortOrder, string filter)
        {
            var items = HttpContext.Session.GetObject <List <Item> >("searchItems");

            int pageSize = 20;

            IOrderedEnumerable <Item> list      = null;
            IEnumerable <Item>        temp_list = items;

            if (filter == "Amazon")
            {
                temp_list = items.Where(i => i.soldBy == "Amazon");
            }
            else if (filter == "eBay")
            {
                temp_list = items.Where(i => i.soldBy == "eBay");
            }
            else if (filter == "1")
            {
                temp_list = items.Where(i => (int)Math.Round(i.CurrentPrice) < 100);
            }
            else if (filter == "2")
            {
                temp_list = items.Where(i => (int)Math.Round(i.CurrentPrice) >= 100 && (int)Math.Round(i.CurrentPrice) < 200);
            }
            else if (filter == "3")
            {
                temp_list = items.Where(i => (int)Math.Round(i.CurrentPrice) >= 200 && (int)Math.Round(i.CurrentPrice) < 400);
            }
            else if (filter == "4")
            {
                temp_list = items.Where(i => (int)Math.Round(i.CurrentPrice) >= 400 && (int)Math.Round(i.CurrentPrice) < 600);
            }
            else if (filter == "5")
            {
                temp_list = items.Where(i => (int)Math.Round(i.CurrentPrice) >= 600 && (int)Math.Round(i.CurrentPrice) < 800);
            }
            else if (filter == "6")
            {
                temp_list = items.Where(i => (int)Math.Round(i.CurrentPrice) >= 800 && (int)Math.Round(i.CurrentPrice) < 1000);
            }
            else if (filter == "7")
            {
                temp_list = items.Where(i => (int)Math.Round(i.CurrentPrice) >= 1000);
            }

            if (sortOrder == null)
            {
                list = temp_list.OrderBy(p => p.CurrentPrice);
            }
            else if (sortOrder == "price decrease")
            {
                list = temp_list.OrderByDescending(p => p.CurrentPrice);
            }
            else if (sortOrder == "name increase")
            {
                list = temp_list.OrderBy(p => p.Title);
            }
            else if (sortOrder == "name decrease")
            {
                list = temp_list.OrderByDescending(p => p.Title);
            }
            else if (sortOrder == "rating")
            {
                list = temp_list.OrderByDescending(p => p.averageRating);
            }

            ViewBag.currentSortOrder = sortOrder;
            ViewBag.currentFilter    = filter;
            ViewBag.keyword          = HttpContext.Session.GetString("keyword");
            HttpContext.Session.SetString("reviewFrom", "productList");

            return(View(PaginatedList <Item> .CreatePage(list, pageNumber ?? 1, pageSize)));
        }