Package controllers.api

Source Code of controllers.api.Residences

package controllers.api;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import models.Residence;
import play.mvc.Router;
import play.mvc.Http.StatusCode;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import controllers.BaseController;
import controllers.Data;
import exceptions.ValidationException;

public class Residences extends BaseController {
 
  public static void get() {
    Residence residence = Residence.findAll().get(0);
    renderJSON(gson().toJson(residence));
  }
 
  public static void edit(Long id,  JsonObject body) {
    Residence residence = new Gson().fromJson(body, Residence.class);
    if(residence==null) {
      response.status = StatusCode.NOT_FOUND;
      return;
    }
    residence.update();
    response.status = StatusCode.OK;
    String url = Router.reverse("api.Residences.get").url;// GET /api/residence/
    response.setHeader("location", url);
  }
 
}
TOP

Related Classes of controllers.api.Residences

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.