2023-01-16 02:38:13 -06:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
2024-08-04 18:44:33 -05:00
|
|
|
|
namespace LANCommander.Server.Controllers
|
2023-01-16 02:38:13 -06:00
|
|
|
|
{
|
|
|
|
|
|
public class BaseController : Controller
|
|
|
|
|
|
{
|
|
|
|
|
|
public void Alert(string message, string type = "info", bool dismissable = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<AlertViewModel> alerts;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
alerts = JsonSerializer.Deserialize<List<AlertViewModel>>((string)TempData["Alerts"]);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
alerts = new List<AlertViewModel>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
alerts.Add(new AlertViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
Message = message,
|
|
|
|
|
|
Type = type,
|
|
|
|
|
|
Dismissable = dismissable
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
TempData["Alerts"] = JsonSerializer.Serialize(alerts);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|