public ActionResult Index() { Category model = new Category(); model.CategoryList = CategoryBusiness.GetCategories(); return(View(model)); }
// Load Categories public async Task <ActionResult> LoadCategories() { CategoryViewModel viewmodel = new CategoryViewModel(); viewmodel.CategoryList = await CategoryBusiness.GetCategories(); return(PartialView("Categories", viewmodel)); }
// Display Index public async Task <ActionResult> Index() { CategoryViewModel viewmodel = new CategoryViewModel(); viewmodel.CategoryList = await CategoryBusiness.GetCategories(); return(View(viewmodel)); }
/// <summary> /// 获取所有的分类,包括item 和 pictures /// </summary> /// <returns></returns> public ActionResult GetCategories() { var categories = _category.GetCategories(); var items = _item.GetItems(); var pictures = _picture.GetPictures(); for (var i = 0; i < items.Count; i++) { items[i].EPictures = pictures.Where(x => x.EItemId == items[i].EId).ToList(); } for (var i = 0; i < categories.Count; i++) { categories[i].EItems = items.Where(x => x.ECategoryId == categories[i].EId).ToList(); } //处理级别 var firstLevelCategories = categories.Where(x => string.IsNullOrWhiteSpace(x.EParentId)).ToList(); firstLevelCategories = firstLevelCategories.OrderBy(x => int.Parse(x.EName.Replace("-", ""))).ToList(); firstLevelCategories.ForEach(x => { x.EName = GetYearName(x.EName); x.ESubCategories = categories.Where(y => y.EParentId == x.EId).ToList(); x.ESubCategories = x.ESubCategories?.OrderBy(y => int.Parse(y.EName.Replace("-", ""))).ToList(); x.ESubCategories.ForEach(m => { m.EName = GetMonthName(m.EName); m.EItems = m.EItems?.OrderBy(y => DateTime.Parse(y.EName)).ToList(); }); }); return(Json(firstLevelCategories, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Método que consulta todos los registros de la entidad /// </summary> /// <returns>Lista de registros</returns> public async Task <List <Category> > GetCategories() { List <Category> categories = categoryBusiness.GetCategories(); return(categories); }
private void ShowCategories() { dataGridView1.DataSource = CategoryBusiness.GetCategories(); }
//Ekelenen kategorileri formda görmek için: public void getCategories() { dataGridViewCategories.DataSource = categoryBusiness.GetCategories(); }