Ejemplo n.º 1
0
        public PostIndexViewModel(ISbDatabase db, string category = "", int page = 0)
            : base(db)
        {
            CurrentCategory = category ?? "";

            Title    = db.Site.Title;
            About    = db.Site.BriefAbout;
            PageSize = db.Site.PageSize;
            var categoryPosts  = FilterPostsByCategory(db.ActivePosts, CurrentCategory);
            int totalPostCount = categoryPosts.Count();

            Page  = Math.Min(Math.Max(page, 0), (int)Math.Floor((double)totalPostCount / (double)PageSize));
            Posts = FilterPostsByPage(categoryPosts, PageSize, Page);

            var cat = PostCategories.FirstOrDefault(c => string.Compare(c.Name, CurrentCategory, true) == 0);

            if (cat != null)
            {
                CurrentCategoryName = cat.DisplayName;
            }
            else
            {
                CurrentCategoryName = CurrentCategory;
            }

            NewerPostCount = Page * PageSize;
            OlderPostCount = Math.Max(0, totalPostCount - (Page + 1) * PageSize);
        }
Ejemplo n.º 2
0
 public PostDetailsViewModel(ISbDatabase db, int id, Uri requestUrl)
     : base(db)
 {
     Post              = db.ActivePosts.SingleOrDefault(p => p.Id == id);
     RequestUrl        = requestUrl;
     AllPostCategories = db.PostCategories;
 }
Ejemplo n.º 3
0
 public MasterViewModel(ISbDatabase db)
 {
     Zones           = db.LandingZones.Where(z => z.IsActive);
     CurrentZone     = GetCurrentZone(Zones);
     PostCategories  = db.PostCategories;
     ContactEmail    = db.Site.ContactEmail;
     ContactName     = db.Site.ContactName;
     Badges          = db.Badges.Where(b => b.IsActive).OrderBy(b => b.Order);
     TextAds         = db.TextAds;
     BannerAds       = db.BannerAds;
     CopyrightNotice = db.Site.CopyrightNotice;
 }
Ejemplo n.º 4
0
 public WritingIndexViewModel(ISbDatabase db)
     : base(db)
 {
     OutputCategories = db.OutputCategories.OrderBy(c => c.Order);
 }
Ejemplo n.º 5
0
 public TinySellsController(ISbDatabase db) : base(db)
 {
 }
Ejemplo n.º 6
0
 public WritingController(ISbDatabase db) : base(db)
 {
 }
Ejemplo n.º 7
0
 public PostsController(ISbDatabase db) : base(db)
 {
 }
Ejemplo n.º 8
0
 public SbController(ISbDatabase db)
 {
     this.db = db;
 }