// GET: News public ActionResult Index(int? newsId) { var newsIndex = new NewsIndex(); newsIndex.Id = newsId; newsIndex.newsList = facade.GetNewsGateway().ReadAll().ToList(); return View(newsIndex); }
//get all news public List <NewsIndex> GetAllNews(int pageIndex, int pageSize) { var newsList = DB.NewsStories .OrderByDescending(o => o.Date) .Skip((pageIndex - 1) * pageSize) .Take(pageSize) .ToList(); var returnList = new List <NewsIndex>(); foreach (var story in newsList) { var returnStory = new NewsIndex { Author = story.Author, Date = story.Date, ID = story.ID, StoryImgPath = story.StoryImgPath, SubTitle = story.SubTitle, Title = story.Title }; returnList.Add(returnStory); } return(returnList); }
// GET: Default public ActionResult Index() { NewsIndex newsIndex = new NewsIndex { News = Database.Session.Query <News>().ToList() }; return(View(newsIndex)); }
// GET: News public ActionResult Index(int?newsId) { var newsIndex = new NewsIndex(); newsIndex.Id = newsId; newsIndex.newsList = facade.GetNewsGateway().ReadAll().ToList(); return(View(newsIndex)); }
public ActionResult CategoryOfNews(string CategoryName) { Category category = Database.Session.Query <Category>().SingleOrDefault(x => x.CategoryName.Equals(CategoryName)); if (category == null) { return(RedirectToRoute("Home")); } NewsIndex newsIndex = new NewsIndex { News = Database.Session.Query <News>().Where(x => x.CategoryID.Equals(category.ID)).ToList() }; return(View(newsIndex)); }