public async Task <ActionResult> Create() { ViewBag.Majors = await MajorManager.GetAllEntities().ToListAsync(); var departments = await DepartmentManager.GetAllEntities().ToListAsync(); SelectList selectList = new SelectList(departments, "Id", "Name"); ViewBag.selectList = selectList; return(View()); }
public ActionResult Index(int?p, string searchString, string currentFilter) { var list = MajorManager.GetAllEntities(); if (searchString != null) { p = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; list = list.Where(e => string.IsNullOrEmpty(searchString) || e.Name.Contains(searchString)); list = list.OrderBy(e => e.Name); var pagesize = 5; var page = p ?? 1; return(View(list.ToPagedList(page, pagesize))); }