Exemple #1
0
        public void AddRole(CriarPerfilRBACViewModel perfil)
        {
            using (NimbusAcad_DB_Entities db = new NimbusAcad_DB_Entities())
            {
                RBAC_Perfil rbacPerfil = new RBAC_Perfil();
                rbacPerfil.Perfil_Nome = perfil.PerfilNm;
                rbacPerfil.Descricao   = perfil.Descricao;

                db.RBAC_Perfil.Add(rbacPerfil);
                db.SaveChanges();
            }
        }
Exemple #2
0
        public void UpdatePerfil(CriarPerfilRBACViewModel perfil)
        {
            using (NimbusAcad_DB_Entities db = new NimbusAcad_DB_Entities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        RBAC_Perfil p = db.RBAC_Perfil.Where(o => o.Perfil_ID == perfil.PerfilID).FirstOrDefault();
                        p.Perfil_Nome = perfil.PerfilNm;
                        p.Descricao   = perfil.Descricao;

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

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