public ActionResult Index() { var model = new LogsIndexViewModel(); model.Entries = _logsRepository.GetAll().Select(entry => BuildLogEntryViewModel(entry)).ToList(); return(View(model)); }
public ActionResult Index() { List <GoalLog> goalLogs = _context.GoalLogs.ToList(); var model = new LogsIndexViewModel { GoalLogs = goalLogs }; return(View(model)); }
// GET: Logs public async Task <IActionResult> Index() { SelectList users = new SelectList(_context.Users, "UserName", "UserName"); IOrderedQueryable <Log> logs = _context.Logs.OrderByDescending(l => l.Timestamp); LogsIndexViewModel response = new LogsIndexViewModel { Logs = await logs.Take(_logsPP).ToListAsync(), Users = users, FirstPage = true, LastPage = (logs.Count() <= _logsPP), PageNum = 1 }; return(View(response)); }
public async Task <IActionResult> IndexFilter([Bind("ClasseSearch,DateMin,DateMax,User,Page")] LogsSearchViewModel search) { int skipNum = (search.Page - 1) * _logsPP; IQueryable <Log> logs = _context.Logs; if (!String.IsNullOrEmpty(search.ClasseSearch)) { logs = logs.Where(l => l.Classe.Contains(search.ClasseSearch)); } if (!String.IsNullOrEmpty(search.User)) { logs = logs.Where(l => l.Utilizador.Equals(search.User)); } if (search.DateMin != null) { logs = logs.Where(l => l.Timestamp >= search.DateMin); } if (search.DateMax != null) { logs = logs.Where(l => l.Timestamp <= search.DateMax); } logs = logs.Skip(skipNum); LogsIndexViewModel response = new LogsIndexViewModel { Logs = await logs.Take(_logsPP).ToListAsync(), FirstPage = (search.Page == 1), LastPage = (logs.Count() <= _logsPP), PageNum = search.Page }; return(PartialView("PartialViews/_IndexCards", response)); }