public static IEnumerable<PornCantina.Models.Image> GetThumbnailsForGallery(Guid galleryId) { using(var context = new PornCantinaContext()) { var query = (from i in context.Images where i.GalleryId == galleryId orderby i.ThumbnailFileName ascending select i).ToList(); return query; } }
public static List<Gallery> GetGalleries() { using(var context = new PornCantinaContext()) { var query = (from g in context.Galleries where g.IsActive == true orderby g.DatePublished descending select g).ToList(); return query; } }
public static IEnumerable<Image> GetThumbnailsForModelGalleries(Guid modelId) { using(var context = new PornCantinaContext()) { var query = (from i in context.Images join g in context.Galleries on i.GalleryId equals g.Id where g.ModelId == modelId orderby i.ThumbnailFileName ascending select i).ToList(); return query; } }
public int GetActiveGalleryCountByModel(Guid modelId) { int count = 0; using(var context = new PornCantinaContext()) { if(context.Galleries.Where(g => g.ModelId == modelId && g.IsActive == true) != null) { count = context.Galleries.Where(g => g.ModelId == modelId && g.IsActive == true).Count(); } } return count; }
public static PagedList<Gallery> GetModelGalleries(Guid modelId, int skip, int take) { using(var context = new PornCantinaContext()) { var query = GetModelGalleries(modelId); var galleryCount = query.Count(); var galleries = query.Skip(skip).Take(take).ToList(); return new PagedList<Gallery> { Entities = galleries, HasNext = (skip + 20 < galleryCount), HasPrevious = (skip > 0) }; } }
public static PagedList<Gallery> GetPagedGalleries(int skip, int take) { using(var context = new PornCantinaContext()) { var query = (from g in context.Galleries where g.IsActive == true orderby g.DatePublished descending select g).ToList(); var galleryCount = query.Count(); var galleries = query.Skip(skip).Take(take).ToList(); return new PagedList<Gallery> { Entities = galleries, HasNext = (skip + 20 < galleryCount), HasPrevious = (skip > 0) }; } }
public void PopulateGalleryImage() { string basePath = @"Content/Models"; DirectoryInfo dInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + basePath); using(var context = new PornCantinaContext()) { // iterate through each model folder foreach(var modelRootFolder in dInfo.GetDirectories()) { DirectoryInfo modelImageGalleryFolder = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + modelRootFolder + "ImageGalleries"); // iterate through each gallery folder foreach(var galleryFolder in modelImageGalleryFolder.GetDirectories()) { this.PopulateGalleryImages(modelRootFolder.Name, galleryFolder.Name); } } } }
public string GetWebSiteReferralLink(Model model) { using(var context = new PornCantinaContext()) { var webSite = context.WebSites.Where(w => w.Id == model.WebSiteId); return webSite.FirstOrDefault().ReferralLink; } }