package com.accenture.multibank.controller;

import com.accenture.multibank.accounts.AccountType;
import com.accenture.multibank.bank.Bank;
import com.accenture.multibank.entities.Status;
import com.accenture.multibank.entities.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author manuel
 * @version 12/20/16
 */
@RequestMapping("/atm")
@EnableAspectJAutoProxy
@RestController
public class BankController {
    private final Bank bank;

    @Autowired
    public BankController(Bank bank) {
        this.bank = bank;
    }

    @RequestMapping(value = "/{type}", method = RequestMethod.POST)
    public Integer createAccount(@RequestParam AccountType type) {
        return bank.createAccount(type, 0);
    }

    @RequestMapping(method = RequestMethod.PUT)
    public Transaction book(Transaction transaction) {
        if (transaction.getTo() == null)
            if (transaction.getAmount() > 0)
                bank.deposit(transaction.getFrom(), transaction.getAmount());
            else
                bank.withdraw(transaction.getFrom(), transaction.getAmount());
        else
            bank.transfer(transaction.getFrom(), transaction.getTo(), transaction.getAmount());
        transaction.setStatus(Status.FINISHED);
        return transaction;
    }
}

@@ -328,49 +328,173 @@
 ork.
-context.annotation.EnableAspectJAutoProxy
+beans.factory.annotation.Qualifier;%0Aimport org.springframework.context.annotation.EnableAspectJAutoProxy;%0Aimport org.springframework.web.bind.annotation.PathVariable
 ;%0Aim
@@ -607,27 +607,36 @@
 n.Re
-questMethod;%0Aimport
+stController;%0A%0Aimport static
  org
@@ -679,21 +679,27 @@
 .Request
-Param
+Method.POST
 ;%0Aimport
@@ -691,32 +691,39 @@
 od.POST;%0Aimport 
+static 
 org.springframew
@@ -748,30 +748,32 @@
 ation.Re
-stController;%0A
+questMethod.PUT;
 %0A/**%0A * 
@@ -977,16 +977,45 @@
 troller(
+@Qualifier(%22RaiffeisenBank%22) 
 Bank ban
@@ -1100,30 +1100,16 @@
 ethod = 
-RequestMethod.
 POST)%0A  
@@ -1144,20 +1144,20 @@
 nt(@
-RequestParam
+PathVariable
  Acc
@@ -1253,30 +1253,16 @@
 ethod = 
-RequestMethod.
 PUT)%0A   

change to static imports and changed parameter annotation to @PathVariable