Esempio n. 1
0
 public void Update(SeguradoraEntity seguradora)
 {
     try
     {
         OpenConnection();
         using (var cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "UP_SEGURADORA_ATUALIZAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value          = Convert.ToInt32(seguradora.Id);
             cmd.Parameters.Add(new SqlParameter("@NOME", SqlDbType.VarChar)).Value    = (string.IsNullOrEmpty(seguradora.Nome)) ? Convert.DBNull : Convert.ToString(seguradora.Nome).Trim();
             cmd.Parameters.Add(new SqlParameter("@CNPJ", SqlDbType.VarChar)).Value    = (string.IsNullOrEmpty(seguradora.CNPJ)) ? Convert.DBNull : Convert.ToString(seguradora.CNPJ).Trim();
             cmd.Parameters.Add(new SqlParameter("@ANTECIPACAO", SqlDbType.Bit)).Value = Convert.ToBoolean(seguradora.Antecipacao);
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message.ToString());
     }
     finally
     {
         CloseConnection();
     }
 }
Esempio n. 2
0
 public HttpResponseMessage Update(int id, SeguradoraModel seguradora)
 {
     try
     {
         SeguradoraEntity entity = ModelToEntity(seguradora);
         entity.Id = id;
         business.Update(entity);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString()));
     }
 }
Esempio n. 3
0
 public SeguradoraEntity GetById(int id)
 {
     try
     {
         OpenConnection();
         using (cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "UP_SEGURADORA_BUSCAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = id;
             dr = cmd.ExecuteReader();
             SeguradoraEntity seguradora = null;
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     seguradora = new SeguradoraEntity()
                     {
                         Id          = Convert.ToInt32(dr["ID"]),
                         Nome        = Convert.ToString(dr["NOME"]),
                         CNPJ        = Convert.ToString(dr["CNPJ"]),
                         Ativo       = Convert.ToBoolean(dr["Ativo"]),
                         Antecipacao = Convert.ToBoolean(dr["ANTECIPACAO"])
                     };
                 }
             }
             return(seguradora);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message.ToString());
     }
     finally
     {
         CloseConnection();
     }
 }
Esempio n. 4
0
 public void Insert(SeguradoraEntity seguradora)
 {
     try
     {
         OpenConnection();
         using (var cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "UP_SEGURADORA_CADASTRAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@NOME", SqlDbType.VarChar)).Value    = seguradora.Nome;
             cmd.Parameters.Add(new SqlParameter("@CNPJ", SqlDbType.VarChar)).Value    = seguradora.CNPJ;
             cmd.Parameters.Add(new SqlParameter("@ANTECIPACAO", SqlDbType.Bit)).Value = Convert.ToBoolean(seguradora.Antecipacao);
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         CloseConnection();
     }
 }
Esempio n. 5
0
 public void Update(SeguradoraEntity seguradora) => repository.Update(seguradora);
Esempio n. 6
0
 public void Insert(SeguradoraEntity seguradora) => repository.Insert(seguradora);