public ActionResult LogIn(AccountViewModel avm)
        {
            AccountModel am = new AccountModel();
            if (string.IsNullOrEmpty(avm.Account.Username) || string.IsNullOrEmpty(avm.Account.Password) || am.Login(avm.Account.Username, avm.Account.Password) == null)
            {
                ViewBag.Error = "Tài khoản không hợp lệ";
                return View("Index");
            }

            SessionPersister.Username = avm.Account.Username;
            Session["Account"] = am.Login(avm.Account.Username, avm.Account.Password) ;
            return RedirectToAction("Index", "Banner");
            //return View("Success");
        }
 public override void OnAuthorization(AuthorizationContext filterContext)
 {
     if (string.IsNullOrEmpty(SessionPersister.Username))
     {
         filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Account", action = "Index" }));
     }
     else
     {
         AccountModel am = new AccountModel();
         CustomPrincipal mp = new CustomPrincipal(am.Find(SessionPersister.Username));
         if (!mp.IsInRole(Roles))
         {
             filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }));
         }
     }
 }