Example #1
0
  @Transactional
  public static Result pesquisarAnuncio() {
    DynamicForm pesquisarForm = Form.form().bindFromRequest();
    List<Anuncio> result = null;
    if (pesquisarForm.get("optradio").equals("1")) {
      result = dao.findByAttributeName("Anuncio", "nome", pesquisarForm.get("pesquisa"));
    } else if (pesquisarForm.get("optradio").equals("2")) {
      result = dao.findByAttributeInstumento(pesquisarForm.get("pesquisa"));
    } else if (pesquisarForm.get("optradio").equals("3")) {
      result = dao.findByAttributeEstilo(pesquisarForm.get("pesquisa"));
    } else if (pesquisarForm.get("optradio").equals("4")) {
      if (pesquisarForm.get("objetivo").equals("Tocar Ocasionalmente")) {
        result = dao.findByAttributeName("Anuncio", "objetivo", "Tocar Ocasionalmente");
      } else if (pesquisarForm.get("objetivo").equals("Procuro Banda")) {
        result = dao.findByAttributeName("Anuncio", "objetivo", "Procuro Banda");
      } else if (pesquisarForm.get("objetivo").equals("Procuro musico")) {
        result = dao.findByAttributeName("Anuncio", "objetivo", "Procuro musico");
      }
    } else if (pesquisarForm.get("optradio").equals("5")) {
      result = dao.findByAttributeName("Anuncio", "objetivo", "Procuro Banda");
    } else if (pesquisarForm.get("optradio").equals("6")) {
      result = dao.findByAttributeName("Anuncio", "objetivo", "Procuro musico");
    }
    if (result == null) {
      return redirect(routes.Application.anuncios());
    }

    return ok(views.html.pesquisar.render(result));
  }