package com.coding4people.mosquitoreport.api.controllers;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("/focus")
public class FocusController {
    @POST
    @Consumes("application/json")
    @Produces("application/json;charset=UTF-8")
    public String post(@Valid FocusPostInput focus) {
        return "\"" + focus.getLatitude() + "\"";
    }
    
    public static class FocusPostInput {
        @NotNull
        private String longitude;
        
        @NotNull
        private String latitude;

        public String getLongitude() {
            return longitude;
        }

        public void setLongitude(String longitude) {
            this.longitude = longitude;
        }

        public String getLatitude() {
            return latitude;
        }

        public void setLatitude(String latitude) {
            this.latitude = latitude;
        }
    }
}

@@ -54,16 +54,71 @@
 ers;%0D%0A%0D%0A
+import java.util.Date;%0D%0A%0D%0Aimport javax.inject.Inject;%0D%0A
 import j
@@ -305,55 +305,243 @@
 %0D%0A%0D%0A
-@Path(%22/focus%22)%0D%0Apublic class FocusController %7B
+import com.coding4people.mosquitoreport.api.models.Focus;%0D%0Aimport com.coding4people.mosquitoreport.api.repositories.FocusRepository;%0D%0A%0D%0A@Path(%22/focus%22)%0D%0Apublic class FocusController %7B%0D%0A    @Inject FocusRepository focusRepository;%0D%0A    
 %0D%0A  
@@ -644,22 +644,21 @@
  public 
-String
+Focus
  post(@V
@@ -681,66 +681,361 @@
 put 
-focus) %7B%0D%0A        return %22%5C%22%22 + focus.getLatitude() + %22%5C%22%22
+input) %7B%0D%0A        Focus focus = new Focus();%0D%0A        focus.setGuid(java.util.UUID.randomUUID().toString());%0D%0A        focus.setLatitude(input.getLatitude());%0D%0A        focus.setLongitude(input.getLongitude());%0D%0A        focus.setCreateAt(Long.toString(new Date().getTime()));%0D%0A        %0D%0A        focusRepository.save(focus);%0D%0A        %0D%0A        return focus
 ;%0D%0A 

Save focus model