コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idRol"></param>
        /// <param name="dirView"></param>
        /// <param name="todas">0 = NA, 1 = Permitir Todas, 2 = Denegar Todas</param>
        /// <param name="httpContext"></param>
        /// <returns></returns>
        public virtual async Task CrearRolViewPermit(string idRol, string dirView, byte todas, HttpContextBase httpContext)
        {
            IdentityRole rol = await this.GetIdentityRole(idRol);

            if (rol != null)
            {
                if (string.IsNullOrEmpty(dirView))
                {
                    QueryExpresion expr = new QueryExpresion(SqlUtil.Equals("IdRol", "@idRol")).And($"{SqlUtil.Equals("All", "@all1")} {SqlUtil.OR} {SqlUtil.Equals("All", "@all2")}");
                    DataConnection.Instance.ExecuteNonQuery(string.Format("DELETE FROM `tblRolView` WHERE {0}", expr.ToString()), new Dictionary <string, object>()
                    {
                        { "@idRol", idRol }, { "@all1", 1 }, { "@all2", 2 }
                    }, httpContext);
                }
                if (todas != 0 || !string.IsNullOrEmpty(dirView))
                {
                    DataConnection.Instance.ExecuteNonQuery("INSERT INTO `tblRolView` (`View`, `IdRol`, `All`) VALUES (@view, @idRol, @all)", new Dictionary <string, object>()
                    {
                        { "@view", todas != 0 ? "*" : dirView }, { "@idRol", idRol }, { "@all", todas }
                    }, httpContext);
                }
                //this.RemoveValueIfExists(this.GetOrCreateKey(httpContext), "GetViewsPermitidas");
                await this.RemoverCache(httpContext);
            }
            else
            {
                throw new Exception("Rol no existe");
            }
        }
コード例 #2
0
        public virtual async Task <List <IdentityRolPermit> > GetViewsPermitidas(string idRol, HttpContextBase httpContext)
        {
            List <IdentityRolPermit> read = new List <IdentityRolPermit>();
            QueryExpresion           expr = new QueryExpresion(SqlUtil.Equals("IdRol", idRol, true));

            read = this.GetOrCreateValue <List <IdentityRolPermit> >(
                this.GetOrCreateKey(httpContext),
                () => this.FillVistasDeRol(DataConnection.Instance.ExecuteQuery(
                                               string.Format(SqlResource.SqlRolesVistasPermitidasByRol, expr.ToString()),
                                               new Dictionary <string, object>()
            {
                { "@id", idRol }
            },
                                               httpContext,
                                               1))
                , "GetViewsPermitidas", expr?.ToString()
                );
            return(read);
        }
コード例 #3
0
        public virtual async Task EliminarRolView(string idRol, long idView, HttpContextBase httpContext)
        {
            IdentityRole rol = await this.GetIdentityRole(idRol);

            if (rol != null)
            {
                QueryExpresion expr = new QueryExpresion(SqlUtil.Equals("IdRol", "@idRol")).And(SqlUtil.Equals("ID", "@idView"));

                DataConnection.Instance.ExecuteNonQuery(string.Format("DELETE FROM `tblRolView` WHERE {0}", expr.ToString()), new Dictionary <string, object>()
                {
                    { "@idRol", idRol }, { "@idView", idView }
                }, httpContext);

                //this.RemoveValueIfExists(this.GetOrCreateKey(httpContext), "GetViewsPermitidas");
                await this.RemoverCache(httpContext);
            }
            else
            {
                throw new Exception("Rol no existe");
            }
        }