Created
February 11, 2023 17:31
-
-
Save ekremgunes/c0343906dc9b4c39ab657a10743ebc16 to your computer and use it in GitHub Desktop.
ViewAlert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Mvc; | |
namespace ViewAlertApp.Extensions | |
{ | |
public static class ControllerExtensions | |
{ | |
//scripted by gunesekrem.com | |
public static string ViewAlert(this Controller controller, AlertType alert = AlertType.Info, string alertMessage = "Info") | |
{ | |
if (alert == AlertType.Success) | |
{ | |
return $"<span class='successAlert'>{alertMessage}</span>"; | |
} | |
else if (alert == AlertType.Warning) | |
{ | |
return $"<span class='warningAlert'>{alertMessage}</span>"; | |
} | |
else if (alert == AlertType.Error) | |
{ | |
return $"<span class='errorAlert'>{alertMessage}</span>"; | |
} | |
else | |
{ | |
return $"<span class='infoAlert'>{alertMessage}</span>"; | |
} | |
} | |
} | |
public enum AlertType | |
{ | |
Success = 1, | |
Error = 2, | |
Info = 3, | |
Warning = 4 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment