public ActionResult Footer() { V308CMSEntities mEntities = new V308CMSEntities(); NewsRepository newsRepository = new NewsRepository(mEntities); List <NewsGroups> mNewsGroupsList; List <NewsGroupPage> mNewsGroupPageList = new List <NewsGroupPage>(); try { //lay cac nhom con cua: 14 la nhom cha Footer mNewsGroupsList = newsRepository.getNewsGroupAffterParent(14); foreach (NewsGroups it in mNewsGroupsList) { NewsGroupPage mNewsGroupPage = new NewsGroupPage(); //lay danh sach cac tin ben trong List <News> mList = newsRepository.LayTinTheoGroupId(it.ID); mNewsGroupPage.Name = it.Name; mNewsGroupPage.TypeId = it.ID; mNewsGroupPage.NewsList = mList; mNewsGroupPageList.Add(mNewsGroupPage); } return(View(mNewsGroupPageList)); } catch (Exception ex) { return(Content("Xảy ra lỗi hệ thống ! Vui lòng thử lại.")); } finally { mEntities.Dispose(); newsRepository.Dispose(); } }
public ActionResult Footer() { CreateRepos(); try { PageFooterControl Model = new PageFooterControl(); List <NewsGroupPage> NewsCategorys = new List <NewsGroupPage>();; NewsGroups footerCate = NewsRepos.SearchNewsGroup("footer-affiliate"); if (footerCate != null) { List <NewsGroups> categorys = NewsRepos.GetNewsGroup(footerCate.ID, true, 3); if (categorys.Count() > 0) { foreach (NewsGroups cate in categorys) { NewsGroupPage NewsCategory = new NewsGroupPage(); NewsCategory.Name = cate.Name; NewsCategory.NewsList = NewsRepos.LayDanhSachTinMoiNhatTheoGroupId(5, cate.ID); NewsCategorys.Add(NewsCategory); } } } Model.NewsCategorys = NewsCategorys; NewsGroups WhoSale = NewsRepos.LayNhomTinAn(29); if (WhoSale.ID > 0) { NewsGroupPage WhoSalePage = new NewsGroupPage(); WhoSalePage.Name = WhoSale.Name; WhoSalePage.NewsList = NewsRepos.LayDanhSachTinMoiNhatTheoGroupId(5, WhoSale.ID); Model.CategoryWhoSale = WhoSalePage; } string view = "~/Views/" + MainController + "/Elements/Footer.cshtml"; return(View(view, Model)); } catch (Exception ex) { return(Content(ex.InnerException.ToString())); } finally { DisposeRepos(); } }
public ActionResult Footer() { var model = new PageFooterControl(); var newsCategorys = new List <NewsGroupPage>();; var footerCate = NewsService.SearchNewsGroup("footer"); if (footerCate.ID > 0) { var categorys = NewsService.GetNewsGroup(footerCate.ID, true, 3); if (categorys.Any()) { newsCategorys.AddRange(categorys.Select(cate => new NewsGroupPage { Name = cate.Name, NewsList = NewsService.LayDanhSachTinMoiNhatTheoGroupId(5, cate.ID) })); } } model.NewsCategorys = newsCategorys; var whoSale = NewsService.LayNhomTinAn(29); if (whoSale.ID > 0) { var whoSalePage = new NewsGroupPage(); whoSalePage.Name = whoSale.Name; whoSalePage.NewsList = NewsService.LayDanhSachTinMoiNhatTheoGroupId(5, whoSale.ID); model.CategoryWhoSale = whoSalePage; } var menusFooter = NewsService.SearchNewsGroup("MenusFooter"); if (menusFooter != null && menusFooter.ID > 0) { model.MenusFooter = NewsService.GetNewsGroup(menusFooter.ID, true, 6); } return(View("Footer", model)); }