public ViewResult TwoInOne(int productPage = 1, string sortOrder = "", FilterViewModel model = null)
        {
            ProductListViewModel productList = FillProductListViewModelByCategoryId(3, productPage);


            if (!string.IsNullOrEmpty(model.SelectedVendor) || !string.IsNullOrEmpty(model.SelectedMemory) || !string.IsNullOrEmpty(model.SelectedProcessor))
            {
                productList.Products = _productService.GetProductsByCategoryId(3);
                productList          = FilterLogic.FilterByModel(productList, model);
            }
            productList.PagingInfo.TotalItems = productList.Products.Count();

            ViewBag.OrderStatus = "En İyi Eşleşme";

            switch (sortOrder)
            {
            case "best_match":
                productList.Products = _productService.GetProductsByCategoryId(3).OrderByDescending(P => P.CreatedDate);
                ViewBag.OrderStatus  = "En İyi Eşleşme";
                break;

            case "desc_price":
                productList.Products = _productService.GetProductsByCategoryId(3).OrderByDescending(p => p.UnitPrice);
                ViewBag.OrderStatus  = "Fiyat: Azalan";
                break;

            case "asc_price":
                productList.Products = _productService.GetProductsByCategoryId(3).OrderBy(p => p.UnitPrice);
                ViewBag.OrderStatus  = "Fiyat: Artan";
                break;
            }

            return(View(productList));
        }
Beispiel #2
0
        public IActionResult Index(int productPage = 1, string sortOrder = "", FilterViewModel model = null)
        {
            ProductListViewModel productList = new ProductListViewModel()
            {
                Products =
                    _productService.Products.OrderBy(p => p.Id).Skip((productPage - 1) * pageSize).Take(pageSize),
                PagingInfo = new PagingInfo()
                {
                    CurrentPage  = productPage,
                    ItemsPerPage = pageSize,
                    TotalItems   = _productService.Products.Count()
                },
                FilterTypes = new FilterViewModel()
                {
                    Vendors    = _productService.Products.Select(I => I.Vendor).Distinct().OrderBy(I => I).ToList(),
                    Memories   = _productService.Products.Select(I => I.MemoryCapacity).Distinct().OrderBy(I => I).ToList(),
                    Processors = _productService.Products.Select(I => I.ProcessorVendor).Distinct().OrderBy(I => I).ToList()
                }
            };


            if (!string.IsNullOrEmpty(model.SelectedVendor) || !string.IsNullOrEmpty(model.SelectedMemory) || !string.IsNullOrEmpty(model.SelectedProcessor))
            {
                productList.Products = _productService.Products;
                productList          = FilterLogic.FilterByModel(productList, model);
            }

            ViewBag.OrderStatus = "En İyi Eşleşme";

            switch (sortOrder)
            {
            case "best_match":
                productList.Products = productList.Products.OrderByDescending(P => P.CreatedDate);
                ViewBag.OrderStatus  = "En İyi Eşleşme";
                break;

            case "desc_price":
                productList.Products = productList.Products.OrderByDescending(p => p.UnitPrice);
                ViewBag.OrderStatus  = "Fiyat: Azalan";
                break;

            case "asc_price":
                productList.Products = productList.Products.OrderBy(p => p.UnitPrice);
                ViewBag.OrderStatus  = "Fiyat: Artan";
                break;
            }

            return(View(productList));
        }