public IActionResult Index(string sortOrder, string searchString, string currentFilter, int?page)
        {
            ViewData["NameSortParm"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            ProductTypeViewModel model = new ProductTypeViewModel()
            {
                // Cheeses = CheeseData.GetAll()
                ListProductTypes = _database.Find(s => s.IsDeleted == false).ToList()
            };

            if (!string.IsNullOrEmpty(searchString))
            {
                model.ListProductTypes = model.ListProductTypes.Where(s => s.ProductTypeName.ToLower().Contains(searchString.ToLower())).ToList();
            }
            switch (sortOrder)
            {
            case "name_desc":
                model.ListProductTypes = model.ListProductTypes.OrderByDescending(s => s.ProductTypeName).ToList();
                break;
            }
            int pageSize = 5;

            return(View(PaginatedProductList <ProductType> .Create(model.ListProductTypes.AsQueryable(), page ?? 1, pageSize)));
        }
Ejemplo n.º 2
0
        public IActionResult Add(string mess)
        {
            Product loaiSachVMD = new Product();

            ViewData["TheLoaiSach"] = new SelectList(_proTypeDatabase.Find(s => s.IsDeleted == false).ToList(), "ProductTypeID", "ProductTypeName");
            ViewBag.noti            = mess;
            return(View(loaiSachVMD));
        }
Ejemplo n.º 3
0
        //
        // GET: /ProductTypes/Details/5

        public ViewResult Details(System.Guid id)
        {
            return(View(producttypeRepository.Find(id)));
        }