Esempio n. 1
0
 public Result editHeliForm(String modelNum) {
   log.debug("Edit Heli form: {}", modelNum);
   HeliModel model = heliService.getHeliModelByID(modelNum);
   log.debug("Edit heli form model: {}", model);
   Form<HeliForm> heliForm = Form.form(HeliForm.class).bind(Json.toJson(model));
   return ok(editheli.render("RC Helicopter Edit", heliForm));
 }
Esempio n. 2
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. 3
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());
 }
Esempio n. 4
0
 public Result getHelis() {
   List<HeliModel> heliModel = heliService.getAllHelis();
   return ok(Json.toJson(heliModel));
 }
Esempio n. 5
0
 public Result helis() {
   List<HeliModel> heliModels = heliService.getAllHelis();
   log.debug("Helis: {}", heliModels);
   return ok(helis.render("RC Helicopters", heliModels));
 }