Пример #1
0
        public ActionResult Index()
        {
            IEnumerable<Category> cats;
            using (Repos repo = new Repos())
            {
                cats = repo.GetCategoryList();
            }

            return View(cats);
        }
Пример #2
0
 private void PopulateCategoryDropDownList(object selectedCategory = null)
 {
     IEnumerable<Category> categoryQuery;
     using (Repos repo = new Repos())
     {
         categoryQuery = repo.GetCategoryList();
     }
     ViewBag.CategoryId = new SelectList(categoryQuery.Distinct().ToList(), "CategoryId", "CategoryName", selectedCategory);
 }