Esempio n. 1
0
 public Result editHeli() {
   log.debug("Edit Heli");
   Form<HeliForm> heliForm = Form.form(HeliForm.class).bindFromRequest();
   if (heliForm.hasErrors()) {
     log.debug("Edit heli error form:");
     return badRequest(editheli.render("RC Helicopter Edit", heliForm));
   }
   MultipartFormData data = request().body().asMultipartFormData();
   HeliModel model = new HeliModel();
   model.setVersion(heliForm.data().get("version"));
   if (data.getFile("photo") != null) {
     model.setPhoto(heliForm.get().getPhotoBytes(data.getFile("photo").getFile()));
   }
   model.setMake(heliForm.data().get("make"));
   model.setModel(heliForm.data().get("model"));
   model.setModelNumber(heliForm.data().get("modelNumber"));
   heliService.updateHeli(model);
   return redirect(routes.Heli.helis());
 }
Esempio n. 2
0
 public Result addHeli() {
   log.debug("Add Heli");
   Form<HeliForm> heli = Form.form(HeliForm.class).bindFromRequest();
   log.debug("Add heli form: {}", heli);
   if (heli.hasErrors()) {
     return badRequest(addheli.render("RC Helicopter", heli));
   }
   MultipartFormData data = request().body().asMultipartFormData();
   log.debug("Add heli data: {}", data);
   HeliModel model = new com.HeliModel();
   model.setModel(heli.data().get("model"));
   if (data.getFile("photo") != null) {
     model.setPhoto(heli.get().getPhotoBytes(data.getFile("photo").getFile()));
   }
   model.setMake(heli.data().get("make"));
   model.setModelNumber(heli.data().get("modelNumber"));
   model.setVersion(heli.data().get("version"));
   log.debug("Add heli model: {}", model);
   heliService.createHeli(model);
   return redirect(routes.Heli.helis());
 }