コード例 #1
0
        // GET: Admin/ListUsers
        public ActionResult Index(string SortOrder, string SortBy, string Page)
        {
            ViewBag.SortOrder = SortOrder;
            ViewBag.SortBy    = SortBy;
            var users = objBs.GetALL();

            switch (SortBy)
            {
            case "UserEmail":
                switch (SortOrder)
                {
                case "Asc":
                    users = users.OrderBy(x => x.UserEmail).ToList();
                    break;

                case "Desc":
                    users = users.OrderByDescending(x => x.UserEmail).ToList();
                    break;

                default:
                    break;
                }
                break;

            case "Role":
                switch (SortOrder)
                {
                case "Asc":
                    users = users.OrderBy(x => x.Role).ToList();
                    break;

                case "Desc":
                    users = users.OrderByDescending(x => x.Role).ToList();
                    break;

                default:
                    break;
                }
                break;

            default:
                users = users.OrderBy(x => x.UserEmail).ToList();
                break;
            }

            ViewBag.TotalPages = Math.Ceiling(objBs.GetALL().Count() / 10.0);

            int page = int.Parse(Page == null ? "1" : Page);

            ViewBag.Page = page;
            users        = users.Skip((page - 1) * 10).Take(10);


            return(View(users));
        }
コード例 #2
0
 // controller to create an event
 public ActionResult Index()
 {
     ViewBag.UserID = new SelectList(objUserBs.GetALL().ToList(), "UserID", "Email");
     return(View("Index"));
 }