public Result crearAlumno() { Form<Alumno> form = Form.form(Alumno.class).bindFromRequest(); if (form.hasErrors()) { return badRequest(ControllerHelper.errorJson(2, "invalid_alumno", form.errorsAsJson())); } Alumno alumno = form.get(); alumno.save(); return created(); }
public Result actualizarAlumno(String id) { Alumno alumno = Alumno.find.byId(id); if (alumno == null) { return notFound(); } Form<Alumno> form = Form.form(Alumno.class).bindFromRequest(); if (form.hasErrors()) { return badRequest(ControllerHelper.errorJson(1, "invalid_alumno", form.errorsAsJson())); } Result res; if (alumno.changeData(form.get())) { alumno.save(); res = ok(); } else { res = status(NOT_MODIFIED); } return res; }