package demojsoncrud.services;

import demojsoncrud.dao.DAOFactory;
import demojsoncrud.dao.UbigeoDAO;
import org.json.JSONObject;

public class UbigeoService {

  DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.SQL_SERVER);
  UbigeoDAO dao = daoFactory.getUbigeoDAO();

  public JSONObject listarDepartamento() {
    JSONObject jsonReturn = null;
    try {
      jsonReturn = dao.listarDepartamento();
    } catch (Exception e) {
      System.out.println("Error UbigeoService >> listarDepartamento >> " + e.getMessage());
    }
    return jsonReturn;
  }

  public JSONObject listarProvincia(JSONObject datos) {
    JSONObject jsonReturn = null;
    try {
      jsonReturn = dao.listarProvincia(datos);
    } catch (Exception e) {
      System.out.println("Error UbigeoService >> listarProvincia >> " + e.getMessage());
    }
    return jsonReturn;
  }

  public JSONObject listarDistrito(JSONObject datos) {
    JSONObject jsonReturn = null;
    try {
      jsonReturn = dao.listarDistrito(datos);
    } catch (Exception e) {
      System.out.println("Error UbigeoService >> listarDistrito >> " + e.getMessage());
    }
    return jsonReturn;
  }

}
