using Microsoft.AspNetCore.Mvc; using System.Text.Json; namespace LANCommander.Server.Controllers { public class BaseController : Controller { public void Alert(string message, string type = "info", bool dismissable = true) { List alerts; try { alerts = JsonSerializer.Deserialize>((string)TempData["Alerts"]); } catch { alerts = new List(); } alerts.Add(new AlertViewModel() { Message = message, Type = type, Dismissable = dismissable }); TempData["Alerts"] = JsonSerializer.Serialize(alerts); } } }