play-java-ebean-example icon indicating copy to clipboard operation
play-java-ebean-example copied to clipboard

Working with computer ebean only

Open HannahJSwystun opened this issue 7 years ago • 0 comments

Hello,

Can you help me please to use only computer ebean instead of ( computer , company ) !


    public CompletionStage<Result> create() {
        Form<Computer> computerForm = formFactory.form(Computer.class);
		Computer computer = computerForm.get();
        
// I don't know how to change this only for compter or may be remove it ?!!!
        return companyRepository.options().thenApplyAsync((Map<String, String> companies) -> {         
	
            return ok(views.html.createForm.render(computerForm)); }, httpExecutionContext.current());
  }

    
    public CompletionStage<Result> save() {
        Form<Computer> computerForm = formFactory.form(Computer.class).bindFromRequest();
        if (computerForm.hasErrors()) {

// How to change this line for computer only
            return companyRepository.options().thenApplyAsync(companies -> {

                return badRequest(views.html.createForm.render(computerForm));
            }, httpExecutionContext.current());
        }

        Computer computer = computerForm.get();
        return computerRepository.insert(computer).thenApplyAsync(data -> {
            flash("success", "Computer " + computer.name + " has been created");
            return GO_HOME;
        }, httpExecutionContext.current());
    }

HannahJSwystun avatar Oct 15 '18 11:10 HannahJSwystun