public ExtendedUserData(string UserName) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { vw_carrot_UserData rc = CompiledQueries.cqFindUserByName(_db, UserName); LoadUserData(rc); } }
public static int GetSimilar(Guid SiteID, Guid CategoryID, string categorySlug) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { IQueryable<carrot_ContentCategory> query = CompiledQueries.cqGetContentCategoryNoMatch(_db, SiteID, CategoryID, categorySlug); return query.Count(); } }
public ExtendedUserData(Guid UserID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { vw_carrot_UserData rc = CompiledQueries.cqFindUserByID(_db, UserID); LoadUserData(rc); } }
public static void SaveSerialized(Guid itemID, string sKey, string sData) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { bool bAdd = false; carrot_SerialCache itm = CompiledQueries.SearchSeriaCache(_db, itemID, sKey); if (itm == null) { bAdd = true; itm = new carrot_SerialCache(); itm.SerialCacheID = Guid.NewGuid(); itm.SiteID = SiteData.CurrentSiteID; itm.ItemID = itemID; itm.EditUserId = SecurityData.CurrentUserGuid; itm.KeyType = sKey; } itm.SerializedData = sData; itm.EditDate = DateTime.UtcNow; if (bAdd) { _db.carrot_SerialCaches.InsertOnSubmit(itm); } _db.SubmitChanges(); } }
public int GetSitePageCount(ContentPageType.PageType entryType) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { int iCount = CannedQueries.GetAllByTypeList(_db, this.SiteID, false, entryType).Count(); return(iCount); } }
public static bool AddUserToRole(string userName, string roleName) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { membership_Role role = (from r in _db.membership_Roles where r.Name == roleName select r).FirstOrDefault(); membership_User user = (from u in _db.membership_Users where u.UserName == userName select u).FirstOrDefault(); membership_UserRole usrRole = (from r in _db.membership_Roles join ur in _db.membership_UserRoles on r.Id equals ur.RoleId join u in _db.membership_Users on ur.UserId equals u.Id where r.Name == roleName && u.UserName == userName select ur).FirstOrDefault(); if (usrRole == null && role != null && user != null) { usrRole = new membership_UserRole(); usrRole.UserId = user.Id; usrRole.RoleId = role.Id; _db.membership_UserRoles.InsertOnSubmit(usrRole); _db.SubmitChanges(); return(true); } return(false); } }
public static List <UserProfile> GetCreditUserProfileSearch(string searchTerm) { List <UserProfile> usrs = null; List <string> admins = null; List <string> editors = null; using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { admins = (from ur in _db.membership_UserRoles join u in _db.membership_Users on ur.UserId equals u.Id join r in _db.membership_Roles on ur.RoleId equals r.Id join ud in _db.carrot_UserDatas on u.Id equals ud.UserKey where r.Name == CMSGroup_Admins select ud.UserKey.ToLower()).ToList(); editors = (from sm in _db.carrot_UserSiteMappings join ud in _db.carrot_UserDatas on sm.UserId equals ud.UserId where sm.SiteID == SiteData.CurrentSiteID select ud.UserKey.ToLower()).ToList(); usrs = (from u in _db.membership_Users join ud1 in _db.carrot_UserDatas on u.Id equals ud1.UserKey into ud2 from ud in ud2.DefaultIfEmpty() where (u.UserName.ToLower().Contains(searchTerm.ToLower()) || u.Email.ToLower().Contains(searchTerm.ToLower())) && admins.Union(editors).Contains(u.Id.ToLower()) select new UserProfile(u, ud)).Take(50).ToList(); } return(usrs); }
public static int GetHistoryListCount(Guid siteID, bool showLatestOnly, DateTime?editDate, Guid?editUserID) { Guid userID = Guid.Empty; if (editUserID.HasValue) { userID = editUserID.Value; } DateTime dateStart = DateTime.UtcNow.Date.AddDays(-2); DateTime dateEnd = DateTime.UtcNow.Date.AddDays(1); if (editDate.HasValue) { dateStart = editDate.Value.Date.AddDays(-8); dateEnd = editDate.Value.Date.AddDays(1); } using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from h in _db.vw_carrot_EditHistories where h.SiteID == siteID && (!showLatestOnly || h.IsLatestVersion == true) && (!editDate.HasValue || (h.EditDate.Date >= dateStart.Date && h.EditDate.Date <= dateEnd.Date)) && (!editUserID.HasValue || h.EditUserId == userID) select h).Count()); } }
public static List <ApplicationUser> GetCreditUserSearch(string searchTerm) { List <ApplicationUser> usrs = null; List <string> admins = null; List <string> editors = null; using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { admins = (from ur in _db.membership_UserRoles join u in _db.membership_Users on ur.UserId equals u.Id join r in _db.membership_Roles on ur.RoleId equals r.Id join ud in _db.carrot_UserDatas on u.Id equals ud.UserKey where r.Name == CMSGroup_Admins select ud.UserKey.ToLower()).ToList(); editors = (from sm in _db.carrot_UserSiteMappings join ud in _db.carrot_UserDatas on sm.UserId equals ud.UserId where sm.SiteID == SiteData.CurrentSiteID select ud.UserKey.ToLower()).ToList(); } using (var securityHelper = new SecurityHelper()) { usrs = (from u in securityHelper.DataContext.Users where (u.UserName.ToLower().Contains(searchTerm.ToLower()) || u.Email.ToLower().Contains(searchTerm.ToLower())) && admins.Union(editors).Contains(u.Id.ToLower()) select securityHelper.UserManager.FindByName(u.UserName)).Take(50).ToList(); } return(usrs); }
public bool VerifyUserHasSiteAccess(Guid siteID, Guid userID) { //all admins have rights to all sites if (SecurityData.IsAdmin) { return(true); } // if user is neither admin nor editor, they should not be in the backend of the site if (!(SecurityData.IsSiteEditor || SecurityData.IsAdmin)) { return(false); } using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { // by this point, the user is probably an editor, make sure they have rights to this site IQueryable <Guid> lstSiteIDs = (from l in _db.carrot_UserSiteMappings where l.UserId == userID && l.SiteID == siteID select l.SiteID); return(lstSiteIDs.Any()); } return(false); }
public bool AddToSite(Guid siteID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { carrot_UserSiteMapping map = (from m in _db.carrot_UserSiteMappings where m.UserId == this.UserId && m.SiteID == siteID select m).FirstOrDefault(); if (map == null) { _siteIDs = null; map = new carrot_UserSiteMapping(); map.UserSiteMappingID = Guid.NewGuid(); map.SiteID = siteID; map.UserId = this.UserId; _db.carrot_UserSiteMappings.InsertOnSubmit(map); _db.SubmitChanges(); return(true); } else { return(false); } } }
public static int GetCommentCountByContent(Guid siteID, Guid rootContentID, DateTime postDate, string postIP) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from c in CannedQueries.FindCommentsByDate(_db, siteID, rootContentID, postDate, postIP) select c).Count()); } }
public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { carrot_TextWidget s = CompiledQueries.cqTextWidgetByID(_db, this.TextWidgetID); if (s == null) { s = new carrot_TextWidget(); s.TextWidgetID = Guid.NewGuid(); s.SiteID = this.SiteID; s.TextWidgetAssembly = this.TextWidgetAssembly; _db.carrot_TextWidgets.InsertOnSubmit(s); } s.ProcessBody = this.ProcessBody; s.ProcessPlainText = this.ProcessPlainText; s.ProcessHTMLText = this.ProcessHTMLText; s.ProcessComment = this.ProcessComment; s.ProcessSnippet = this.ProcessSnippet; _db.SubmitChanges(); this.TextWidgetID = s.TextWidgetID; } }
public static int GetAllCommentCountBySite(Guid siteID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from c in CannedQueries.GetSiteContentComments(_db, siteID) select c).Count()); } }
public static int GetCommentCountBySiteAndType(Guid siteID, ContentPageType.PageType pageType, bool?approved, bool?spam) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from c in CannedQueries.GetSiteContentCommentsByPostType(_db, siteID, pageType, approved, spam) select c).Count()); } }
public static int GetCommentCountByContent(Guid rootContentID, bool?approved, bool?spam) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from c in CannedQueries.GetContentPageComments(_db, rootContentID, approved, spam) select c).Count()); } }
public static void AddUserToRole(Guid UserId, string roleName) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { membership_Role role = (from r in _db.membership_Roles where r.Name.ToLower() == roleName.ToLower() select r).FirstOrDefault(); membership_User user = (from u in _db.membership_Users join ud in _db.carrot_UserDatas on u.Id equals ud.UserKey where ud.UserId == UserId select u).FirstOrDefault(); membership_UserRole usrRole = (from r in _db.membership_Roles join ur in _db.membership_UserRoles on r.Id equals ur.RoleId join u in _db.membership_Users on ur.UserId equals u.Id join ud in _db.carrot_UserDatas on u.Id equals ud.UserKey where r.Name.ToLower() == roleName.ToLower() && ud.UserId == UserId select ur).FirstOrDefault(); if (usrRole == null && role != null && user != null) { usrRole = new membership_UserRole(); usrRole.UserId = user.Id; usrRole.RoleId = role.Id; _db.membership_UserRoles.InsertOnSubmit(usrRole); _db.SubmitChanges(); } } }
public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { bool bNew = false; carrot_UserData usr = CompiledQueries.cqFindUserTblByID(_db, this.UserId); if (usr == null) { usr = new carrot_UserData(); usr.UserKey = this.UserKey; usr.UserId = Guid.NewGuid(); bNew = true; } usr.UserNickName = this.UserNickName; usr.FirstName = this.FirstName; usr.LastName = this.LastName; usr.UserBio = this.UserBio; if (bNew) { _db.carrot_UserDatas.InsertOnSubmit(usr); } _db.SubmitChanges(); this.UserId = usr.UserId; //grab fresh copy from DB vw_carrot_UserData rc = CompiledQueries.cqFindUserByID(_db, usr.UserId); LoadUserData(rc); } }
public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { bool bNew = false; carrot_ContentTag s = CompiledQueries.cqGetContentTagByID(_db, this.ContentTagID); if (s == null || (s != null && s.ContentTagID == Guid.Empty)) { s = new carrot_ContentTag(); s.ContentTagID = Guid.NewGuid(); s.SiteID = this.SiteID; bNew = true; } s.TagSlug = ContentPageHelper.ScrubSlug(this.TagSlug); s.TagText = this.TagText; s.IsPublic = this.IsPublic; if (bNew) { _db.carrot_ContentTags.InsertOnSubmit(s); } _db.SubmitChanges(); this.ContentTagID = s.ContentTagID; } }
public static List <UserRole> GetRoleList() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from r in _db.membership_Roles orderby r.Name select new UserRole(r)).ToList()); } }
public static IQueryable <ExtendedUserData> GetUsers() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { IQueryable <ExtendedUserData> lstUsr = (from u in CompiledQueries.cqGetUserList(_db) select new ExtendedUserData(u)); return(lstUsr); } }
public static UserRole FindRole(string RoleName) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from r in _db.membership_Roles where r.Name.ToLower() == RoleName.ToLower() select new UserRole(r)).FirstOrDefault()); } }
public static UserRole FindRoleByID(string roleID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from r in _db.membership_Roles where r.Id == roleID select new UserRole(r)).FirstOrDefault()); } }
public static int GetSimilar(Guid siteID, Guid rootSnippetID, string categorySlug) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { IQueryable <vw_carrot_ContentSnippet> query = CompiledQueries.cqGetContentSnippetNoMatch(_db, siteID, rootSnippetID, categorySlug); return(query.Count()); } }
public static int GetSimilar(Guid SiteID, Guid TagID, string tagSlug) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { IQueryable <carrot_ContentTag> query = CompiledQueries.cqGetContentTagNoMatch(_db, SiteID, TagID, tagSlug); return(query.Count()); } }
public List <ContentSnippet> GetContentSnippetList() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { List <ContentSnippet> _types = (from d in CompiledQueries.cqGetSnippetsBySiteID(_db, this.SiteID) select new ContentSnippet(d)).ToList(); return(_types); } }
public List <ExtendedUserData> GetMappedUsers() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from l in _db.carrot_UserSiteMappings join u in _db.vw_carrot_UserDatas on l.UserId equals u.UserId where l.SiteID == this.SiteID select new ExtendedUserData(u)).ToList()); } }
public static List <PostComment> GetCommentsByContentPage(Guid rootContentID, bool bActiveOnly) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { IQueryable <vw_carrot_Comment> lstComments = (from c in CannedQueries.GetContentPageComments(_db, rootContentID, bActiveOnly) select c); return(lstComments.Select(x => new PostComment(x)).ToList()); } }
public static List <PostComment> GetAllCommentsBySite(Guid siteID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { IQueryable <PostComment> s = (from c in CannedQueries.GetSiteContentComments(_db, siteID) select new PostComment(c)); return(s.ToList()); } }
public List <SiteData> GetSiteList() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { return((from m in _db.carrot_UserSiteMappings join s in _db.carrot_Sites on m.SiteID equals s.SiteID where m.UserId == this.UserId select new SiteData(s)).ToList()); } }