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); }
public PostDetailsViewModel(ISbDatabase db, int id, Uri requestUrl) : base(db) { Post = db.ActivePosts.SingleOrDefault(p => p.Id == id); RequestUrl = requestUrl; AllPostCategories = db.PostCategories; }
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; }
public WritingIndexViewModel(ISbDatabase db) : base(db) { OutputCategories = db.OutputCategories.OrderBy(c => c.Order); }
public TinySellsController(ISbDatabase db) : base(db) { }
public WritingController(ISbDatabase db) : base(db) { }
public PostsController(ISbDatabase db) : base(db) { }
public SbController(ISbDatabase db) { this.db = db; }