Package controllers

Source Code of controllers.Application

package controllers;

import com.avaje.ebean.Ebean;
import models.Bar;
import play.data.Form;
import play.db.ebean.Model;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.index;

import java.util.List;

public class Application extends Controller {

    public static Result index() {
        return ok(index.render("Your new application is ready."));
    }

    public static Result addBar() {
        Bar bar = Form.form(Bar.class).bindFromRequest().get();
        bar.save();
        return redirect(routes.Application.index());
    }

    public static Result getBar() {
        List<Bar> bars = Ebean.find(Bar.class).findList();
        List<Bar> bars1 = new Model.Finder<>(String.class, Bar.class).all();

        return ok(Json.toJson(bars));
    }

}
TOP

Related Classes of controllers.Application

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.