//Возвращает виды макетов (визитки, листовки) public ActionResult ItemTypes() { //var cards = new List<cards>(_entities.cards.OrderByDescending(c => c.Id).Where(c => c.published == true && c.ITEM_TYPE_ID == 1).GroupBy(c => c.layout_id).SelectMany(c => c.Take(10)).ToList()); //var lists = new List<cards>(_entities.cards.OrderByDescending(c => c.Id).Where(c => c.published == true && c.ITEM_TYPE_ID == 2).GroupBy(c => c.layout_id).SelectMany(c => c.Take(10)).ToList()); var cards = new List <KeyValuePair <layout, List <cards> > >(); foreach (var item in _entities.ITEM_TYPE) { List <cards> tmpList = new List <Models.cards>(); foreach (var i in _entities.layout) { int width = Int32.Parse(i.width); int height = Int32.Parse(i.height); if (width > height) { tmpList = _entities.cards.OrderByDescending(c => c.Id).Where(c => c.published == true && c.ITEM_TYPE_ID == item.Id && c.layout_id == i.Id).Take(10).ToList(); KeyValuePair <layout, List <cards> > cardKVP = new KeyValuePair <layout, List <Models.cards> >(i, tmpList); cards.Add(cardKVP); } } } string userName = User.Identity.Name; var store = new UserStore <ApplicationUser>(new ApplicationDbContext()); var userManager = new UserManager <ApplicationUser>(store); ApplicationUser user = new ApplicationUser(); if (userName != null) { user = userManager.FindByNameAsync(userName).Result; } List <favorite> favorites = new List <favorite>(); if (user != null) { favorites = _entities.favorite.Where(c => c.user_id == user.Id).ToList(); } ViewBag.favorites = favorites; ViewBag.cards = cards; return(View(applicationDAO.getAllItemTypes())); }