public static Showcases GetByID(int ShowcaseID, IEnumerable <string> includeList = null)
        {
            Showcases obj = null;
            string    key = cacheKeyPrefix + ShowcaseID + GetCacheIncludeText(includeList);

            Showcases tmpClass = null;

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

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

            return(obj);
        }
 public Showcases(Showcases objectToCopy)
 {
     Active        = objectToCopy.Active;
     CMMicrositeID = objectToCopy.CMMicrositeID;
     MLSData       = objectToCopy.MLSData;
     ShowcaseID    = objectToCopy.ShowcaseID;
     Title         = objectToCopy.Title;
 }
Example #3
0
        public static bool IsCurrentShowcaseMLS()
        {
            int?showcaseID = GetCurrentShowcaseID();

            if (!showcaseID.HasValue)
            {
                return(false);
            }
            return(Showcases.GetByID(showcaseID.Value).MLSData);
        }
Example #4
0
        public static int?GetDefaultShowcaseID()
        {
            int?   obj = null;
            string key = "Showcase_DefaultShowcaseID";

            int?tmpClass = null;

            if (Cache.IsEnabled)
            {
                tmpClass = Cache[key] as int?;
            }

            if (tmpClass != null)
            {
                obj = tmpClass;
            }
            else
            {
                Showcases showcaseEntity = Showcases.GetAll().OrderBy(s => s.ShowcaseID).FirstOrDefault();
                if (showcaseEntity != null)
                {
                    obj = showcaseEntity.ShowcaseID;
                }
                else if (!Settings.MultipleShowcases)
                {
                    showcaseEntity = new Showcases {
                        Active = true, Title = "Default Showcase"
                    };
                    showcaseEntity.Save();
                    obj = showcaseEntity.ShowcaseID;
                }

                Cache.Store(key, obj);
            }

            return(obj);
        }
Example #5
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"]));
        }