Beispiel #1
0
        public static string GetNextPageLink(this HtmlHelper helper, BlogPageViewModel model)
        {
            var parts = new List <string> {
                "blog"
            };

            if (model.Year != 0)
            {
                parts.Add("archive");
                parts.Add(model.Year.ToString());
                if (model.Month != 0)
                {
                    parts.Add(model.Month.ToString("D2"));
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(model.Category))
                {
                    parts.Add("category");
                    parts.Add(model.Category);
                }
            }

            return($"/{string.Join("/", parts)}/?page={model.CurrentPage + 1}");
        }
Beispiel #2
0
        public static string GetPreviousPageLink(this HtmlHelper helper, BlogPageViewModel model)
        {
            var parts = new List <string>();

            parts.Add("blog");

            if (model.Year != 0)
            {
                parts.Add(model.Year.ToString());
                if (model.Month != 0)
                {
                    parts.Add(model.Month.ToString("D2"));
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(model.Category))
                {
                    parts.Add("category");
                    parts.Add(model.Category);
                }
            }

            return(string.Format("/{0}/?page={1}",
                                 string.Join("/", parts),
                                 Math.Max(model.CurrentPage - 1, 1)));
        }
        public ActionResult Index(BlogPageViewModel currentPage, int pager = 0)
        {
            currentPage.BlogPosts  = MemoryCache.GetTenPosts(pager);
            currentPage.Categories = MemoryCache.GetAllCategories();
            currentPage.Page       = pager;

            return(View("Blog", currentPage));
        }
Beispiel #4
0
        public ViewResult Index()
        {
            var blogPosts = new BlogPageViewModel
            {
                Posts = _posts.Posts
            };

            return(View(blogPosts));
        }
        public ActionResult Category(BlogPageViewModel currentPage, string category, int pager = 0)
        {
            currentPage.BlogPosts      = MemoryCache.GetTenPostsFromCategory(category, pager);
            currentPage.Categories     = MemoryCache.GetAllCategories();
            currentPage.Page           = pager;
            currentPage.ActiveCategory = category;

            return(View("Blog", currentPage));
        }
Beispiel #6
0
        public static BlogPageViewModel Get(IPublishedContent pageItem)
        {
            var model = new BlogPageViewModel();

            Helpers.PopulatePageBase.Fill(model, pageItem);

            model.Tags = pageItem.HasValue(FieldNames.Tags) ? pageItem.GetPropertyValue <string>(FieldNames.Tags) : string.Empty;

            return(model);
        }
Beispiel #7
0
        public BlogPageViewModel BuildList(IAbstractPage blogPage)
        {
            var vm = new BlogPageViewModel {
                Header = blogPage.Title
            };

            vm.Items.AddRange(BlogService.GetAllPosts().Select(p => new BlogItemInListViewModel
            {
                Id               = p.Id,
                Title            = p.Title,
                Brief            = p.Brief,
                Date             = p.PostDate.ToString("dd.MM.yyyy"),
                CategoryName     = p.Category?.Title,
                Image            = p.Image,
                YoutubeVideoCode = p.YoutubeVideoCode,
                Url              = blogPage.GetUrl() + "/details/" + p.Id,
                Published        = p.Published
            }));
            return(vm);
        }
 public ActionResult Create()
 {
     var model = new BlogPageViewModel();
     return View(model);
 }
Beispiel #9
0
        public ActionResult Index(BlogPage currentPage)
        {
            var model = new BlogPageViewModel();

            return(View(model));
        }
Beispiel #10
0
 public BlogPage()
 {
     InitializeComponent();
     BindingContext = ViewModel = new BlogPageViewModel(Navigation);
 }