Demo app using the Scala Play framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

40 lines
731 B

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. package controllers
  2. import play.api._
  3. import play.api.mvc._
  4. import play.api.data._
  5. import play.api.data.Forms._
  6. import models.Task
  7. object Application extends Controller {
  8. val taskForm = Form(
  9. "label" -> nonEmptyText
  10. )
  11. def index = Action {
  12. Redirect(routes.Application.tasks)
  13. }
  14. def tasks = Action {
  15. Ok(views.html.index(Task.all(), taskForm))
  16. }
  17. def newTask = Action { implicit request =>
  18. taskForm.bindFromRequest.fold(
  19. errors => BadRequest(views.html.index(Task.all(), errors)),
  20. label => {
  21. Task.create(label)
  22. Redirect(routes.Application.tasks)
  23. }
  24. )
  25. }
  26. def deleteTask(id:Long) = Action {
  27. Task.delete(id)
  28. Redirect(routes.Application.tasks)
  29. }
  30. }