コード例 #1
0
        public async Task <ActionResult> Index(int?page)
        {
            if (page == null)
            {
                page = 1;
            }
            //string hnBaseUrl = ConfigurationManager.AppSettings["HNBaseUrl"];

            //int pageSize = int.Parse(ConfigurationManager.AppSettings["PageSize"].ToString());

            _hackerNewsService.SetHNBaseUrl(HnBaseUrl);
            StoryRepo storyRepo = new StoryRepo(_hackerNewsService, HnBaseUrl);

            int[] storyIds = await storyRepo.GetBestStoryIds();

            ViewBag.NumOfPages = Math.Ceiling((double)storyIds.Length / PageSize);

            ViewBag.CurrentPageNumber = page;

            int[] currentStoryIds = storyIds
                                    .Skip((page.Value - 1) * PageSize)
                                    .Take(PageSize)
                                    .ToArray();

            StoryCollection colStory = await storyRepo.GetBestStories(currentStoryIds);

            return(View(colStory));
        }
コード例 #2
0
 public RedirectToActionResult WriteStory(string writer, string storyText)
 {
     story           = new Story();
     story.Writer    = writer;
     story.StoryText = storyText;
     StoryRepo.AddStory(story);
     return(RedirectToAction("Stories"));
 }
コード例 #3
0
 public void StoryController()
 {
     user.Name = "Junebug";
     if (StoryRepo.Stories.Count == 0)
     {
         story = new Story();
         {
             story.Writer    = "Junebug";
             story.StoryText = "I am Junebug and I like to sleep on chairs and take the entire couch. I also love to eat your left over yogurt!";
             StoryRepo.AddStory(story);
         }
     }
 }
コード例 #4
0
 public StoryServImpl()
 {
     storyRepo = Factory.getInstance().getStoryRepo();
 }