public bool IsAdmin(MerchantTribeApplication app)
        {
            // don't check more than once per request
            if (_adminResult.HasValue)
            {
                return(_adminResult.Value);
            }

            try
            {
                if (System.Web.HttpContext.Current == null)
                {
                    return(false);
                }
                if (System.Web.HttpContext.Current.Request == null)
                {
                    return(false);
                }
                if (System.Web.HttpContext.Current.Request.RequestContext == null)
                {
                    return(false);
                }
                if (System.Web.HttpContext.Current.Request.RequestContext.HttpContext == null)
                {
                    return(false);
                }


                Guid?tokenId = MerchantTribe.Web.Cookies.GetCookieGuid(WebAppSettings.CookieNameAuthenticationTokenAdmin(app.CurrentStore.Id),
                                                                       System.Web.HttpContext.Current.Request.RequestContext.HttpContext, new EventLog());

                // no token, return
                if (!tokenId.HasValue)
                {
                    return(false);
                }


                Accounts.AccountService accountServices = Accounts.AccountService.InstantiateForDatabase(this);

                if (accountServices.IsTokenValidForStore(CurrentStore.Id, tokenId.Value))
                {
                    _adminResult      = true;
                    _adminAuthTokenId = tokenId.Value;
                    return(true);
                }
            }
            catch
            {
                return(false);
            }

            return(false);
        }
        public Accounts.UserAccount CurrentAdministrator(MerchantTribeApplication app)
        {
            if (!IsAdmin(app))
            {
                return(null);
            }
            Accounts.AccountService accountServices = Accounts.AccountService.InstantiateForDatabase(this);
            Accounts.UserAccount    admin           = accountServices.FindAdminUserByAuthTokenId(_adminAuthTokenId.Value);

            if (admin == null)
            {
                return(null);
            }
            if (admin.Id < 1)
            {
                return(null);
            }

            return(admin);
        }