Ejemplo n.º 1
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var _Controlador = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
            var _Action      = HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString();
            var token        = HttpContext.Current.Request.Cookies["token"];
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            var obj = HttpContext.Current.Request.Cookies["token"] != null?
                      json_serializer.Deserialize <Usuario>(ctx.DecryptText(HttpContext.Current.Request.Cookies["token"].Value)) :
                          null;

            if (_Controlador == "Empresa" && _Action == "Index" && (obj.perfil != null && obj.perfil.adm != "s"))
            {
                filterContext.Result = new RedirectResult("~/Home/Index");
            }
            if (_Controlador == "Servico" && _Action == "Index" && (obj.perfil != null && obj.perfil.adm != "s"))
            {
                filterContext.Result = new RedirectResult("~/Home/Index");
            }
            if (_Controlador == "Usuario" && _Action == "Index" && (obj.perfil != null && obj.perfil.adm != "s"))
            {
                filterContext.Result = new RedirectResult("~/Home/Index");
            }
            if (_Controlador == "Transacao" && _Action == "Faturamento" && (obj.perfil != null && obj.perfil.adm != "s"))
            {
                filterContext.Result = new RedirectResult("~/Home/Index");
            }
            if (token == null && _Controlador != "Login" && _Action == "Index")
            {
                filterContext.Result = new RedirectResult("~/Login/Index");
            }
        }
Ejemplo n.º 2
0
        public void Salvar(Transacao t)
        {
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            UsuarioCtx           Uctx            = new UsuarioCtx();

            t.empresa_contratante    = new Empresa();
            t.empresa_contratante.id = json_serializer
                                       .Deserialize <Usuario>(Uctx.DecryptText(Request.Cookies["token"].Value))
                                       .empresa.id;
            ctx.Salvar(t);
        }
Ejemplo n.º 3
0
        public JsonResult getTransacoes()
        {
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            UsuarioCtx           Uctx            = new UsuarioCtx();
            var objToken = json_serializer
                           .Deserialize <Usuario>(Uctx.DecryptText(Request.Cookies["token"].Value));
            int idEmpresa = Request.Cookies["token"] == null ||
                            objToken.empresa == null ? 0
                            : objToken.empresa.id;

            if (idEmpresa != 0 && objToken.perfil.analista != "s" && objToken.perfil.adm != "s")
            {
                return(Json(ctx.getTransacaoAll().Where(x => x.empresa_contratante.id == idEmpresa), JsonRequestBehavior.AllowGet));
            }
            return(Json(ctx.getTransacaoAll(), JsonRequestBehavior.AllowGet));
        }