public ProductsWeb Get(int SiteID, string Url, string Lang, int CurrencyID, string ProductCategoryFriendlyUrl, int Page) { int Take = 100;//SHOULD BE FROM USER INPUT using (var _c = db) { if (SiteID == 0) { SiteID = new SiteBLL().Get(Url, _c).SiteID; } var _Culture = new CategoryBLL().GetCulture(SiteID, Lang, ProductCategoryFriendlyUrl, _c); var _Q = Get(SiteID, _Culture.CultureID, CurrencyID, ProductCategoryFriendlyUrl, _c); var _PW = new ProductsWeb(); _PW.Products = _Q.Skip(Take * (Page - 1)).Take(Take).ToList(); _PW.NumberPages = _Q.Count() / Take; // _PW.Categories = new CategoryBLL().Get(SiteID, null, ProductCategoryFriendlyUrl, Lang, FriendlyUrl); _PW.CultureID = _Culture.CultureID; _PW.CultureName = _Culture.Name; //if (!string.IsNullOrEmpty(ProductCategoryFriendlyUrl)) //{ // _PW.Category = new CategoryBLL().Get(ProductCategoryFriendlyUrl, _Culture.CultureID); //} return(_PW); } }
public BlogListWeb Get(int SiteID , string Url , string Lang , string BlogCategoryFriendlyUrl , string BlogTagName , int Page , bool IncludeContent = false) { var _Take = 10;//SHOULD BE CUSTOM BY USER using (var _c = db) { if (SiteID == 0) SiteID = new SiteBLL().Get(Url, _c).SiteID; var _Site = new SiteBLL().Get(SiteID); var _Query = from bpc in _c.BlogPostCultures where bpc.BlogPost.SiteID == SiteID //THIS CODE BRING ALL FROM REQUETED LANG & IF THERE IS OTHER POST IN THE DEFAULT LANG IT BRINGS AS WELL && (bpc.Culture.Name.ToLower().Equals(Lang.ToLower()) ? bpc.Culture.Name.ToLower().Equals(Lang.ToLower()) : bpc.Culture.Name.ToLower().Equals(_Site.DefaultLang)) && bpc.Published select bpc; if (!string.IsNullOrEmpty(BlogCategoryFriendlyUrl)) { _Query = from q in _Query join c in _c.BlogPostCategories on q.BlogPostID equals c.BlogPostID join cc in _c.BlogCategoryCultures on c.BlogCategoryID equals cc.BlogCategoryID where cc.FriendlyUrl.Equals(BlogCategoryFriendlyUrl) select q; } if (!string.IsNullOrEmpty(BlogTagName)) { _Query = from q in _Query join t in _c.BlogPostTags on q.BlogPostID equals t.BlogPostID where t.BlogTag.BlogTagName.Equals(BlogTagName) select q; } var _Model = new BlogListWeb(); var _Count = _Query.Count(); _Model.Pages = _Count % _Take == 0 ? _Count / _Take : (_Count / _Take) + 1; _Model.Data = _Query.OrderByDescending(m => m.DateCreated).Select(m => new BlogPostWeb { BlogPostID = m.BlogPostID, FriendlyUrl = m.FriendlyUrl, Title = m.Title, ContentPreview = m.ContentPreview, FeatureImageUrl = m.BlogPostFeatureImage != null ? m.BlogPostFeatureImage.Media.MediaUrl : null, DateCreated = m.DateCreated, Content = (IncludeContent) ? m.Content : null }) .Skip(_Take * (Page - 1)).Take(_Take).ToList(); _Model.Categories = GetCategoriesUsed(SiteID, Lang); _Model.Tags = GetTagUsed(SiteID); return _Model; } }
public List<CategoryWeb> Get(int SiteID, string Url, int CategoryID, string Lang, string FriendlyUrl) { using (var _c = db) { if (SiteID == 0) SiteID = new SiteBLL().Get(Url, _c).SiteID; int CultureID = GetCulture(SiteID, Lang, FriendlyUrl, _c).CultureID; var _Category = Get(SiteID, CultureID, CategoryID, _c).ToList(); return GetTree(_Category, SiteID, CultureID, CategoryID, _c); } }
public ContentBindingList GetByRoot(int SiteID, String Url, string AliasList, string Lang, ApplicationDbContext _c) { if (string.IsNullOrEmpty(AliasList)) { return(null); } List <ContentBindingList> _List; if (SiteID == 0) { SiteID = new SiteBLL().Get(Url, _c).SiteID; } var _CParentID = (from c in _c.ContentProperties where c.SiteID == SiteID && c.ContentPropertyAlias == AliasList select c.ContentPropertyID).FirstOrDefault(); if (_CParentID == 0) { return(null); } _List = (from cr in _c.ContentRoots join p in _c.ContentProperties on cr.ContentID equals p.ContentPropertyID where cr.ContentParentID == _CParentID || p.ContentPropertyID == _CParentID select new ContentBindingList { ContentPropertyAlias = p.ContentPropertyAlias, ContentPropertyID = p.ContentPropertyID, ContentPropertyParentID = p.ContentPropertyParentID, Priority = p.Priority, SiteID = p.SiteID, ContentPropertyType = p.ContentPropertyType, Enabled = p.Enabled, InMenu = p.InMenu, ContentCultures = p.ContentPropertyCultures.Where(m => m.Culture.Name.ToLower().Equals(Lang.ToLower()) && m.Culture.SiteID == p.SiteID).Select(m => new ContentCultureBinding { ContentPropertyID = p.ContentPropertyID, ContentPropertyValue = m.ContentPropertyValue, CultureID = m.CultureID, Hint = m.Hint }) }).OrderBy(m => m.Priority).ToList(); if (_List == null || _List.Count == 0) { return(null); } var _RootItem = _List.Where(m => m.ContentPropertyID == _CParentID).FirstOrDefault(); _RootItem.Items = OrderByRoot(_List, _CParentID); return(_RootItem); }
public List <CategoryWeb> Get(int SiteID, string Url, int CategoryID, string Lang, string FriendlyUrl) { using (var _c = db) { if (SiteID == 0) { SiteID = new SiteBLL().Get(Url, _c).SiteID; } int CultureID = GetCulture(SiteID, Lang, FriendlyUrl, _c).CultureID; var _Category = Get(SiteID, CultureID, CategoryID, _c).ToList(); return(GetTree(_Category, SiteID, CultureID, CategoryID, _c)); } }
public ProductWeb GetDetail(int SiteID, string Url, string FriendlyUrl, int CurrencyID) { using (var _c = db) { if (SiteID == 0) { SiteID = new SiteBLL().Get(Url, _c).SiteID; } return(Select((from m in _c.ProductCultures where m.Product.SiteID == SiteID && m.FriendlyUrl.ToLower().Equals(FriendlyUrl.ToLower()) select m), CurrencyID, _c).FirstOrDefault()); } }
public void Migrator() { using (var _c = db) { _c.Database.ExecuteSqlCommand("DELETE FROM ContentRoots"); } var _Sites = new SiteBLL().GetAll(); foreach (var item in _Sites) { var _Tree = Get(item.SiteID); MigratorUpdate(_Tree); } }
public SiteMapModel GetSitemap(int SiteID, string Url) { using (var _c = db) { bool _ECommerce = false; bool _Blog = false; if (SiteID == 0) { var _Site = new SiteBLL().Get(Url, _c); SiteID = _Site.SiteID; _ECommerce = _Site.ECommerce; _Blog = _Site.Blog; } else { var _Site = new SiteBLL().Get(SiteID); _ECommerce = _Site.ECommerce; _Blog = _Site.Blog; } var _S = new SiteMapModel(); _S.Pages = (from p in _c.PageCultures where p.Page.SiteID == SiteID where p.Published && string.IsNullOrEmpty(p.RedirectUrl) select new PageCultureBinding { CultureID = p.CultureID, FriendlyUrl = p.FriendlyUrl, RedirectUrl = p.RedirectUrl, Name = p.Name, PageAlias = p.Page.Alias }).Distinct().ToList(); _S.Ecommerce = _ECommerce; _S.Blog = _Blog; if (_ECommerce) { _S.Products = new ProductBLL().GetSitemap(SiteID); _S.Categories = new CategoryBLL().GetSitemap(SiteID); } if (_Blog) { _S.Posts = new BlogBLL().GetSitemap(SiteID); _S.BlogCategories = new BlogBLL().GetSitemapCategories(SiteID); _S.BlogTags = new BlogBLL().GetSitemapTags(SiteID); } return(_S); } }
public ContentBindingList GetByRoot(int SiteID, String Url, string AliasList, string Lang, ApplicationDbContext _c) { if (string.IsNullOrEmpty(AliasList)) return null; List<ContentBindingList> _List; if (SiteID == 0) SiteID = new SiteBLL().Get(Url, _c).SiteID; var _CParentID = (from c in _c.ContentProperties where c.SiteID == SiteID && c.ContentPropertyAlias == AliasList select c.ContentPropertyID).FirstOrDefault(); if(_CParentID==0) return null; _List = (from cr in _c.ContentRoots join p in _c.ContentProperties on cr.ContentID equals p.ContentPropertyID where cr.ContentParentID == _CParentID || p.ContentPropertyID == _CParentID select new ContentBindingList { ContentPropertyAlias = p.ContentPropertyAlias, ContentPropertyID = p.ContentPropertyID, ContentPropertyParentID = p.ContentPropertyParentID, Priority = p.Priority, SiteID = p.SiteID, ContentPropertyType = p.ContentPropertyType, Enabled = p.Enabled, InMenu = p.InMenu, ContentCultures = p.ContentPropertyCultures.Where(m => m.Culture.Name.ToLower().Equals(Lang.ToLower()) && m.Culture.SiteID == p.SiteID).Select(m => new ContentCultureBinding { ContentPropertyID = p.ContentPropertyID, ContentPropertyValue = m.ContentPropertyValue, CultureID = m.CultureID, Hint = m.Hint }) }).OrderBy(m => m.Priority).ToList(); if (_List == null || _List.Count == 0) return null; var _RootItem = _List.Where(m => m.ContentPropertyID == _CParentID).FirstOrDefault(); _RootItem.Items = OrderByRoot(_List, _CParentID); return _RootItem; }
public BlogPostWeb GetDetail(int SiteID, string Url, int BlogPostID, string FriendlyUrl) { using (var _c = db) { if (SiteID == 0) { SiteID = new SiteBLL().Get(Url, _c).SiteID; } var _Model = GetDetail(SiteID, BlogPostID, FriendlyUrl, null, _c).FirstOrDefault(); if (_Model == null) { var _Site = new SiteBLL().Get(SiteID); _Model = GetDetail(SiteID, BlogPostID, null, _Site.DefaultLang, _c).FirstOrDefault(); } _Model.AllCategories = GetCategoriesUsed(_Model.SiteID, _Model.CultureID); _Model.AllTags = GetTagUsed(_Model.SiteID); return(_Model); } }
public ProductsWeb Get(int SiteID, string Url, string Lang, int CurrencyID, string ProductCategoryFriendlyUrl, int Page) { int Take = 100;//SHOULD BE FROM USER INPUT using (var _c = db) { if (SiteID == 0) SiteID = new SiteBLL().Get(Url, _c).SiteID; var _Culture = new CategoryBLL().GetCulture(SiteID, Lang, ProductCategoryFriendlyUrl, _c); var _Q = Get(SiteID, _Culture.CultureID, CurrencyID, ProductCategoryFriendlyUrl, _c); var _PW = new ProductsWeb(); _PW.Products = _Q.Skip(Take * (Page - 1)).Take(Take).ToList(); _PW.NumberPages = _Q.Count() / Take; // _PW.Categories = new CategoryBLL().Get(SiteID, null, ProductCategoryFriendlyUrl, Lang, FriendlyUrl); _PW.CultureID = _Culture.CultureID; _PW.CultureName = _Culture.Name; //if (!string.IsNullOrEmpty(ProductCategoryFriendlyUrl)) //{ // _PW.Category = new CategoryBLL().Get(ProductCategoryFriendlyUrl, _Culture.CultureID); //} return _PW; } }
public BlogPostWeb GetDetail(int SiteID, string Url, int BlogPostID, string FriendlyUrl) { using (var _c = db) { if (SiteID == 0) SiteID = new SiteBLL().Get(Url, _c).SiteID; var _Model = GetDetail(SiteID, BlogPostID, FriendlyUrl, null, _c).FirstOrDefault(); if (_Model == null) { var _Site = new SiteBLL().Get(SiteID); _Model = GetDetail(SiteID, BlogPostID, null, _Site.DefaultLang, _c).FirstOrDefault(); } _Model.AllCategories = GetCategoriesUsed(_Model.SiteID, _Model.CultureID); _Model.AllTags = GetTagUsed(_Model.SiteID); return _Model; } }
public ProductWeb GetDetail(int SiteID, string Url, string FriendlyUrl, int CurrencyID) { using (var _c = db) { if (SiteID == 0) SiteID = new SiteBLL().Get(Url, _c).SiteID; return Select((from m in _c.ProductCultures where m.Product.SiteID == SiteID && m.FriendlyUrl.ToLower().Equals(FriendlyUrl.ToLower()) select m), CurrencyID, _c).FirstOrDefault(); } }
public BlogListWeb Get(int SiteID , string Url , string Lang , string BlogCategoryFriendlyUrl , string BlogTagName , int Page , bool IncludeContent = false) { var _Take = 10;//SHOULD BE CUSTOM BY USER using (var _c = db) { if (SiteID == 0) { SiteID = new SiteBLL().Get(Url, _c).SiteID; } var _Site = new SiteBLL().Get(SiteID); var _Query = from bpc in _c.BlogPostCultures where bpc.BlogPost.SiteID == SiteID //THIS CODE BRING ALL FROM REQUETED LANG & IF THERE IS OTHER POST IN THE DEFAULT LANG IT BRINGS AS WELL && (bpc.Culture.Name.ToLower().Equals(Lang.ToLower()) ? bpc.Culture.Name.ToLower().Equals(Lang.ToLower()) : bpc.Culture.Name.ToLower().Equals(_Site.DefaultLang)) && bpc.Published select bpc; if (!string.IsNullOrEmpty(BlogCategoryFriendlyUrl)) { _Query = from q in _Query join c in _c.BlogPostCategories on q.BlogPostID equals c.BlogPostID join cc in _c.BlogCategoryCultures on c.BlogCategoryID equals cc.BlogCategoryID where cc.FriendlyUrl.Equals(BlogCategoryFriendlyUrl) select q; } if (!string.IsNullOrEmpty(BlogTagName)) { _Query = from q in _Query join t in _c.BlogPostTags on q.BlogPostID equals t.BlogPostID where t.BlogTag.BlogTagName.Equals(BlogTagName) select q; } var _Model = new BlogListWeb(); var _Count = _Query.Count(); _Model.Pages = _Count % _Take == 0 ? _Count / _Take : (_Count / _Take) + 1; _Model.Data = _Query.OrderByDescending(m => m.DateCreated).Select(m => new BlogPostWeb { BlogPostID = m.BlogPostID, FriendlyUrl = m.FriendlyUrl, Title = m.Title, ContentPreview = m.ContentPreview, FeatureImageUrl = m.BlogPostFeatureImage != null ? m.BlogPostFeatureImage.Media.MediaUrl : null, DateCreated = m.DateCreated, Content = (IncludeContent) ? m.Content : null }) .Skip(_Take * (Page - 1)).Take(_Take).ToList(); _Model.Categories = GetCategoriesUsed(SiteID, Lang); _Model.Tags = GetTagUsed(SiteID); return(_Model); } }
public SiteMapModel GetSitemap(int SiteID, string Url) { using (var _c = db) { bool _ECommerce = false; bool _Blog = false; if (SiteID == 0) { var _Site = new SiteBLL().Get(Url, _c); SiteID = _Site.SiteID; _ECommerce = _Site.ECommerce; _Blog = _Site.Blog; } else { var _Site = new SiteBLL().Get(SiteID); _ECommerce = _Site.ECommerce; _Blog = _Site.Blog; } var _S = new SiteMapModel(); _S.Pages = (from p in _c.PageCultures where p.Page.SiteID == SiteID where p.Published && string.IsNullOrEmpty(p.RedirectUrl) select new PageCultureBinding { CultureID = p.CultureID, FriendlyUrl = p.FriendlyUrl, RedirectUrl = p.RedirectUrl, Name = p.Name, PageAlias = p.Page.Alias }).Distinct().ToList(); _S.Ecommerce = _ECommerce; _S.Blog = _Blog; if (_ECommerce) { _S.Products = new ProductBLL().GetSitemap(SiteID); _S.Categories = new CategoryBLL().GetSitemap(SiteID); } if (_Blog) { _S.Posts = new BlogBLL().GetSitemap(SiteID); _S.BlogCategories = new BlogBLL().GetSitemapCategories(SiteID); _S.BlogTags = new BlogBLL().GetSitemapTags(SiteID); } return _S; } }