diff --git a/funds/src/main/kotlin/com/pepe/rest/resteasyjackson/FundResource.kt b/funds/src/main/kotlin/com/pepe/rest/resteasyjackson/FundResource.kt index 0e982e34b..0be5ec1ba 100644 --- a/funds/src/main/kotlin/com/pepe/rest/resteasyjackson/FundResource.kt +++ b/funds/src/main/kotlin/com/pepe/rest/resteasyjackson/FundResource.kt @@ -31,6 +31,12 @@ class FundService { return "hello $name" } + fun addFund(f: Fund): Boolean{ + return funds.add(f) + + } + + fun getFunds(): Set{ return funds } @@ -41,6 +47,7 @@ class FundService { @Path("/") class FundResource { + @Inject @field: Default lateinit var service: FundService @@ -55,4 +62,21 @@ class FundResource { return service.getFunds() } + // Creates one funds + @POST + @Path("/funds") + fun add(f: Fund): Response { + val result = service.addFund(f) + if(result){ + println("POST -> Fund was created") + var m = Message("Created", "Fund was created"); + return Response.status(Response.Status.ACCEPTED).entity(m).build(); + } + println("POST -> Fund was NOT created") + var m = Message("Not Created", "Fund was not created"); + return Response.status(Response.Status.BAD_REQUEST).entity(m).build(); + + } + + } \ No newline at end of file