package edu.fiu.controllers;

import edu.fiu.models.UserStory;
import edu.fiu.repositories.UserStoryRepository;

import org.jooby.Err;
import org.jooby.Request;
import org.jooby.Status;
import org.jooby.mvc.*;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;

@Path("/api/story/submit")
public class SubmitStoryController
{
    private Request req;
    private UserStoryRepository repo; 

    @Inject
    public SubmitStoryController(UserStoryRepository repo, Request req) {
        this.repo = repo;
        this.req = req;
    }

    /*
    @Inject
    public SubmitStoryController(Request req) {
        this.req = req;
    }
    */
    //SP3
    @GET
    public List<UserStory> List () {
        return repo.list();
    }

    @POST
    public boolean Post(@Body UserStory story) throws Exception {
        
        //System.out.println("This is the body of the post request");  
        //System.out.println(story.toString());     
        
        return repo.create(story);
    }
}
