Example #1
0
  public static void disableLast(Person resident) {
    MJPastWork pastWork = MJPastWork.find("resident = ? " + "and actif = true", resident).first();

    if (pastWork != null) {
      pastWork.actif = false;
      pastWork.save();
    }
  }
Example #2
0
  public static MJPastWork getLastActif(Person resident) {
    MJPastWork pastWork =
        MJPastWork.find(
                "resident = ? " + "and actif = true " + "order by creationDate desc", resident)
            .first();

    if (pastWork == null) {
      pastWork = new MJPastWork();
      pastWork.resident = resident;
      pastWork.creationDate = new GregorianCalendar();
      pastWork.actif = true;
      pastWork.save();
    }

    return pastWork;
  }