예제 #1
0
        public IActionResult Agents(string sortOrder)
        {
            ViewData["NameSortParm"]   = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["EmailSortParm"]  = sortOrder == "Email" ? "email_desc" : "Email";
            ViewData["OfficeSortParm"] = sortOrder == "Office" ? "office_desc" : "Office";

            var agents = _repo.GetAllAppUsers();

            switch (sortOrder)
            {
            case "name_desc":
                agents = agents.OrderByDescending(a => a.LastName).ToList();
                break;

            case "email_desc":
                agents = agents.OrderByDescending(a => a.Email).ToList();
                break;

            case "Email":
                agents = agents.OrderBy(a => a.Email).ToList();
                break;

            case "office_desc":
                agents = agents.OrderByDescending(a => a.Office).ToList();
                break;

            case "Office":
                agents = agents.OrderBy(a => a.Office).ToList();
                break;

            default:
                agents = agents.OrderBy(a => a.LastName).ToList();
                break;
            }

            return(View(agents));
        }