public ActionResult ShowAll() { var allCategories = _categoriesStorage.GetAllCategories(); if (allCategories != null) { return(View(allCategories)); } else { return(RedirectToAction("HttpError404", "Error")); } }
private List <SelectListItem> GetAllCategories() { var listOfCategories = _getcategory.GetAllCategories(); List <SelectListItem> selectList = new List <SelectListItem>(); for (int i = 0; i < listOfCategories.Count; i++) { selectList.Add(new SelectListItem() { Value = listOfCategories[i].ID.ToString(), Text = listOfCategories[i].Name }); } return(selectList); }