Skip to content

Commit f8c8629

Browse files
committed
Fixes #2
1 parent 27e700c commit f8c8629

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Simplify.Web.MessageBox/Responses/MessageBox.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,29 @@ public class MessageBox : ControllerResponse
1010
/// </summary>
1111
/// <param name="text">The message box text.</param>
1212
/// <param name="status">The message box status.</param>
13+
/// <param name="statusCode">The HTTP response status code.</param>
1314
/// <param name="title">The title.</param>
14-
public MessageBox(string text, MessageBoxStatus status = MessageBoxStatus.Error, string title = null)
15+
public MessageBox(string text, MessageBoxStatus status = MessageBoxStatus.Error, int statusCode = 200, string title = null)
1516
{
1617
Text = text;
1718
Status = status;
19+
StatusCode = statusCode;
1820
Title = title;
1921
}
2022

23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="MessageBox" /> class.
25+
/// </summary>
26+
/// <param name="text">The message box text.</param>
27+
/// <param name="statusCode">The HTTP response status code.</param>
28+
/// <param name="status">The message box status.</param>
29+
public MessageBox(string text, int statusCode, MessageBoxStatus status = MessageBoxStatus.Error)
30+
{
31+
Text = text;
32+
StatusCode = statusCode;
33+
Status = status;
34+
}
35+
2136
/// <summary>
2237
/// Gets the text.
2338
/// </summary>
@@ -34,6 +49,14 @@ public MessageBox(string text, MessageBoxStatus status = MessageBoxStatus.Error,
3449
/// </value>
3550
public MessageBoxStatus Status { get; }
3651

52+
/// <summary>
53+
/// Gets the HTTP response status code.
54+
/// </summary>
55+
/// <value>
56+
/// The HTTP response status code.
57+
/// </value>
58+
public int StatusCode { get; }
59+
3760
/// <summary>
3861
/// Gets the title.
3962
/// </summary>
@@ -48,6 +71,8 @@ public MessageBox(string text, MessageBoxStatus status = MessageBoxStatus.Error,
4871
/// <returns></returns>
4972
public override ControllerResponseResult Process()
5073
{
74+
Context.Response.StatusCode = StatusCode;
75+
5176
var handler = new MessageBoxHandler(TemplateFactory, StringTableManager, DataCollector);
5277

5378
handler.Show(Text, Status, Title);

0 commit comments

Comments
 (0)