コード例 #1
0
ファイル: WebContext.cs プロジェクト: microbet/sizeup
        private void SetCurrentIndustry(Core.DataLayer.Models.Industry CurrentIndustry)
        {
            HttpCookie cookie = SizeUp.Core.Web.CookieFactory.Create("industry");

            if (CurrentIndustry == null)
            {
                cookie.Expires = DateTime.Now.AddDays(-1.0);
            }
            else
            {
                cookie.Value   = CurrentIndustry.Id.ToString();
                cookie.Expires = DateTime.Now.AddDays(7.0);
            }
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
コード例 #2
0
ファイル: WebContext.cs プロジェクト: microbet/sizeup
        private Core.DataLayer.Models.Industry GetCurrentIndustry()
        {
            var industry = (string)HttpContext.Current.Request.RequestContext.RouteData.Values["industry"];
            var cookie   = HttpContext.Current.Request.Cookies["industry"];

            Core.DataLayer.Models.Industry output = null;
            using (var context = ContextFactory.SizeUpContext)
            {
                if (!string.IsNullOrEmpty(industry))
                {
                    output = Core.DataLayer.Industry.Get(context, industry);
                }
                else if (cookie != null)
                {
                    long id;
                    if (long.TryParse(cookie.Value, out id))
                    {
                        output = Core.DataLayer.Industry.Get(context, id);
                    }
                }
            }
            return(output);
        }