Skip to content

Commit c3cdeb4

Browse files
committed
added TempDataHelper
1 parent db2321d commit c3cdeb4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.AspNetCore.Mvc.ViewFeatures;
2+
using System;
3+
4+
namespace GridEditor.RazorPages
5+
{
6+
public static class TempDataHelper
7+
{
8+
public static void SetSuccessMessage(this ITempDataDictionary tempData, string message)
9+
{
10+
tempData.Remove(AlertCss.Success);
11+
if (string.IsNullOrEmpty(message)) return;
12+
tempData.Add(AlertCss.Success, message);
13+
}
14+
15+
public static void SetErrorMessage(this ITempDataDictionary tempData, string message)
16+
{
17+
tempData.Remove(AlertCss.Error);
18+
tempData.Add(AlertCss.Error, message);
19+
}
20+
21+
public static void SetErrorMessage(this ITempDataDictionary tempData, Exception exception)
22+
{
23+
tempData.Remove(AlertCss.Error);
24+
tempData.Add(AlertCss.Error, exception.Message);
25+
}
26+
27+
public static void ClearErrorMessage(this ITempDataDictionary tempData)
28+
{
29+
tempData.Remove(AlertCss.Error);
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)