diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java index 979f967..98a4c8b 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java @@ -29,8 +29,8 @@ public class SupplierOfferController { List totals = new ArrayList<>(); for (ArticleOffer article : offersRepository.findAll()) { - UImodelOfferedArticle tmp = new UImodelOfferedArticle(); - tmp.addData(article, articleRepository.findArticleIDByRelatedID(article.id)); + UImodelOfferedArticle tmp = new UImodelOfferedArticle(article, + articleRepository.findArticleIDByRelatedID(article.id)); totals.add(tmp); } @@ -50,13 +50,17 @@ public class SupplierOfferController { public int listedArticleId; public boolean offerIsListed; // true --> offered article is listed - public void addData(ArticleOffer article, Optional listedArticleId) { + public UImodelOfferedArticle(ArticleOffer article, Optional listedArticleId) { this.offerId = article.id; this.title = article.title; this.manufacturer = article.manufacturer; this.articleNumber = article.articleNumber; - this.supplierName = article.cheapestSupplier.name; + if (article.cheapestSupplier != null) { + this.supplierName = article.cheapestSupplier.name; + } else { + this.supplierName = "-"; + } this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100)); this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein"; diff --git a/prototype/src/main/resources/templates/intern/offeredArticles/index.html b/prototype/src/main/resources/templates/intern/offeredArticles/index.html index df2814f..027627c 100644 --- a/prototype/src/main/resources/templates/intern/offeredArticles/index.html +++ b/prototype/src/main/resources/templates/intern/offeredArticles/index.html @@ -44,7 +44,8 @@ - + - +