public Result getAllProfits() {

    List<Profit> profits = Profit.findAllProfits();

    if (RequestUtils.acceptsJson(request())) {
      return ok(Json.toJson(profits));
    } else if (RequestUtils.acceptsXml(request())) {
      return ok(views.xml.profits.render(profits));
    }

    return badRequest("unsupported format");
  }
  public Result retrieve(Integer pId) {

    Profit profit = Profit.findProfitWithId(pId);

    if (profit == null) {
      return notFound();
    }

    if (RequestUtils.acceptsJson(request())) {
      return ok(Json.toJson(profit));
    } else if (RequestUtils.acceptsXml(request())) {
      return ok(views.xml.profit.render(profit));
    }

    return badRequest("unsupported format");
  }
  public Result getAdvisedUserFromProfit(Integer pId) {
    Profit profit = Profit.findProfitWithId(pId);

    if (profit == null) {
      return notFound();
    }

    AdvisedUser advisedUser = profit.getUser();

    if (RequestUtils.acceptsJson(request())) {
      return ok(Json.toJson(advisedUser));
    } else if (RequestUtils.acceptsXml(request())) {
      return ok(views.xml.adviseduser.render(advisedUser));
    }

    return badRequest("unsupported format");
  }