public void deleteEjerciciosByIds(List <long> idsEjericios) { try { for (int i = 0; i < idsEjericios.Count; i++) { DDBBGateway data = new DDBBGateway(); data.prepareStatement( "delete from Ejercicios " + "where Ejercicios.id = '" + idsEjericios[i] + "'"); data.sendStatement(); data.closeConnection(); } } catch (Exception ex) { throw ex; } }
public bool deleteEntrenamiento(EntrenamientoModel _entrenamiento) { try { //Primero, obtengo la lista de rutinas a eliminar a partir del id de entrenamiento List <long> listaRutinas = new List <long>(); RutinaService rServ = new RutinaService(); listaRutinas = rServ.getRutinasByEntrenamientoId(_entrenamiento); //Ahora, obtengo la lista de ejercicios a eliminar a partir de los id de rutinas List <long> listaEjercicios = new List <long>(); EjercicioService eServ = new EjercicioService(); listaEjercicios = eServ.getIdEjerciciosByRutinaID(listaRutinas); if (listaEjercicios.Count > 0) { eServ.deleteEjerciciosByIds(listaEjercicios); } if (listaRutinas.Count > 0) { rServ.deleteRutinasByIds(listaRutinas); } DDBBGateway data = new DDBBGateway(); data.prepareStatement( "delete from Entrenamientos" + " where Entrenamientos.id = '" + _entrenamiento.id + "'"); data.sendStatement(); return(true); } catch (Exception ex) { throw ex; } }