Esempio n. 1
0
 // GET: News
 public ActionResult Index(int? newsId)
 {
     var newsIndex = new NewsIndex();
     newsIndex.Id = newsId;
     newsIndex.newsList = facade.GetNewsGateway().ReadAll().ToList();
     return View(newsIndex);
 }
Esempio n. 2
0
        //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);
        }
Esempio n. 3
0
        // GET: Default
        public ActionResult Index()
        {
            NewsIndex newsIndex = new NewsIndex {
                News = Database.Session.Query <News>().ToList()
            };

            return(View(newsIndex));
        }
Esempio n. 4
0
        // GET: News
        public ActionResult Index(int?newsId)
        {
            var newsIndex = new NewsIndex();

            newsIndex.Id       = newsId;
            newsIndex.newsList = facade.GetNewsGateway().ReadAll().ToList();
            return(View(newsIndex));
        }
Esempio n. 5
0
        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));
        }