예제 #1
0
 public bool newEjercicio(EjercicioModel _ejercicio)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareQuery(
             "insert into Ejercicios " +
             "values ('" + _ejercicio.nombre + "', '" + _ejercicio.tipo + "', '" + _ejercicio.urlEjemplo + "', '" + _ejercicio.tiempo +
             "', '" + _ejercicio.repeticiones + "', '" + _ejercicio.comentarios + "', '" + _ejercicio.intensidad +
             "', '" + _ejercicio.idPersona + "', '" + _ejercicio.idRutina + "')");
         if (data.sendStatement() == false)
         {
             return(false);
         }
         if (data.getAffectedRows() <= 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public bool updatePersonaByIdAndDNI(personaModel _persona, int _oldDNI, long _oldID)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareQuery("" +
                           "update Personas " +
                           "set nombre = '" + _persona.nombre + "', apellido = '" + _persona.apellido + "', dni = '" + _persona.dni + "'" +
                           ", fechaNacimiento = '" + _persona.fechaNacimiento + "' " +
                           "where dni = '" + _oldDNI + "' and id = '" + _oldID + "';");
         data.sendStatement();
         if (data.getAffectedRows() <= 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void newPersona(personaModel persona)
        {
            try
            {
                DDBBGateway data = new DDBBGateway();
                data.prepareQuery(
                    "insert into Personas values (" +
                    "'" + persona.nombre + "', " +
                    "'" + persona.apellido + "', " +
                    "'" + persona.dni + "', " +
                    "'" + persona.fechaNacimiento.ToUniversalTime() + "');");
                data.sendStatement();

                personaService pServ = new personaService();
                persona.id             = pServ.getLastPersonaID();
                persona.user.idPersona = persona.id;

                userService uServ = new userService();
                uServ.newUsuario(persona.user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void newUsuario(usuarioModel user)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareQuery(
             "insert into Usuarios values (" +
             "'" + user.idPersona + "', '" + user.mail + "', '" + user.password + "', '" + user.profile + "')");
         data.sendStatement();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #5
0
 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;
            }
        }
 public bool newEntrenamiento(EntrenamientoModel _entrenamiento)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareQuery(
             "insert into Entrenamientos " +
             "values ('" + _entrenamiento.idPersona + "', '" + _entrenamiento.descripcion + "', '" + _entrenamiento.nombre + "')");
         data.sendStatement();
         if (data.getAffectedRows() <= 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public bool updateEntrenamiento(EntrenamientoModel _entrenamiento)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareQuery(
             "update Entrenamientos" +
             " set descripcion = '" + _entrenamiento.descripcion + "', nombre = '" + _entrenamiento.nombre + "' " +
             "where id = '" + _entrenamiento.id + "'");
         data.sendStatement();
         if (data.getAffectedRows() <= 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public bool updateUsuarioByID(usuarioModel _user)
 {
     try
     {
         DDBBGateway data = new DDBBGateway();
         data.prepareQuery(
             "update Usuarios " +
             "set mail = '" + _user.mail + "', password = '******', profile = '" + _user.profile + "' " +
             "where id = '" + _user.id + "'");
         data.sendStatement();
         if (data.getAffectedRows() <= 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }