Skip to content
Snippets Groups Projects
Commit 0f6be9cc authored by Tom Käsler's avatar Tom Käsler
Browse files

add service for session and global motds

parent 127fcc6d
Branches
1 merge request!13Motd
Pipeline #7888 failed with stages
in 2 minutes and 26 seconds
package de.thm.arsnova.services
import de.thm.arsnova.models.{GlobalMotd, GlobalMotdId}
import slick.driver.MySQLDriver.api._
import scala.concurrent.Future
object GlobalMotdService extends BaseService {
def getById(motdId: GlobalMotdId): Future[GlobalMotd] = {
globalMotdsTable.filter(_.id === motdId).result.head
}
def getByAudience(audience: String): Future[Seq[GlobalMotd]] = {
globalMotdsTable.filter(_.audience === audience).result
}
def create(motd: GlobalMotd): Future[GlobalMotdId] = {
globalMotdsTable.returning(globalMotdsTable.map(_.id)) += motd
}
def update(motd: GlobalMotd): Future[Int] = {
globalMotdsTable.filter(_.id === motd.id.get).map(m =>
(m.audience, m.title, m.text))
.update(motd.audience, motd.title, motd.text)
}
def delete(motdId: GlobalMotdId): Future[Int] = {
globalMotdsTable.filter(_.id === motdId).delete
}
}
package de.thm.arsnova.services
import de.thm.arsnova.models.{SessionMotd, SessionMotdId}
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
}
def getByAudience(audience: String): Future[Seq[SessionMotd]] = {
globalMotdsTable.filter(_.audience === audience).result
}
def create(motd: SessionMotd): Future[SessionMotdId] = {
globalMotdsTable.returning(globalMotdsTable.map(_.id)) += motd
}
def update(motd: SessionMotd): Future[Int] = {
globalMotdsTable.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
}
}
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