예제 #1
0
        public async Task <IActionResult> News()
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = await _userManager.GetUserAsync(User);

            return(Json(_newsReader.GetNews(user)));
        }
예제 #2
0
        public void Setup()
        {
            mockPage = new Mock <Page>(MockBehavior.Strict, new object[] { 8, 2, 1 });

            var newsReader = new NewsReader();
            var allNews    = newsReader.GetNews();

            foreach (News news in allNews)
            {
                mockPage.Object.AddNews(news);
            }

            mockPageRules = new Mock <PageRules>(MockBehavior.Strict, new object[] { mockPage.Object });
        }
예제 #3
0
        static void Main(string[] args)
        {
            NewsReader newsReader = new NewsReader();

            newsReader.RegisterNewsService(new GoogleNewsService());
            newsReader.RegisterNewsService(new PressTrustOfIndiaNewsService());
            newsReader.RegisterNewsService(new InternalNewsService());

            NewsBoard newsPaper = new NewsBoard("NEWS CHANNEL", DateTime.Now);

            newsPaper.MaxPages = 2;
            int maxNewsPerPage          = 8;
            int maxAdvertisementPerPage = 2;
            int pageNumber = 1;

            Page page = newsPaper.CreatePage(maxNewsPerPage, maxAdvertisementPerPage, pageNumber);

            newsPaper.AddPage(page);

            while (true)
            {
                // Get all news from different registered services
                var allNews = newsReader.GetNews();
                foreach (News news in allNews)
                {
                    if (page.IsPageFull())
                    {
                        page = newsPaper.CreatePage(maxNewsPerPage, maxAdvertisementPerPage, (newsPaper.PageCount + 1));
                        newsPaper.AddPage(page);
                    }
                    page.AddNews(news);
                }

                newsPaper.DisplayAllNews();
                Thread.Sleep(3000);
            }
        }
 public async Task <ActionResult> GetNews(DataTablesModel model)
 {
     return(DataTable(await NewsReader.GetNews(model)));
 }