// GET: Events public ActionResult Index() { HomeworkRepository repository = new HomeworkRepository(); List<Homework> postPublications = repository.GetAll(); postPublications.Reverse(); HomeworkListViewModel model = new HomeworkListViewModel(); model.Homeworks = postPublications; return View(model); }
// GET : Homework List public async Task <IActionResult> List() { var homeworkList = new HomeworkListViewModel() { HomeworkList = await _schoolDataDbContext.HomeworkDescriptions.ToListAsync() }; if (homeworkList == null) { ModelState.AddModelError(string.Empty, "List has null values"); return(View("Index")); } return(View(homeworkList)); }
// POST: Homework List public async Task <IActionResult> List(string key) { if (string.IsNullOrEmpty(key)) { ModelState.AddModelError(string.Empty, "Key is null"); return(View("List")); } var result = new HomeworkListViewModel() { HomeworkList = await _schoolDataDbContext.HomeworkDescriptions.Where(s => s.HomeworkDetails.Contains(key)).ToListAsync() }; if (result == null) { ModelState.AddModelError(string.Empty, "Model is not have any value"); return(View("List")); } return(View("List", result)); }