Beispiel #1
0
 public ActionResult Dashboard()
 {
     string user_id = HttpContext.User.Identity.Name;
     UserManager userMgr = new UserManager(int.Parse(user_id), null);
     BUser user = userMgr.CurrentUser;
     ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr);
     BShopStatistic statistic = shopManager.GetShopStatistic(0, true);
     return View(statistic);
 }
Beispiel #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            string user_id = filterContext.HttpContext.User.Identity.Name;
            if (string.IsNullOrEmpty(user_id))
            {
                return;
            }
            //Verify if the cookie user is a valid user
            UserManagement userManagement = new UserManagement();
            BUser loginuser = userManagement.GetUserInfo(int.Parse(user_id));
            if (loginuser == null)
            {
                return;
            }

            if (!loginuser.IsSystemUser)
            {
                //normal user login
                UserManager userMgr = new UserManager(int.Parse(user_id), null);
                BUser user = userMgr.CurrentUser;
                ShopManager shopManager = new ShopManager(user, userMgr.Shop, userMgr.CurrentUserPermission, userMgr);
                filterContext.Controller.ViewData["CurrentShop"] = userMgr.Shop;
                filterContext.Controller.ViewData["MainShop"] = userMgr.Main_Shop;
                filterContext.Controller.ViewData["ChildShop"] = userMgr.ChildShops;
                filterContext.Controller.ViewData["CurrentPermission"] = userMgr.CurrentUserPermission;
                filterContext.Controller.ViewData["CurrentUser"] = userMgr.CurrentUser;
                filterContext.Controller.ViewData["SPStatistic"] = shopManager.GetShopStatistic(0, true);
            }
            else
            {
                //system user login
                //filterContext.HttpContext.Response.Redirect("/Admin/Index");
                filterContext.Controller.ViewData["CurrentUser"] = loginuser;
            }
        }