public ActionResult FilterAndSort(string sort, bool desc, string startDate, string endDate, string user, string car, bool showUncompleted) { List<Report> reports = _db.Reports.ToList().Filter(startDate, endDate, user, car, showUncompleted); reports = reports.Sort(sort, desc); // Sort() is an extension method, see Utils->ExtensionMethod->Sort List<LogViewModel> LogList = new List<LogViewModel>(); foreach (Report item in reports) { LogViewModel LVM = new LogViewModel(); LVM.Report = item; LogList.Add(LVM); } return PartialView("_LogTable", LogList); }
// GET: Log public ActionResult Index(string orderBy) { List<LogViewModel> LogList = new List<LogViewModel>(); foreach (Report item in _db.Reports.OrderByDescending(r => r.Date)) { LogViewModel LVM = new LogViewModel(); LVM.Report = item; LogList.Add(LVM); } ViewData["LogList"] = LogList; return View(); }