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)); }
public RedirectToActionResult WriteStory(string writer, string storyText) { story = new Story(); story.Writer = writer; story.StoryText = storyText; StoryRepo.AddStory(story); return(RedirectToAction("Stories")); }
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); } } }
public StoryServImpl() { storyRepo = Factory.getInstance().getStoryRepo(); }