Search in sources :

Example 6 with Path

use of br.com.caelum.vraptor.Path in project agiletickets by caelum.

the class EspetaculosController method sessoes.

@Get
@Path("/espetaculo/{espetaculoId}/sessoes")
public void sessoes(Long espetaculoId) {
    Espetaculo espetaculo = carregaEspetaculo(espetaculoId);
    result.include("espetaculo", espetaculo);
}
Also used : Espetaculo(br.com.caelum.agiletickets.models.Espetaculo) Path(br.com.caelum.vraptor.Path) Get(br.com.caelum.vraptor.Get)

Example 7 with Path

use of br.com.caelum.vraptor.Path in project agiletickets by caelum.

the class EspetaculosController method sessao.

@Get
@Path("/sessao/{id}")
public void sessao(Long id) {
    Sessao sessao = agenda.sessao(id);
    if (sessao == null) {
        result.notFound();
    }
    result.include("sessao", sessao);
}
Also used : Sessao(br.com.caelum.agiletickets.models.Sessao) Path(br.com.caelum.vraptor.Path) Get(br.com.caelum.vraptor.Get)

Example 8 with Path

use of br.com.caelum.vraptor.Path in project agiletickets by caelum.

the class EspetaculosController method reserva.

@Post
@Path("/sessao/{sessaoId}/reserva")
public void reserva(Long sessaoId, final Integer quantidade) {
    Sessao sessao = agenda.sessao(sessaoId);
    if (sessao == null) {
        result.notFound();
        return;
    }
    if (quantidade < 1) {
        validator.add(new ValidationMessage("Você deve escolher um lugar ou mais", ""));
    }
    if (!sessao.podeReservar(quantidade)) {
        validator.add(new ValidationMessage("Não existem ingressos disponíveis", ""));
    }
    // em caso de erro, redireciona para a lista de sessao
    validator.onErrorRedirectTo(this).sessao(sessao.getId());
    BigDecimal precoTotal = CalculadoraDePrecos.calcula(sessao, quantidade);
    sessao.reserva(quantidade);
    result.include("message", "Sessão reservada com sucesso por " + CURRENCY.format(precoTotal));
    result.redirectTo(IndexController.class).index();
}
Also used : ValidationMessage(br.com.caelum.vraptor.validator.ValidationMessage) Sessao(br.com.caelum.agiletickets.models.Sessao) BigDecimal(java.math.BigDecimal) Path(br.com.caelum.vraptor.Path) Post(br.com.caelum.vraptor.Post)

Example 9 with Path

use of br.com.caelum.vraptor.Path in project agiletickets by caelum.

the class EstabelecimentosController method adiciona.

@Post
@Path("/estabelecimentos")
public void adiciona(final Estabelecimento estabelecimento) {
    // validando!
    validator.checking(new Validations() {

        {
            that(!Strings.isNullOrEmpty(estabelecimento.getNome()), "estabelecimento.nome", "nome.nulo");
            that(!Strings.isNullOrEmpty(estabelecimento.getEndereco()), "estabelecimento.endereco", "endereco.nulo");
        }
    });
    validator.onErrorRedirectTo(this).lista();
    diretorio.adiciona(estabelecimento);
    result.redirectTo(this).lista();
}
Also used : Validations(br.com.caelum.vraptor.validator.Validations) Path(br.com.caelum.vraptor.Path) Post(br.com.caelum.vraptor.Post)

Example 10 with Path

use of br.com.caelum.vraptor.Path in project restfulie-java by caelum.

the class ItemsController method show.

@Get
@Path("/items/{id}")
public void show(int id) {
    Item item = database.get(id);
    result.use(representation()).from(item).serialize();
}
Also used : Item(br.com.caelum.example.model.Item) Path(br.com.caelum.vraptor.Path) Get(br.com.caelum.vraptor.Get)

Aggregations

Path (br.com.caelum.vraptor.Path)10 Get (br.com.caelum.vraptor.Get)5 Post (br.com.caelum.vraptor.Post)5 Sessao (br.com.caelum.agiletickets.models.Sessao)3 Espetaculo (br.com.caelum.agiletickets.models.Espetaculo)2 ValidationMessage (br.com.caelum.vraptor.validator.ValidationMessage)2 Item (br.com.caelum.example.model.Item)1 Consumes (br.com.caelum.vraptor.Consumes)1 Item (br.com.caelum.vraptor.restbucks.Item)1 ConfigurableHypermediaResource (br.com.caelum.vraptor.restfulie.hypermedia.ConfigurableHypermediaResource)1 Serializer (br.com.caelum.vraptor.serialization.Serializer)1 Validations (br.com.caelum.vraptor.validator.Validations)1 BigDecimal (java.math.BigDecimal)1