ajout du flash message
This commit is contained in:
parent
da4179a065
commit
8a7c302b5e
11
Apps/HackerNet.Web/Controllers/HackerController.cs
Normal file
11
Apps/HackerNet.Web/Controllers/HackerController.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace HackerNet.Web.Controllers;
|
||||||
|
|
||||||
|
public abstract class HackerController : Controller
|
||||||
|
{
|
||||||
|
protected void SetFlashMessage(string message)
|
||||||
|
{
|
||||||
|
TempData["FlashMessage"] = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace HackerNet.Web.Controllers;
|
namespace HackerNet.Web.Controllers;
|
||||||
|
|
||||||
public class LinksController : Controller
|
public class LinksController : HackerController
|
||||||
{
|
{
|
||||||
private readonly LinkService _linkService;
|
private readonly LinkService _linkService;
|
||||||
|
|
||||||
@ -45,6 +45,8 @@ public class LinksController : Controller
|
|||||||
|
|
||||||
_linkService.PublishLink(cmd);
|
_linkService.PublishLink(cmd);
|
||||||
|
|
||||||
|
SetFlashMessage("Votre lien a correctement été publié !");
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
@{
|
||||||
|
var flashMessage = TempData["FlashMessage"] as string;
|
||||||
|
}
|
||||||
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
@ -15,7 +18,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="mx-auto max-w-4xl px-4">
|
<div class="mx-auto max-w-4xl px-4">
|
||||||
|
@if(!string.IsNullOrWhiteSpace(flashMessage))
|
||||||
|
{
|
||||||
|
<p class="p-6 bg-indigo-100 text-indigo-700 font-semibold">
|
||||||
|
@flashMessage
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
<main role="main" class="pb-3">
|
<main role="main" class="pb-3">
|
||||||
@RenderBody()
|
@RenderBody()
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user