diff --git a/Apps/HackerNet.Web/Controllers/HackerController.cs b/Apps/HackerNet.Web/Controllers/HackerController.cs new file mode 100644 index 0000000..a0dec74 --- /dev/null +++ b/Apps/HackerNet.Web/Controllers/HackerController.cs @@ -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; + } +} \ No newline at end of file diff --git a/Apps/HackerNet.Web/Controllers/LinksController.cs b/Apps/HackerNet.Web/Controllers/LinksController.cs index 7eaab5a..41b40f5 100644 --- a/Apps/HackerNet.Web/Controllers/LinksController.cs +++ b/Apps/HackerNet.Web/Controllers/LinksController.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc; namespace HackerNet.Web.Controllers; -public class LinksController : Controller +public class LinksController : HackerController { private readonly LinkService _linkService; @@ -45,6 +45,8 @@ public class LinksController : Controller _linkService.PublishLink(cmd); + SetFlashMessage("Votre lien a correctement été publié !"); + return RedirectToAction("Index"); } } \ No newline at end of file diff --git a/Apps/HackerNet.Web/Views/Shared/_Layout.cshtml b/Apps/HackerNet.Web/Views/Shared/_Layout.cshtml index 65a770b..c8fae64 100644 --- a/Apps/HackerNet.Web/Views/Shared/_Layout.cshtml +++ b/Apps/HackerNet.Web/Views/Shared/_Layout.cshtml @@ -1,4 +1,7 @@ - +@{ + var flashMessage = TempData["FlashMessage"] as string; +} +
@@ -15,7 +18,15 @@ ++ @flashMessage +
+ } +