コード例 #1
0
        public static ShowcaseUser GetByID(int ShowcaseUserID, IEnumerable <string> includeList = null)
        {
            ShowcaseUser obj = null;
            string       key = cacheKeyPrefix + ShowcaseUserID + GetCacheIncludeText(includeList);

            ShowcaseUser tmpClass = null;

            if (Cache.IsEnabled)
            {
                if (Cache.IsEmptyCacheItem(key))
                {
                    return(null);
                }
                tmpClass = Cache[key] as ShowcaseUser;
            }

            if (tmpClass != null)
            {
                obj = tmpClass;
            }
            else
            {
                using (Entities entity = new Entities())
                {
                    IQueryable <ShowcaseUser> itemQuery = AddIncludes(entity.ShowcaseUser, includeList);
                    obj = itemQuery.FirstOrDefault(n => n.ShowcaseUserID == ShowcaseUserID);
                }
                Cache.Store(key, obj);
            }

            return(obj);
        }
コード例 #2
0
        public static bool UserCanManageOtherShowcases()
        {
            bool   returnValue;
            bool?  tmpValue = null;
            int    userID   = Helpers.GetCurrentUserID();
            string key      = "Showcase_UserCanManageOtherShowcases_" + userID;

            if (Cache.IsEnabled)
            {
                tmpValue = Cache[key] as bool?;
            }

            if (tmpValue != null)
            {
                returnValue = tmpValue.Value;
            }
            else
            {
                returnValue = IsShowcaseAdmin() || ShowcaseUser.ShowcaseUserGetByUserID(userID).Count > 1;

                Cache.Store(key, returnValue);
            }

            return(returnValue);
        }
コード例 #3
0
 public ShowcaseUser(ShowcaseUser objectToCopy)
 {
     ShowcaseID     = objectToCopy.ShowcaseID;
     ShowcaseUserID = objectToCopy.ShowcaseUserID;
     UserID         = objectToCopy.UserID;
 }
コード例 #4
0
        public static int?GetCurrentShowcaseID(HttpContext requestContext = null)
        {
            if (requestContext == null)
            {
                requestContext = HttpContext.Current;
            }
            if (requestContext == null || requestContext.Items["CurrentShowcaseID"] == "null")
            {
                return(null);
            }
            if (requestContext.Items["CurrentShowcaseID"] == null)
            {
                //Frontend Check
                if (!HttpContext.Current.Request.Path.ToLower().Contains("admin/"))
                {
                    if (Settings.MultipleShowcases)
                    {
                        HttpRequest currentRequest = HttpContext.Current.Request;
                        int         temp           = 0;
                        if (currentRequest.RawUrl.ToLower().Contains("showcasewebmethods.asmx") && currentRequest.UrlReferrer != null ? !String.IsNullOrEmpty(HttpUtility.ParseQueryString(currentRequest.UrlReferrer.Query)["ShowcaseID"]) && Int32.TryParse(HttpUtility.ParseQueryString(currentRequest.UrlReferrer.Query)["ShowcaseID"], out temp) : !String.IsNullOrEmpty(currentRequest.QueryString["ShowcaseID"]) && Int32.TryParse(currentRequest.QueryString["ShowcaseID"], out temp))
                        {
                            Showcases showcaseEntity = Showcases.GetByID(temp);
                            if (showcaseEntity != null && showcaseEntity.Active)
                            {
                                requestContext.Items["CurrentShowcaseID"] = temp;
                                return(temp);
                            }
                        }
                        else if (currentRequest.RawUrl.ToLower().Contains("showcase-item.aspx") && !String.IsNullOrEmpty(currentRequest.QueryString["ID"]) && Int32.TryParse(currentRequest.QueryString["ID"], out temp))
                        {
                            Showcases showcaseEntity = Showcases.GetByID(ShowcaseItem.GetByID(temp).ShowcaseID);
                            if (showcaseEntity != null && showcaseEntity.Active)
                            {
                                requestContext.Items["CurrentShowcaseID"] = showcaseEntity.ShowcaseID;
                                return(showcaseEntity.ShowcaseID);
                            }
                        }
                    }
                    requestContext.Items["CurrentShowcaseID"] = GetDefaultShowcaseID();
                    return(GetDefaultShowcaseID());
                }
                //Backend Check
                if (Settings.MultipleShowcases)
                {
                    int showcaseID;
                    if (HttpContext.Current.Session != null && HttpContext.Current.Session["ShowcaseID"] != null && Int32.TryParse(HttpContext.Current.Session["ShowcaseID"].ToString(), out showcaseID))
                    {
                        if (Showcases.GetByID(showcaseID) == null || (!IsShowcaseAdmin() && !ShowcaseUser.ShowcaseUserGetByShowcaseID(showcaseID).Exists(s => s.UserID == Helpers.GetCurrentUserID())))
                        {
                            HttpContext.Current.Session.Remove("ShowcaseID");
                            return(null);
                        }
                        requestContext.Items["CurrentShowcaseID"] = showcaseID;
                        return(showcaseID);
                    }
                    return(null);
                }
                int?defaultID = GetDefaultShowcaseID();
                if (defaultID != null)
                {
                    SetUsersCurrentShowcaseID(defaultID.Value);
                    requestContext.Items["CurrentShowcaseID"] = defaultID;
                    return(defaultID);
                }
                if (requestContext.Items["CurrentShowcaseID"] == null)
                {
                    requestContext.Items["CurrentShowcaseID"] = 0;
                }
            }

            return(Convert.ToInt32(requestContext.Items["CurrentShowcaseID"]));
        }