package demojsoncrud.services;

import demojsoncrud.beans.PersonaBean;
import demojsoncrud.dao.DAOFactory;
import demojsoncrud.dao.PersonaDAO;
import org.json.JSONObject;

public class PersonaService {

    DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.SQL_SERVER);
    PersonaDAO service = daoFactory.getPersonaDAO();

    public JSONObject listarPersonaTest() {
        JSONObject jsonReturn = null;
        try {
            jsonReturn = service.listarPersonaTest();
        } catch (Exception e) {
            e.getMessage();
        }
        return jsonReturn;
    }

    public JSONObject listarPersona(String search, String draw, String start, String length) {
        JSONObject jsonReturn = null;
        try {
            jsonReturn = service.listarPersona(search, draw, start, length);
        } catch (Exception e) {
            e.getMessage();
        }
        return jsonReturn;
    }

    public JSONObject registrarPersona(PersonaBean bean) {
        JSONObject jsonReturn = null;
        try {
            jsonReturn = service.registrarPersona(bean);
        } catch (Exception e) {
            e.getMessage();
        }
        return jsonReturn;
    }

    public JSONObject editarPersona(PersonaBean bean) {
        JSONObject jsonReturn = null;
        try {
            jsonReturn = service.editarPersona(bean);
        } catch (Exception e) {
            e.getMessage();
        }
        return jsonReturn;
    }

    public JSONObject activarPersona(PersonaBean bean) {
        JSONObject jsonReturn = null;
        try {
            jsonReturn = service.activarPersona(bean);
        } catch (Exception e) {
        }
        return jsonReturn;
    }

    public JSONObject desactivarPersona(PersonaBean bean) {
        JSONObject jsonReturn = null;
        try {
            jsonReturn = service.desactivarPersona(bean);
        } catch (Exception e) {
        }
        return jsonReturn;
    }

}
