Package com.sertaogames.mundoj.model

Examples of com.sertaogames.mundoj.model.Compra


  private static final long serialVersionUID = 1L;

  @Override
  protected void execute(HttpServletRequest req, HttpServletResponse resp) {

    Compra compra = new Compra();

    Gson gson = new Gson();
    List<Integer> ids =  gson.fromJson(req.getParameter("produtos"), new TypeToken<List<Integer>>(){}.getType());

    for (Integer id : ids) {
      Produto p = jdo.findById(Produto.class, id);

      compra.setTotal(compra.getTotal().add(p.getPreco()));

      ItemCompra itemCompra = new ItemCompra();
      itemCompra.setProduto(p);
      compra.getItens().add(itemCompra);
    }

    try {
     
      compra.saveJSON();
      jdo.save(compra);
     
      req.setAttribute("compra", compra);
      getServletContext().getRequestDispatcher("/detalhe-compra.jsp").forward(req, resp);
    } catch (Exception e) {
View Full Code Here


  private static final long serialVersionUID = 1L;

  @Override
  protected void execute(HttpServletRequest req, HttpServletResponse resp) {
   
    Compra compra = jdo.findById(Compra.class, Long.valueOf(req.getParameter("id")));
    req.setAttribute("compra", compra);
    compra.loadJSON();
   
    try {
      getServletContext().getRequestDispatcher("/detalhe-compra.jsp").forward(req, resp);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of com.sertaogames.mundoj.model.Compra

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.