You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicstaticclassSRModelStateDictionaryExtensions{publicstaticboolIsFailed(thisModelStateDictionarymodelState);publicstatic Result Invalid(thisModelStateDictionarymodelState);publicstatic Result Invalid(thisModelStateDictionarymodelState,stringmessage);publicstatic BadRequestObjectResult BadRequest(thisModelStateDictionarymodelState);publicstatic BadRequestObjectResult BadRequest(thisModelStateDictionarymodelState,stringmessage);}
SRModelStateDictionaryExtensions contains methods that convert an instance of ModelStateDictionary into an instance of type Result.
The SR "prefix" is so as not to cause name conflicts.
Usage
[Route("api/[controller]")]publicclassPersonController:ControllerBase{[HttpPost]publicActionResult<Result<CreatedId>>Create([FromBody]Personperson){if(ModelState.IsFailed())return ModelState.BadRequest();// Some code..}}
The text was updated successfully, but these errors were encountered:
These extension methods will be added to the ModelStateDictionary type:
SRModelStateDictionaryExtensions
contains methods that convert an instance ofModelStateDictionary
into an instance of typeResult
.The SR "prefix" is so as not to cause name conflicts.
Usage
The text was updated successfully, but these errors were encountered: