Ejemplo n.º 1
0
        public void AddPermission(CriarPermissaoRBACViewModel permissao)
        {
            using (NimbusAcad_DB_Entities db = new NimbusAcad_DB_Entities())
            {
                RBAC_Permissao rbacPermissao = new RBAC_Permissao();
                rbacPermissao.Permissao_Nome = permissao.PermissaoNm;

                db.RBAC_Permissao.Add(rbacPermissao);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void UpdatePermissao(CriarPermissaoRBACViewModel permissao)
        {
            using (NimbusAcad_DB_Entities db = new NimbusAcad_DB_Entities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        RBAC_Permissao p = db.RBAC_Permissao.Where(o => o.Permissao_ID == permissao.PermissaoID).FirstOrDefault();
                        p.Permissao_Nome = permissao.PermissaoNm;

                        db.Entry(p).State = EntityState.Modified;
                        db.SaveChanges();

                        dbContextTransaction.Commit();
                    }
                    catch
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
        }