示例#1
0
        public IActionResult Index(string sortOrder, string searchString, string currentFilter, int?page)
        {
            ViewBag.lisEmail         = _userProfileDatabase.Find(s => s.IsDeleted == false).ToList();
            ViewData["NameSortParm"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;

            BillListViewModel model = new BillListViewModel()
            {
                ListBill = _billDatabase.GetAll().ToList()
            };

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

            return(View(PaginatedProductList <Bill> .Create(model.ListBill.AsQueryable(), page ?? 1, pageSize)));
        }
        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)));
        }
        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;
            UserListViewModel model = new UserListViewModel()
            {
                ListUsers = _database.Find(s => s.IsDeleted == false).ToList()
            };

            if (!string.IsNullOrEmpty(searchString))
            {
                model.ListUsers = model.ListUsers.Where(s => s.UserName.ToLower().Contains(searchString.ToLower())).ToList();
            }
            switch (sortOrder)
            {
            case "name_desc":
                model.ListUsers = model.ListUsers.OrderByDescending(s => s.FullName).ToList();
                break;

            case "country_desc":
                model.ListUsers = model.ListUsers.OrderByDescending(s => s.Email).ToList();
                break;

            case "year_desc":
                model.ListUsers = model.ListUsers.OrderByDescending(s => s.Role).ToList();
                break;
            }
            int pageSize = 10;

            return(View(PaginatedProductList <UserProfile> .Create(model.ListUsers.AsQueryable(), page ?? 1, pageSize)));
        }