本文整理汇总了Scala中play.api.i18n.I18nSupport类的典型用法代码示例。如果您正苦于以下问题:Scala I18nSupport类的具体用法?Scala I18nSupport怎么用?Scala I18nSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了I18nSupport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: TimeCostInput
//设置package包名称以及导入依赖的类
package controllers
import javax.inject.Inject
import com.shouldioptimize.model.{Ec2Pricing, PreTaxHourlyTimeCostModel}
import play.api.cache.Cached
import play.api.data.Forms._
import play.api.data._
import play.api.data.validation.{Constraint, Invalid, Valid, ValidationResult}
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.mvc._
case class TimeCostInput(programmerHourCost: BigDecimal, instanceType: String)
class Application @Inject()(val messagesApi: MessagesApi, cached: Cached) extends Controller with I18nSupport {
val validInstanceType = Constraint[String] ({
case it if Ec2Pricing.all.contains(it) => Valid
case _ => Invalid("invalid instance type")
}: PartialFunction[String,ValidationResult])
val TimeCostInputForm = Form(
mapping(
"programmerHourCost" -> bigDecimal,
"instanceType" -> text.verifying(validInstanceType)
)(TimeCostInput.apply)(TimeCostInput.unapply))
private val DefaultProgrammerHourCost = BigDecimal("42.88")
private val DefaultInstanceType = "t2.large"
private val DefaultForm = TimeCostInputForm.fill(TimeCostInput(BigDecimal("42.88"), DefaultInstanceType))
def index = cached.status(_ => "/index", OK, 60) {
Action {
Ok(views.html.results(new PreTaxHourlyTimeCostModel(BigDecimal("42.88")).calculate.values, DefaultForm))
}
}
def results = Action { request =>
val form = TimeCostInputForm.bind(request.queryString.mapValues(_.head))
form.fold(
formWithErrors => BadRequest(views.html.results(new PreTaxHourlyTimeCostModel(DefaultProgrammerHourCost).calculate.values, formWithErrors)),
timeCostInput => Ok(views.html.results(new PreTaxHourlyTimeCostModel(timeCostInput.programmerHourCost).calculate.values, form))
)
}
def why = cached.status(_ => "/why", OK, 60) {
Action {
Ok(views.html.why())
}
}
}
示例2: SignupController
//设置package包名称以及导入依赖的类
package controllers
import javax.inject.{Inject, Singleton}
import com.mohiva.play.silhouette.api.Silhouette
import forms.SignupForm
import play.api.i18n.{I18nSupport, Messages, MessagesApi}
import play.api.mvc.{Action, Controller, Flash}
import utils.auth.DefaultEnv
@Singleton
class SignupController @Inject()
(
val messagesApi: MessagesApi,
silhouette: Silhouette[DefaultEnv]
) extends Controller with I18nSupport {
def createUser = Action { implicit request =>
println("trying to create!")
SignupForm.form.bindFromRequest.fold(
hasErrors = { form =>
Redirect(routes.SignupController.registerPage())
.flashing(Flash(form.data) + ("error" -> Messages("validation.errors")))
},
success = { signupData =>
println(s"creating a new user $signupData")
Redirect(routes.BookmarkController.list())
}
)
}
def registerPage = silhouette.UnsecuredAction { implicit request =>
Ok(views.html.users.register(SignupForm.form))
}
}
示例3: ChangePasswordController
//设置package包名称以及导入依赖的类
package controllers
import javax.inject.Inject
import com.mohiva.play.silhouette.api._
import com.mohiva.play.silhouette.api.exceptions.ProviderException
import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
import com.mohiva.play.silhouette.api.util.{ Credentials, PasswordHasherRegistry, PasswordInfo }
import com.mohiva.play.silhouette.impl.providers.CredentialsProvider
import models.services.UserService
import play.api.i18n.{ I18nSupport, Messages, MessagesApi }
import play.api.libs.concurrent.Execution.Implicits._
import play.api.mvc.Controller
import utils.auth.{ DefaultEnv, WithProvider }
import scala.concurrent.Future
class ChangePasswordController @Inject() (
val messagesApi: MessagesApi,
silhouette: Silhouette[DefaultEnv],
userService: UserService,
credentialsProvider: CredentialsProvider,
authInfoRepository: AuthInfoRepository,
passwordHasherRegistry: PasswordHasherRegistry
)
extends Controller with I18nSupport {
def view = silhouette.SecuredAction(WithProvider[DefaultEnv#A](CredentialsProvider.ID)) { implicit request =>
Ok(views.html.changePassword(new myform.MyChangePasswordForm(), request.identity))
}
def submit = silhouette.SecuredAction(WithProvider[DefaultEnv#A](CredentialsProvider.ID)).async { implicit request =>
new myform.MyChangePasswordForm().bindFromRequest match {
case form: myform.MyChangePasswordForm => Future.successful(BadRequest(views.html.changePassword(form, request.identity)))
case data: myform.MyChangePasswordFormData => {
val (currentPassword, newPassword) = (data.currentPassword, data.newPassword)
val credentials = Credentials(request.identity.email.getOrElse(""), currentPassword)
credentialsProvider.authenticate(credentials).flatMap { loginInfo =>
val passwordInfo = passwordHasherRegistry.current.hash(newPassword)
authInfoRepository.update[PasswordInfo](loginInfo, passwordInfo).map { _ =>
Redirect(routes.ChangePasswordController.view()).flashing("success" -> Messages("password.changed"))
}
}.recover {
case e: ProviderException =>
Redirect(routes.ChangePasswordController.view()).flashing("error" -> Messages("current.password.invalid"))
}
}
}
}
}
示例4: ResetPasswordController
//设置package包名称以及导入依赖的类
package controllers
import java.util.UUID
import javax.inject.Inject
import com.mohiva.play.silhouette.api._
import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
import com.mohiva.play.silhouette.api.util.{ PasswordHasherRegistry, PasswordInfo }
import com.mohiva.play.silhouette.impl.providers.CredentialsProvider
import models.services.{ AuthTokenService, UserService }
import play.api.i18n.{ I18nSupport, Messages, MessagesApi }
import play.api.libs.concurrent.Execution.Implicits._
import play.api.mvc.Controller
import utils.auth.DefaultEnv
import scala.concurrent.Future
class ResetPasswordController @Inject() (
val messagesApi: MessagesApi,
silhouette: Silhouette[DefaultEnv],
userService: UserService,
authInfoRepository: AuthInfoRepository,
passwordHasherRegistry: PasswordHasherRegistry,
authTokenService: AuthTokenService
)
extends Controller with I18nSupport {
def view(token: UUID) = silhouette.UnsecuredAction.async { implicit request =>
authTokenService.validate(token).map {
case Some(authToken) => Ok(views.html.resetPassword(new myform.MyResetPasswordForm(), token))
case None => Redirect(routes.SignInController.view()).flashing("error" -> Messages("invalid.reset.link"))
}
}
def submit(token: UUID) = silhouette.UnsecuredAction.async { implicit request =>
authTokenService.validate(token).flatMap {
case Some(authToken) =>
new myform.MyResetPasswordForm().bindFromRequest match {
case form: myform.MyResetPasswordForm => Future.successful(BadRequest(views.html.resetPassword(form, token)))
case data: myform.MyResetPasswordFormData => userService.retrieve(authToken.userID).flatMap {
case Some(user) if user.loginInfo.providerID == CredentialsProvider.ID =>
val passwordInfo = passwordHasherRegistry.current.hash(data.password)
authInfoRepository.update[PasswordInfo](user.loginInfo, passwordInfo).map { _ =>
Redirect(routes.SignInController.view()).flashing("success" -> Messages("password.reset"))
}
case _ => Future.successful(Redirect(routes.SignInController.view()).flashing("error" -> Messages("invalid.reset.link")))
}
}
case None => Future.successful(Redirect(routes.SignInController.view()).flashing("error" -> Messages("invalid.reset.link")))
}
}
}
示例5: ForgotPasswordController
//设置package包名称以及导入依赖的类
package controllers
import javax.inject.Inject
import com.mohiva.play.silhouette.api._
import com.mohiva.play.silhouette.impl.providers.CredentialsProvider
import models.services.{ AuthTokenService, UserService }
import models.daos._
import play.api.i18n.{ I18nSupport, Messages, MessagesApi }
import play.api.libs.concurrent.Execution.Implicits._
import play.api.libs.mailer.{ Email, MailerClient }
import play.api.mvc.Controller
import utils.auth.DefaultEnv
import scala.concurrent.Future
class ForgotPasswordController @Inject() (
val messagesApi: MessagesApi,
silhouette: Silhouette[DefaultEnv],
userService: UserService,
authTokenService: AuthTokenService,
mailerClient: MailerClient,
envDAO: EnvDAO
)
extends Controller with I18nSupport {
def view = silhouette.UnsecuredAction.async { implicit request =>
Future.successful(Ok(views.html.forgotPassword(new myform.MyForgotPasswordForm())))
}
def submit = silhouette.UnsecuredAction.async { implicit request =>
new myform.MyForgotPasswordForm().bindFromRequest match {
case form: myform.MyForgotPasswordForm => Future.successful(BadRequest(views.html.forgotPassword(form)))
case data: myform.MyForgotPasswordFormData => {
val email = data.email
val loginInfo = LoginInfo(CredentialsProvider.ID, email)
val result = Redirect(routes.SignInController.view()).flashing("info" -> Messages("reset.email.sent"))
userService.retrieve(loginInfo).flatMap {
case Some(user) if user.email.isDefined =>
authTokenService.create(user.userID).map { authToken =>
val url = routes.ResetPasswordController.view(authToken.id).absoluteURL()
println("url " + url)
if (envDAO.getDosendmail) mailerClient.send(Email(
subject = Messages("email.reset.password.subject"),
from = Messages("email.from"),
to = Seq(email),
bodyText = Some(views.txt.emails.resetPassword(user, url).body),
bodyHtml = Some(views.html.emails.resetPassword(user, url).body)
))
result
}
case None => Future.successful(result)
}
}
}
}
}
示例6: BaseController
//设置package包名称以及导入依赖的类
package controllers
import java.util.UUID
import org.joda.time.LocalDateTime
import play.api.i18n.I18nSupport
import services.user.AuthenticationEnvironment
import com.mohiva.play.silhouette.api._
import com.mohiva.play.silhouette.impl.authenticators.CookieAuthenticator
import models.user.{ Role, User }
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.mvc.{ AnyContent, Result }
import scala.concurrent.Future
abstract class BaseController() extends Silhouette[User, CookieAuthenticator] with I18nSupport {
def env: AuthenticationEnvironment
def withAdminSession(block: (SecuredRequest[AnyContent]) => Future[Result]) = SecuredAction.async { implicit request =>
if (request.identity.roles.contains(Role.Admin)) {
block(request)
} else {
Future.successful(NotFound("404 Not Found"))
}
}
def withSession(block: (SecuredRequest[AnyContent]) => Future[Result]) = UserAwareAction.async { implicit request =>
val response = request.identity match {
case Some(user) =>
val secured = SecuredRequest(user, request.authenticator.getOrElse(throw new IllegalStateException()), request)
block(secured).map { r =>
r
}
case None =>
val user = User(
id = UUID.randomUUID(),
username = None,
profiles = Nil,
created = new LocalDateTime()
)
for {
user <- env.userService.save(user)
authenticator <- env.authenticatorService.create(LoginInfo("anonymous", user.id.toString))
value <- env.authenticatorService.init(authenticator)
result <- block(SecuredRequest(user, authenticator, request))
authedResponse <- env.authenticatorService.embed(value, result)
} yield {
env.eventBus.publish(SignUpEvent(user, request, request2Messages))
env.eventBus.publish(LoginEvent(user, request, request2Messages))
authedResponse
}
}
response
}
}
示例7: ApplicationController
//设置package包名称以及导入依赖的类
package controllers
import javax.inject._
import play.api._
import play.api.mvc._
import play.api.data._
import play.api.data.Forms._
import javax.inject.Inject
// Play needs these to generate form messages
import play.api.i18n.I18nSupport
import play.api.i18n.MessagesApi
import views._
import model.{PropertySearchForm}
@Singleton
class ApplicationController @Inject()(val messagesApi: MessagesApi) extends Controller with I18nSupport {
val searchForm = Form(
"Address" -> nonEmptyText
)
def index = Action {
Ok(views.html.index("Enter an Address", searchForm, ""))
}
def searchProperty() = Action { implicit request =>
PropertySearchForm.form.bindFromRequest.fold(
// if any error in submitted data
errors => BadRequest(views.html.index("Enter an Address", searchForm, "Error ocurred")),
data => {
Ok(views.html.index("Enter an Address", searchForm, data.address))
})
}
}
示例8: PasswordSettingsData
//设置package包名称以及导入依赖的类
package controllers.my.settings
import controllers.{ HasConfig, HasUserService, Security }
import javax.inject.Inject
import jp.t2v.lab.play2.auth.AuthElement
import models.user.UserService
import models.user.Roles._
import play.api.Configuration
import play.api.data.Form
import play.api.data.Forms._
import play.api.data.validation._
import play.api.i18n.{ I18nSupport, MessagesApi }
import play.api.mvc.Controller
import scala.concurrent.{ ExecutionContext, Future }
case class PasswordSettingsData(currentPassword: String, newPassword: String, verifyPassword: String)
class PasswordSettingsController @Inject() (
val config: Configuration,
val users: UserService,
val messagesApi: MessagesApi,
implicit val ctx: ExecutionContext
) extends Controller with AuthElement with HasConfig with HasUserService with Security with I18nSupport {
private val matchingPasswords: Constraint[PasswordSettingsData] = Constraint("constraints.valid"){ d =>
if (d.newPassword == d.verifyPassword) Valid else Invalid("Passwords must match")
}
val passwordSettingsForm = Form(
mapping(
"current" -> nonEmptyText,
"new" -> nonEmptyText,
"verify" -> nonEmptyText
)(PasswordSettingsData.apply)(PasswordSettingsData.unapply).verifying(matchingPasswords)
)
def index() = StackAction(AuthorityKey -> Normal) { implicit request =>
Ok(views.html.my.settings.password(passwordSettingsForm, loggedIn.user))
}
def updatePassword() = AsyncStack(AuthorityKey -> Normal) { implicit request =>
passwordSettingsForm.bindFromRequest.fold(
formWithErrors =>
Future.successful(BadRequest(views.html.my.settings.password(formWithErrors, loggedIn.user))),
f => {
users.updatePassword(loggedIn.user.getUsername, f.currentPassword, f.newPassword)
.map { _ match {
case Right(_) =>
Redirect(routes.PasswordSettingsController.index).flashing("success" -> "Your password has been updated.")
case Left(errorMessage) =>
Redirect(routes.PasswordSettingsController.index).flashing("error" -> errorMessage)
}}.recover { case t:Throwable => {
t.printStackTrace()
Redirect(routes.PasswordSettingsController.index).flashing("error" -> "There was an error while updating your password.")
}}
}
)
}
}
示例9: LoginData
//设置package包名称以及导入依赖的类
package controllers.landing
import controllers.{ HasConfig, HasUserService, Security }
import javax.inject.{ Inject, Singleton }
import jp.t2v.lab.play2.auth.{ AuthElement, LoginLogout }
import models.document.DocumentService
import models.user.UserService
import play.api.Configuration
import play.api.data.Form
import play.api.data.Forms._
import play.api.i18n.{ I18nSupport, MessagesApi }
import play.api.mvc.{ Action, Controller }
import scala.concurrent.{ ExecutionContext, Future }
case class LoginData(usernameOrPassword: String, password: String)
@Singleton
class LoginLogoutController @Inject() (
val config: Configuration,
val users: UserService,
implicit val ctx: ExecutionContext,
val messagesApi: MessagesApi
) extends Controller with AuthElement with HasConfig with HasUserService with Security with LoginLogout with I18nSupport {
private val MESSAGE = "message"
private val INVALID_LOGIN = "Invalid Username or Password"
val loginForm = Form(
mapping(
"username" -> nonEmptyText,
"password" -> nonEmptyText
)(LoginData.apply)(LoginData.unapply)
)
def showLoginForm(destination: Option[String]) = Action { implicit request =>
destination match {
case None => Ok(views.html.landing.login(loginForm))
case Some(dest) => Ok(views.html.landing.login(loginForm)).withSession("access_uri" -> dest)
}
}
def processLogin = Action.async { implicit request =>
loginForm.bindFromRequest.fold(
formWithErrors =>
Future(BadRequest(views.html.landing.login(formWithErrors))),
loginData =>
users.validateUser(loginData.usernameOrPassword, loginData.password).flatMap {
case Some(validUser) => gotoLoginSucceeded(validUser.getUsername)
case None => Future(Redirect(routes.LoginLogoutController.showLoginForm()).flashing(MESSAGE -> INVALID_LOGIN))
}
)
}
def logout = Action.async { implicit request =>
gotoLogoutSucceeded
}
}
示例10: Application
//设置package包名称以及导入依赖的类
package controllers
import javax.inject.Inject
import scala.concurrent.Future
import com.mohiva.play.silhouette.api.Silhouette
import com.mohiva.play.silhouette.impl.providers.SocialProviderRegistry
import play.api.mvc._
import play.api.i18n.{I18nSupport, MessagesApi}
import utils.auth.CookieEnv
class Application @Inject() (
val messagesApi: MessagesApi,
silhouette: Silhouette[CookieEnv],
socialProviderRegistry: SocialProviderRegistry,
implicit val webJarAssets: WebJarAssets) extends Controller with I18nSupport {
import silhouette._
def index = UserAwareAction.async { implicit request =>
Future.successful(Ok(views.html.index(request.identity, request.authenticator.map(_.loginInfo))))
}
def profile = SecuredAction { implicit request =>
Ok(views.html.profile(request.identity, request.authenticator.loginInfo, socialProviderRegistry))
}
}
示例11: RestApi
//设置package包名称以及导入依赖的类
package controllers
import javax.inject.Inject
import scala.concurrent.Future
import com.mohiva.play.silhouette.api.Silhouette
import play.api.libs.json._
import play.api.mvc._
import play.api.i18n.{I18nSupport, Messages, MessagesApi}
import models.User
import User._
import com.mohiva.play.silhouette.api.actions.SecuredErrorHandler
import utils.auth.CookieEnv
class RestApi @Inject() (
val messagesApi: MessagesApi,
val silhouette: Silhouette[CookieEnv]) extends Controller with I18nSupport {
import silhouette._
def profile = SecuredAction.async { implicit request =>
val json = Json.toJson(request.identity.profileFor(request.authenticator.loginInfo).get)
val prunedJson = json.transform(
(__ \ 'loginInfo).json.prune andThen
(__ \ 'passordInfo).json.prune andThen
(__ \ 'oauth1Info).json.prune)
prunedJson.fold(
_ => Future.successful(InternalServerError(Json.obj("error" -> Messages("error.profileError")))),
js => Future.successful(Ok(js))
)
}
val errorHandler = new SecuredErrorHandler {
override def onNotAuthenticated(implicit request: RequestHeader) = {
Future.successful(Unauthorized(Json.obj("error" -> Messages("error.profileUnauth"))))
}
override def onNotAuthorized(implicit request: RequestHeader) = {
Future.successful(Forbidden("local.not.authorized"))
}
}
}
示例12: ErrorHandler
//设置package包名称以及导入依赖的类
package utils
import javax.inject.{Inject, Provider}
import com.mohiva.play.silhouette.api.actions.SecuredErrorHandler
import play.api.http.DefaultHttpErrorHandler
import play.api.i18n.{I18nSupport, Messages, MessagesApi}
import play.api.mvc.Results._
import play.api.mvc.{RequestHeader, Result}
import play.api.routing.Router
import play.api.{Configuration, OptionalSourceMapper}
import scala.concurrent.Future
import controllers.{WebJarAssets, routes}
class ErrorHandler @Inject() (
val messagesApi: MessagesApi,
env: play.api.Environment,
config: Configuration,
sourceMapper: OptionalSourceMapper,
router: javax.inject.Provider[Router],
p: Provider[WebJarAssets])
extends DefaultHttpErrorHandler(env, config, sourceMapper, router)
with SecuredErrorHandler with I18nSupport {
// https://www.playframework.com/documentation/2.5.x/Migration25#Handling-legacy-components
implicit lazy val webJarAssets = p.get()
override def onNotAuthenticated(implicit request: RequestHeader): Future[Result] =
Future.successful(Redirect(routes.Auth.signIn()))
override def onNotAuthorized(implicit request: RequestHeader): Future[Result] =
Future.successful(Redirect(routes.Auth.signIn()).flashing("error" -> Messages("error.accessDenied")))
override def onNotFound(request: RequestHeader, message: String): Future[Result] =
Future.successful(Ok(views.html.errors.notFound(request)))
override def onServerError(request:RequestHeader, exception:Throwable):Future[Result] =
Future.successful(Ok(views.html.errors.serverError(request, exception)))
}
示例13: HttpsOnlyFilter
//设置package包名称以及导入依赖的类
package utils
import javax.inject.Inject
import scala.concurrent.Future
import play.api._
import play.api.i18n.{I18nSupport, Messages, MessagesApi}
import play.api.mvc._
import Results.Ok
import akka.stream.Materializer
import play.api.http.HttpFilters
import play.filters.csrf.CSRFFilter
import controllers.routes
// If we configure play.http.forwarded.trustedProxies correctly, we don't need this filter... right? right!?
class HttpsOnlyFilter @Inject() (implicit val mat:Materializer, val messagesApi:MessagesApi) extends Filter with I18nSupport {
def apply(nextFilter:RequestHeader => Future[Result])(request:RequestHeader):Future[Result] = {
implicit val r = request
request.headers.get("X-Forwarded-Proto").map {
case "https" => nextFilter(request)
case _ => Future.successful(Ok(views.html.errors.onlyHttpsAllowed()))
}.getOrElse(nextFilter(request))
}
}
class Filters @Inject() (
configuration:Configuration,
csrfFilter:CSRFFilter,
httpsOnlyFilter:HttpsOnlyFilter) extends HttpFilters {
val map = Map("application.proxy.httpsOnly" -> httpsOnlyFilter)
override def filters = csrfFilter +: map.foldRight[Seq[EssentialFilter]](Seq.empty) { case ((k,f),filters) =>
configuration.getBoolean(k) collect {
case true => f +: filters
} getOrElse filters
}
}
示例14: FormController
//设置package包名称以及导入依赖的类
package controllers
import javax.inject._
import models.UserData
import play.api._
import play.api.mvc._
import play.api.http.HttpEntity
import play.api.data._
import play.api.data.Forms._
import play.api.i18n.{MessagesApi, I18nSupport}
@Singleton
class FormController @Inject()(val messagesApi: MessagesApi) extends Controller with I18nSupport {
val userForm: Form[UserData] = Form(
mapping(
"name" -> nonEmptyText(minLength = 1, maxLength = 60),
"age" -> number(min = 0, max = 100)
)(UserData.apply)(UserData.unapply)
)
def createUser = Action {
Ok(views.html.createUser(userForm))
}
def saveUser = Action { implicit request =>
val userData: UserData = userForm.bindFromRequest.get
val name: String = userData.name
val age: Long = userData.age
Ok(s"saved a user with name $name and of age $age")
}
}
示例15: ApartmentController
//设置package包名称以及导入依赖的类
package controllers
import com.google.inject.Inject
import models.{Apartment, ApartmentForm}
import play.api.i18n.{Messages, I18nSupport, MessagesApi}
import play.api.mvc.{Action, Controller}
import services.ApartmentService
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits._
class ApartmentController @Inject()(apartmentService: ApartmentService, val messagesApi: MessagesApi) extends Controller with I18nSupport with Secured {
def dashboard = IsAuthenticated {
username =>
implicit request =>
apartmentService.listAllApartments map {
apartments => Ok(views.html.apartment(ApartmentForm.form, apartments))
}
}
def addApartment() = Action.async { implicit request =>
ApartmentForm.form.bindFromRequest.fold(
errorForm => Future.successful(Ok(views.html.apartment(errorForm, Seq.empty[Apartment]))),
data => {
val newApartment = Apartment(0, data.name, data.rooms, data.area)
apartmentService.addApartment(newApartment).map(res =>
Redirect(routes.ApartmentController.dashboard()).flashing(Messages("flash.success") -> res)
)
})
}
def deleteApartment(id: Long) = Action.async { implicit request =>
apartmentService.deleteApartment(id) map { res =>
Redirect(routes.ApartmentController.dashboard())
}
}
}