Esempio n. 1
0
 public IHttpActionResult PublicInsert(Producto_Compra producto)
 {
     if (producto == null)
     {
         return(BadRequest());
     }
     if (PrivateInsert(producto))
     {
         return(Ok());
     }
     else
     {
         return(InternalServerError());
     }
 }
Esempio n. 2
0
 private bool PrivateInsert(Producto_Compra producto)
 {
     using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Tienda"].ConnectionString))
     {
         SqlCommand sqlCommand = new SqlCommand(@"INSERT INTO PRODUCTO_COMPRA(COM_ID,PRO_ID,COM_PRO_CANTIDAD,CM_PRECIO_PRODUCTO_UNIDAD) VALUES(@COM_ID,@PRO_ID,@COM_PRO_CANTIDAD,@CM_PRECIO_PRODUCTO_UNIDAD);", sqlConnection);
         sqlCommand.Parameters.AddWithValue("@COM_ID", producto.COM_ID);
         sqlCommand.Parameters.AddWithValue("@PRO_ID", producto.PRO_ID);
         sqlCommand.Parameters.AddWithValue("@COM_PRO_CANTIDAD", producto.COM_PRO_CANTIDAD);
         sqlCommand.Parameters.AddWithValue("@CM_PRECIO_PRODUCTO_UNIDAD", producto.CM_PRECIO_PRODUCTO_UNIDAD);
         sqlConnection.Open();
         int filasAfectadas = sqlCommand.ExecuteNonQuery();
         sqlConnection.Close();
         if (filasAfectadas > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 3
0
 public bool PrivateUpdate(Producto_Compra producto)
 {
     using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Tienda"].ConnectionString))
     {
         SqlCommand sqlCommand = new SqlCommand(@"UPDATE PRODUCTO_COMPRA SET COM_ID=@COM_ID,PRO_ID=@PRO_ID,COM_PRO_CANTIDAD=@COM_PRO_CANTIDAD WHERE CM_ID=@ID;", sqlConnection);
         sqlCommand.Parameters.AddWithValue("@ID", producto.CM_ID);
         sqlCommand.Parameters.AddWithValue("@COM_ID", producto.COM_ID);
         sqlCommand.Parameters.AddWithValue("@PRO_ID", producto.PRO_ID);
         sqlCommand.Parameters.AddWithValue("@COM_PRO_CANTIDAD", producto.COM_PRO_CANTIDAD);
         sqlConnection.Open();
         int filasAfectadas = sqlCommand.ExecuteNonQuery();
         sqlConnection.Close();
         if (filasAfectadas > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 4
0
 public async Task Insertar(Producto_Compra producto_Compra, string token)
 {
     HttpClient client = GetClient(token);
     await client.PostAsync(URLInsertar, new StringContent(JsonConvert.SerializeObject(producto_Compra), Encoding.UTF8, "application/json"));
 }