示例#1
0
  public static void update(Time entity) {
    entity.Milestone = Milestone.findById(entity.Task.Milestone.id);

    validation.valid(entity);
    if (validation.hasErrors()) {
      flash.error(Messages.get("scaffold.validation"));
      render("@edit", entity);
    }

    entity = entity.merge();
    entity.save();
    flash.success(Messages.get("scaffold.updated", "Time"));
    index();
  }
示例#2
0
  public static void save(Time entity) {
    entity.createdBy = User.find("byUserName", Security.connected()).<User>first();

    if (entity.Task != null) {
      entity.Milestone = Milestone.findById(entity.Task.Milestone.id);
    } else if (entity.Issue != null) {
      entity.Milestone = Milestone.findById(entity.Issue.Milestone.id);
    }

    validation.valid(entity);
    if (validation.hasErrors()) {
      flash.error(Messages.get("scaffold.validation"));
      render("@create", entity);
    }
    entity.save();
    flash.success(Messages.get("scaffold.created", "Time"));

    if (entity.Task != null) {
      Tasks.show(entity.Task.id);
    } else {
      Issues.show(entity.Issue.id);
    }
  }