From 1515cd80103ca8e799947026ae84aab34e2ac38b Mon Sep 17 00:00:00 2001
From: "michael.ramusi" <michael.ramusi@etu.hesge.ch>
Date: Sun, 3 Feb 2019 19:55:32 +0100
Subject: [PATCH] credit an account

---
 services/src/main/java/ch/hepia/order/http.java | 9 +++++++++
 services/src/main/resources/static/demo.html    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/services/src/main/java/ch/hepia/order/http.java b/services/src/main/java/ch/hepia/order/http.java
index ada7dd4..844e118 100644
--- a/services/src/main/java/ch/hepia/order/http.java
+++ b/services/src/main/java/ch/hepia/order/http.java
@@ -60,6 +60,15 @@ public class http {
         return name;
     }
 
+    @RequestMapping("/creditAccount")
+    public String createAccount(
+        @RequestParam(value = "idAccount", defaultValue = "1") int idAccount,
+        @RequestParam(value = "amount", defaultValue = "1") double amount) {
+        accountService.send(new EventCreditAnAccount(5, "Crediting account", idAccount, amount));
+        return null;
+    }
+
+
     @RequestMapping("/createProduct")
     public Product createProduct(@RequestParam(value = "name", defaultValue = "poire") String name,
             @RequestParam(value = "price", defaultValue = "1") double price) {
diff --git a/services/src/main/resources/static/demo.html b/services/src/main/resources/static/demo.html
index cbeb1c2..c5b8611 100644
--- a/services/src/main/resources/static/demo.html
+++ b/services/src/main/resources/static/demo.html
@@ -18,8 +18,9 @@
     <p>Create a product that is an apple that costs 1.3 <a href="/createProduct?name=apple&price=1.3">/createProduct?name=apple&price=1.3</a></p>
     
     <h2>Accounts</h2>
-    <p>Create an account with default values <a href="/createAccount">/createAccount</a></p>
+    <p>Create an account with default value (name=Orphée) <a href="/createAccount">/createAccount</a></p>
     <p>Create an account with name Ovide <a href="/createAccount?name=Ovide">/createAccount?name=Ovide</a></p>
+    <p>Credit 50.- to account with id 1 <a href="/creditAccount?idAccount=1&amount=50">/creditAccount?idAccount=1&amount=50</a></p>
     
     <h2>Orders</h2>
     <!-- <p>Order 2 units of product with id = 1 <a href="/order?idProduct=1&quantity=2">/order?idProduct=1&quantity=2</a></p> -->
-- 
GitLab