예제 #1
0
        public ActionResult Archive(int month = 0, int year = 0)
        {
            DateTime now = DateTime.Now;

            if(month == 0 || year == 0)
            {
                month = now.Month;
                year = now.Year;
            }
            BlogPostService bps = new BlogPostService();
            TagService ts = new TagService();
            IList<PostViewModel> postVms = bps.GetBlogPostsByMonth(month, year).Select(p => PostViewModel.FromBlogPost(p)).ToList();
            IList<ArchiveItem> archiveItems = bps.GetArchiveDetails();
            IList<TagCount> tagCounts = ts.GetTagCounts();

            BlogArchivesPageViewModel vm = new BlogArchivesPageViewModel
            {
                PostViewModels = postVms,
                ArchiveItems = archiveItems,
                TagCounts = tagCounts,
                Year = year,
                MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month),
                IsFuture = now.Year <= year && now.Month < month
            };

            return View(vm);
        }
예제 #2
0
        // GET: Blog
        public ActionResult Index()
        {
            BlogPostService bps = new BlogPostService();
            TagService ts = new TagService();
            IList<PostViewModel> postVms = bps.GetBlogPosts().Select(p => PostViewModel.FromBlogPost(p)).ToList();
            IList<ArchiveItem> archiveItems = bps.GetArchiveDetails();
            IList<TagCount> tagCounts = ts.GetTagCounts();

            BlogLandingPageViewModel vm = new BlogLandingPageViewModel
            {
                PostViewModels = postVms,
                ArchiveItems = archiveItems,
                TagCounts = tagCounts
            };

            return View(vm);
        }
예제 #3
0
        public ActionResult BlogPost(string urlSlug)
        {
            BlogPostService bps = new BlogPostService();
            TagService ts = new TagService();
            PostViewModel postVm = PostViewModel.FromBlogPost(bps.GetBlogPost(urlSlug));
            IList<ArchiveItem> archiveItems = bps.GetArchiveDetails();
            IList<TagCount> tagCounts = ts.GetTagCounts();

            BlogPostPageViewModel vm = new BlogPostPageViewModel
            {
                PostViewModel = postVm,
                ArchiveItems = archiveItems,
                TagCounts = tagCounts
            };

            return View(vm);
        }
예제 #4
0
        public ActionResult Tags(string urlSlug)
        {
            BlogPostService bps = new BlogPostService();
            TagService ts = new TagService();
            IList<PostViewModel> postVms = bps.GetBlogPostsByTag(urlSlug).Select(p => PostViewModel.FromBlogPost(p)).ToList();
            IList<ArchiveItem> archiveItems = bps.GetArchiveDetails();
            IList<TagCount> tagCounts = ts.GetTagCounts();
            string tagName = ts.GetTagNameFromSlug(urlSlug);

            BlogTagsPageViewModel vm = new BlogTagsPageViewModel
            {
                PostViewModels = postVms,
                ArchiveItems = archiveItems,
                TagCounts = tagCounts,
                TagName = tagName
            };

            return View(vm);
        }