diff --git a/Apps/Website/Controllers/BaseController.cs b/Apps/Website/Controllers/BaseController.cs new file mode 100644 index 0000000..2afd701 --- /dev/null +++ b/Apps/Website/Controllers/BaseController.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Website.Controllers +{ + public abstract class BaseController : Controller + { + public const string FlashTextKey = "Flash.Text"; + + public void SetFlash(string message) + { + TempData[FlashTextKey] = message; + } + } +} \ No newline at end of file diff --git a/Apps/Website/Controllers/LinksController.cs b/Apps/Website/Controllers/LinksController.cs index 0bcb5a8..8fe0c98 100644 --- a/Apps/Website/Controllers/LinksController.cs +++ b/Apps/Website/Controllers/LinksController.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; namespace Website.Controllers { - public class LinksController : Controller + public class LinksController : BaseController { private readonly IMediator _bus; @@ -35,6 +35,8 @@ namespace Website.Controllers await _bus.Send(command); + SetFlash("Link added!"); + return RedirectToAction(nameof(Index)); } } diff --git a/Apps/Website/Views/Shared/_FlashMessage.cshtml b/Apps/Website/Views/Shared/_FlashMessage.cshtml new file mode 100644 index 0000000..6dc1157 --- /dev/null +++ b/Apps/Website/Views/Shared/_FlashMessage.cshtml @@ -0,0 +1,8 @@ +@{ + var text = (string)TempData[Website.Controllers.BaseController.FlashTextKey]; +} + +@if (!string.IsNullOrWhiteSpace(text)) +{ +
+} \ No newline at end of file diff --git a/Apps/Website/Views/Shared/_Layout.cshtml b/Apps/Website/Views/Shared/_Layout.cshtml index b602b71..bfe128b 100644 --- a/Apps/Website/Views/Shared/_Layout.cshtml +++ b/Apps/Website/Views/Shared/_Layout.cshtml @@ -32,6 +32,7 @@