/**
   * Adds an all-in-one computer (combined with four freely customizable parts) to the cart.
   *
   * @param article requested all-in-one computer
   * @param number the amount of requested articles
   * @param cart contains a fresh initialized cart
   * @param success notification about adding an article to the cart
   * @return redirect to template "allinone"
   */
  @RequestMapping(value = "/cart2", method = RequestMethod.POST)
  public String addcomp(
      @RequestParam("pid") Computer article,
      @RequestParam("number") int number,
      @ModelAttribute Cart cart,
      RedirectAttributes success) {

    Optional<InventoryItem> item = inventory.findByProductIdentifier(article.getIdentifier());

    Quantity quantity = item.map(InventoryItem::getQuantity).orElse(NONE);
    BigDecimal amount1 = quantity.getAmount();
    int i = amount1.intValue();
    int amount = number;
    if (number <= 0) {
      amount = 1;
    }
    if (number >= i) {
      amount = i;
    }

    cart.addOrUpdateItem(article, Quantity.of(amount));
    cart.addOrUpdateItem(article.getProzessor().get(0), Quantity.of(amount));
    cart.addOrUpdateItem(article.getGraka().get(0), Quantity.of(amount));
    cart.addOrUpdateItem(article.getHdd().get(0), Quantity.of(amount));
    cart.addOrUpdateItem(article.getRam().get(0), Quantity.of(amount));

    article.getGraka().clear();
    article.getHdd().clear();
    article.getProzessor().clear();
    article.getRam().clear();

    success.addFlashAttribute(
        "success", "Der Artikel wurde erfolgreich Ihrem Warenkorb hinzugefügt.");
    return "redirect:allinone";
  }
  /**
   * Adds an article (notebook, supply, software) to the cart.
   *
   * @param article the requested article
   * @param number the amount of requested articles
   * @param cart contains a fresh initialized cart
   * @param success notification about adding an article to the cart
   * @return redirect to the category the requested article is part of
   */
  @RequestMapping(value = "/cart", method = RequestMethod.POST)
  public String addarticle(
      @RequestParam("pid") Article article,
      @RequestParam("number") int number,
      @ModelAttribute Cart cart,
      RedirectAttributes success) {

    Optional<InventoryItem> item = inventory.findByProductIdentifier(article.getIdentifier());

    Quantity quantity = item.map(InventoryItem::getQuantity).orElse(NONE);
    BigDecimal amount1 =
        quantity.getAmount(); // Herrje, wer das schöner schreiben will, kann das gerne machen
    int i = amount1.intValue(); // Endlich funktioniert die Validierung, besser als beim
    int amount = number; // Videoshop :P Kevin
    if (number <= 0) {
      amount = 1;
    }
    if (number >= i) {
      amount = i;
    }

    cart.addOrUpdateItem(article, Quantity.of(amount));

    success.addFlashAttribute(
        "success", "Der Artikel wurde erfolgreich Ihrem Warenkorb hinzugefügt.");

    switch (article.getType()) {
      case NOTEBOOK:
        return "redirect:laptop";

      case SOFTWARE:
        return "redirect:software";
      case ZUBE:
      default:
        return "redirect:zubehoer";
    }
  }