Commit c63ec762 authored by Tom Käsler's avatar Tom Käsler

fix sessionmotdservice

parent 0f6be9cc
package de.thm.arsnova.services
import de.thm.arsnova.models.{SessionMotd, SessionMotdId}
import de.thm.arsnova.models.{SessionMotd, SessionMotdId, SessionId}
import slick.driver.MySQLDriver.api._
import scala.concurrent.Future
object SessionMotdService extends BaseService {
def getById(motdId: SessionMotdId): Future[SessionMotd] = {
globalMotdsTable.filter(_.id === motdId).result.head
sessionMotdsTable.filter(_.id === motdId).result.head
}
def getByAudience(audience: String): Future[Seq[SessionMotd]] = {
globalMotdsTable.filter(_.audience === audience).result
def getBySessionId(sessionId: SessionId): Future[Seq[SessionMotd]] = {
sessionMotdsTable.filter(_.sessionId === sessionId).result
}
def create(motd: SessionMotd): Future[SessionMotdId] = {
globalMotdsTable.returning(globalMotdsTable.map(_.id)) += motd
sessionMotdsTable.returning(sessionMotdsTable.map(_.id)) += motd
}
def update(motd: SessionMotd): Future[Int] = {
globalMotdsTable.filter(_.id === motd.id.get).map(m =>
sessionMotdsTable.filter(_.id === motd.id.get).map(m =>
(m.title, m.text))
.update(motd.title, motd.text)
}
def delete(motdId: SessionMotdId): Future[Int] = {
globalMotdsTable.filter(_.id === motdId).delete
sessionMotdsTable.filter(_.id === motdId).delete
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment