Skip to content

Instantly share code, notes, and snippets.

@kryton
Created March 28, 2017 16:36
Show Gist options
  • Save kryton/545fa95bcaff6146c15ffecdea699910 to your computer and use it in GitHub Desktop.
Save kryton/545fa95bcaff6146c15ffecdea699910 to your computer and use it in GitHub Desktop.
package controllers
import javax.inject._
import models.{ProductTrackRepo, ResourcePoolRepository}
import play.api._
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import play.api.mvc._
import play.db.NamedDatabase
import scala.concurrent.{ExecutionContext, Future}
//import slick.jdbc.JdbcProfile
import slick.jdbc.JdbcProfile
/**
* This controller creates an `Action` to handle HTTP requests to the
* application's home page.
*/
@Singleton
class HomeController @Inject()
(protected val dbConfigProvider: DatabaseConfigProvider,
@NamedDatabase("project") protected val dbProjectConfigProvider: DatabaseConfigProvider,
productTrackRepo: ProductTrackRepo
// resourcePoolRepository: ResourcePoolRepository
)(implicit ec: ExecutionContext,cc: ControllerComponents) extends AbstractController(cc) with HasDatabaseConfigProvider[JdbcProfile] {
/**
* Create an Action to render an HTML page.
*
* The configuration in the `routes` file means that this method
* will be called when the application receives a `GET` request with
* a path of `/`.
*/
def todo = Action.async(){ request =>
Future(Ok("hi"))
}
def index = Action.async{ request =>
productTrackRepo.find(1).map { x: Option[projectdb.Tables.ProducttrackRow] =>
x match {
case Some(y) => println("Foundit")
Ok(views.html.index())
case None => println("not found")
NotFound("Couldn't find it")
}
}
/**/
/*
resourcePoolRepository.find(1L).map { x=>
x match {
case Some(y) => println("Foundit")
Ok(views.html.index())
case None => println("not found")
NotFound("Couldn't find it")
}
}
*/
Future(Ok("hi"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment