示例#1
0
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     if (HelperController.CheckLogin(HttpContext.Session))
     {
         ViewBag.Login = true;
         base.OnActionExecuting(context);
     }
 }
示例#2
0
 public override IActionResult Index()
 {
     if (!HelperController.CheckLogin(HttpContext.Session))
     {
         ViewBag.Operacao = "I";
         UsersViewModel model = new UsersViewModel();
         return(View("Form", model));
     }
     else
     {
         var list = DAO.List();
         return(View(list));
     }
 }
示例#3
0
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     //if (!HelperController.CheckRegister(HttpContext.Session))
     //    context.Result = RedirectToAction("Create", "Users");
     if (!HelperController.CheckLogin(HttpContext.Session))
     {
         context.Result = RedirectToAction("Create", "Users");
     }
     else
     {
         ViewBag.Login = true;
         base.OnActionExecuting(context);
     }
 }
示例#4
0
        public IActionResult Save(T model, string Operation)
        {
            PopCombos();
            try
            {
                ValidateData(model, Operation);
                if (ModelState.IsValid == false)
                {
                    ViewBag.Operacao = Operation;
                    return(View("Form", model));
                }
                else
                {
                    if (Operation == "I")
                    {
                        DAO.Insert(model);

                        if (!HelperController.CheckLogin(HttpContext.Session))
                        {
                            HttpContext.Session.SetString("Login", "true");
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        DAO.Update(model);
                    }

                    return(RedirectToAction("index"));
                }
            }
            catch (Exception erro)
            {
                ViewBag.Erro     = "Ocorreu um erro: " + erro.Message;
                ViewBag.Operacao = Operation;
                return(View("Form", model));
            }
        }
示例#5
0
 public IActionResult Index()
 {
     ViewBag.Login = HelperController.CheckLogin(HttpContext.Session);
     return(View());
 }