/// <summary>
        /// Altera TB_UNIVERSIDADE_TAG
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static void Update(string token, TB_UNIVERSIDADE_TAG param, ModelApiUnes _dbContext = null)
        {
            ModelApiUnes _db;

            if (_dbContext == null)
            {
                _db = new ModelApiUnes();
            }
            else
            {
                _db = _dbContext;
            }
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    TB_UNIVERSIDADE_TAG value = _db.TB_UNIVERSIDADE_TAG
                                                .Where(e => e.UNT_ID_TAG.Equals(param.UNT_ID_TAG))
                                                .First <TB_UNIVERSIDADE_TAG>();



                    if (param.UNT_ID_TAG != value.UNT_ID_TAG)
                    {
                        value.UNT_ID_TAG = param.UNT_ID_TAG;
                    }
                    if (param.UNT_TX_NOME != null && param.UNT_TX_NOME != value.UNT_TX_NOME)
                    {
                        value.UNT_TX_NOME = param.UNT_TX_NOME;
                    }
                    _db.SaveChanges();
                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message);
                }
                finally
                {
                    if (_dbContext == null)
                    {
                        // Fecha conexão
                        transaction.Dispose();
                        _db.Database.Connection.Close();
                        _db.Dispose();
                    }
                }
            }
        }
 public void Put(string token, [FromBody] TB_UNIVERSIDADE_TAG param)
 {
     // Abre nova conexão
     using (ModelApiUnes _db = new ModelApiUnes())
     {
         try
         {
             if (Permissoes.Autenticado(token, _db))
             {
                 GatewayTbUniversidadeTag.Update(token, param, _db);
             }
             //else
             //return new Retorno() { Token = false }; //throw new Exception("Unauthorized");
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
        /// <summary>
        /// Adiciona nova TB_UNIVERSIDADE_TAG
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static Int64 Add(string token, TB_UNIVERSIDADE_TAG param, ModelApiUnes _dbContext = null)
        {
            ModelApiUnes _db;

            if (_dbContext == null)
            {
                _db = new ModelApiUnes();
            }
            else
            {
                _db = _dbContext;
            }
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    _db.TB_UNIVERSIDADE_TAG.Add(param);
                    _db.SaveChanges();
                    transaction.Commit();
                    return(param.UNT_ID_TAG);
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message);
                }
                finally
                {
                    if (_dbContext == null)
                    {
                        // Fecha conexão
                        transaction.Dispose();
                        _db.Database.Connection.Close();
                        _db.Dispose();
                    }
                }
            }
        }
 public Int64 Post(string token, [FromBody] TB_UNIVERSIDADE_TAG param)
 {
     // Abre nova conexão
     using (ModelApiUnes _db = new ModelApiUnes())
     {
         try
         {
             if (Permissoes.Autenticado(token, _db))
             {
                 Int64 dados = GatewayTbUniversidadeTag.Add(token, param, _db);
                 return(dados);
             }
             else
             {
                 return(0);// new Retorno() { Token = false }; //throw new Exception("Unauthorized");
             }
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }