Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Added UnprocessableEntity overloads to ControllerBase
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristian Hellang committed Sep 19, 2017
1 parent 6402d29 commit a8efc6d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Microsoft.AspNetCore.Mvc.Core/ControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,41 @@ public virtual BadRequestObjectResult BadRequest(ModelStateDictionary modelState
return new BadRequestObjectResult(modelState);
}

/// <summary>
/// Creates an <see cref="UnprocessableEntityResult"/> that produces a <see cref="StatusCodes.Status422UnprocessableEntity"/> response.
/// </summary>
/// <returns>The created <see cref="UnprocessableEntityResult"/> for the response.</returns>
[NonAction]
public virtual UnprocessableEntityResult UnprocessableEntity()
{
return new UnprocessableEntityResult();
}

/// <summary>
/// Creates an <see cref="UnprocessableEntityObjectResult"/> that produces a <see cref="StatusCodes.Status422UnprocessableEntity"/> response.
/// </summary>
/// <returns>The created <see cref="UnprocessableEntityObjectResult"/> for the response.</returns>
[NonAction]
public virtual UnprocessableEntityObjectResult UnprocessableEntity(object error)
{
return new UnprocessableEntityObjectResult(error);
}

/// <summary>
/// Creates an <see cref="UnprocessableEntityObjectResult"/> that produces a <see cref="StatusCodes.Status422UnprocessableEntity"/> response.
/// </summary>
/// <returns>The created <see cref="UnprocessableEntityObjectResult"/> for the response.</returns>
[NonAction]
public virtual UnprocessableEntityObjectResult UnprocessableEntity(ModelStateDictionary modelState)
{
if (modelState == null)
{
throw new ArgumentNullException(nameof(modelState));
}

return new UnprocessableEntityObjectResult(modelState);
}

/// <summary>
/// Creates an <see cref="BadRequestObjectResult"/> that produces a <see cref="StatusCodes.Status400BadRequest"/> response.
/// </summary>
Expand Down

0 comments on commit a8efc6d

Please sign in to comment.