Skip to content

Commit 5f82b83

Browse files
committed
Status code added
Status code added
1 parent 77cc38a commit 5f82b83

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Supermarket/ApiResponse/BadRequestResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ namespace Supermarket.ApiResponse
88
public class BadRequestResponse : ValidationProblemDetails
99
{
1010
public Guid TraceId { get; set; }
11+
1112
public BadRequestResponse(string error) : base(new Dictionary<string, string[]> { { "error", new[] { error } } })
1213
{
1314
TraceId = Guid.NewGuid();
1415
Title = HttpStatusCode.BadRequest.ToString();
16+
Status = (int)HttpStatusCode.BadRequest;
1517
}
1618
}
1719
}

Supermarket/ApiResponse/NotFoundResponse.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,24 @@ namespace Supermarket.ApiResponse
88
public class NotFoundResponse : ValidationProblemDetails
99
{
1010
public Guid TraceId { get; set; }
11+
1112
public NotFoundResponse(string error) : base(new Dictionary<string, string[]> { { "error", new[] { error } } })
1213
{
1314
TraceId = Guid.NewGuid();
1415
Title = HttpStatusCode.NotFound.ToString();
16+
Status = (int)HttpStatusCode.NotFound;
1517
}
18+
19+
////In feature, to log the not found response
20+
//public NotFoundResponse(string error, ILogger logger) : base(new Dictionary<string, string[]> { { "error", new[] { error } } })
21+
//{
22+
// TraceId = Guid.NewGuid();
23+
// Title = HttpStatusCode.NotFound.ToString();
24+
// Status = (int)HttpStatusCode.NotFound;
25+
// logger.LogInformation(JsonConvert.SerializeObject(this,
26+
// Formatting.Indented,
27+
// new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
28+
// ));
29+
//}
1630
}
1731
}

0 commit comments

Comments
 (0)