Skip to content

Commit abfac54

Browse files
committed
Refactored
1 parent 2a66733 commit abfac54

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Simplify.Web.Json/ModelBinding/Binders/JsonModelBinder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ public class JsonModelBinder : IModelBinder
1616
/// <param name="args">The <see cref="ModelBinderEventArgs{T}"/> instance containing the event data.</param>
1717
public void Bind<T>(ModelBinderEventArgs<T> args)
1818
{
19-
if (args.Context.Request.ContentType.Contains("application/json"))
20-
{
21-
if (string.IsNullOrEmpty(args.Context.RequestBody))
22-
throw new ModelValidationException("JSON request body is null or empty");
19+
if (!args.Context.Request.ContentType.Contains("application/json"))
20+
return;
2321

24-
args.SetModel(JsonConvert.DeserializeObject<T>(args.Context.RequestBody));
25-
}
22+
if (string.IsNullOrEmpty(args.Context.RequestBody))
23+
throw new ModelValidationException("JSON request body is null or empty");
24+
25+
args.SetModel(JsonConvert.DeserializeObject<T>(args.Context.RequestBody));
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)