コード例 #1
0
 public HttpResponseMessage Update(int id, PatrocinioModel model)
 {
     try
     {
         PatrocinioEntity patrocinio = ModelToEntity(model);
         patrocinio.Id = id;
         business.Update(patrocinio);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString()));
     }
 }
コード例 #2
0
 public PatrocinioEntity GetById(int id)
 {
     try
     {
         OpenConnection();
         using (var cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "UP_PATROCINIO_BUSCAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = Convert.ToInt32(id);
             dr = cmd.ExecuteReader();
             PatrocinioEntity patrocinio = null;
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     patrocinio = new PatrocinioEntity()
                     {
                         Id         = Convert.ToInt32(dr["ID"]),
                         Seguradora = new SeguradoraEntity()
                         {
                             Id   = Convert.ToInt32(dr["SEGURADORA_ID"]),
                             Nome = Convert.ToString(dr["SEGURADORA_NOME"]),
                             CNPJ = Convert.ToString(dr["SEGURADORA_CNPJ"])
                         },
                         Representante = new RepresentanteEntity()
                         {
                             Id   = Convert.ToInt32(dr["REPRESENTANTE_ID"]),
                             Nome = Convert.ToString(dr["REPRESENTANTE_NOME"]),
                             CNPJ = Convert.ToString(dr["REPRESENTANTE_CNPJ"])
                         }
                     };
                 }
             }
             return(patrocinio);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message.ToString());
     }
     finally
     {
         CloseConnection();
     }
 }
コード例 #3
0
 public void Insert(PatrocinioEntity patrocinio)
 {
     try
     {
         OpenConnection();
         using (var cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "UP_PATROCINIO_CADASTRAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@SEGURADORA_ID", SqlDbType.Int)).Value    = Convert.ToInt32(patrocinio.Seguradora.Id);
             cmd.Parameters.Add(new SqlParameter("@REPRESENTANTE_ID", SqlDbType.Int)).Value = Convert.ToInt32(patrocinio.Representante.Id);
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message.ToString());
     }
     finally
     {
         CloseConnection();
     }
 }
コード例 #4
0
 public void Update(PatrocinioEntity patrocinio) => repository.Update(patrocinio);
コード例 #5
0
 public void Insert(PatrocinioEntity patrocinio) => repository.Insert(patrocinio);