Skip to content

Commit

Permalink
#15 #18 POST fund. Add fund as customer user
Browse files Browse the repository at this point in the history
  • Loading branch information
José Antonio Córdoba Gómez committed Jan 8, 2021
1 parent 880e10b commit c414927
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class FundService {
return "hello $name"
}

fun addFund(f: Fund): Boolean{
return funds.add(f)

}


fun getFunds(): Set<Fund>{
return funds
}
Expand All @@ -41,6 +47,7 @@ class FundService {
@Path("/")
class FundResource {


@Inject
@field: Default
lateinit var service: FundService
Expand All @@ -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();

}


}

0 comments on commit c414927

Please sign in to comment.