/// <summary>
 /// Creates a <see cref="GatewayTimeoutResult"/> object that produces a Gateway Timeout (504) response.
 /// </summary>
 /// <param name="controller">MVC controller instance.</param>
 /// <returns>The created <see cref="GatewayTimeoutResult"/> for the response.</returns>
 public static GatewayTimeoutResult GatewayTimeout(this ControllerBase controller)
 => new GatewayTimeoutResult();
 /// <summary>
 /// Creates a <see cref="ServiceUnavailableResult"/> object that produces an empty Service Unavailable (503) response.
 /// </summary>
 /// <param name="controller">MVC controller instance.</param>
 /// <returns>The created <see cref="ServiceUnavailableResult"/> for the response.</returns>
 public static ServiceUnavailableResult ServiceUnavailable(this ControllerBase controller)
 => new ServiceUnavailableResult();
 /// <summary>
 /// Creates a <see cref="ServiceUnavailableResult"/> object that produces a Service Unavailable (503) response.
 /// </summary>
 /// <param name="controller">MVC controller instance.</param>
 /// <param name="lengthOfDelay">Length of delay after which the server will be running again.</param>
 /// <returns>The created <see cref="ServiceUnavailableResult"/> for the response.</returns>
 public static ServiceUnavailableResult ServiceUnavailable(this ControllerBase controller, string lengthOfDelay)
 => new ServiceUnavailableResult(lengthOfDelay);
 /// <summary>
 /// Creates an <see cref="NotImplementedResult"/> object that produces a Not Implemented (501) response.
 /// </summary>
 /// <param name="controller">MVC controller instance.</param>
 /// <returns>The created <see cref="NotImplementedResult"/> for the response.</returns>
 public static NotImplementedResult NotImplemented(this ControllerBase controller)
 => new NotImplementedResult();
 /// <summary>
 /// Creates a <see cref="BadGatewayResult"/> object that produces a Bad Getaway (502) response.
 /// </summary>
 /// <param name="controller">MVC controller instance.</param>
 /// <returns>The created <see cref="BadGatewayResult"/> for the response.</returns>
 public static BadGatewayResult BadGateway(this ControllerBase controller)
 => new BadGatewayResult();
コード例 #6
0
 public static string GetStringCookie(this ControllerBase controllerBase, string key)
 {
     //read cookie from Request object
     return(controllerBase.Request.GetStringCookie(key));
 }
 /// <summary>
 /// Creates an <see cref="InternalServerErrorResult"/> object that produces an Internal Server Error (500) response.
 /// </summary>
 /// <param name="controller">MVC controller instance.</param>
 /// <returns>The created <see cref="InternalServerErrorResult"/> for the response.</returns>
 public static InternalServerErrorResult InternalServerError(this ControllerBase controller)
 => new InternalServerErrorResult();
コード例 #8
0
 public static int GetUserId(this ControllerBase controller)
 {
     return(controller.User.GetUserId());
 }
コード例 #9
0
 /// <summary>
 /// Returns a HTTP 200 OK with a paging result set from an IQueryable.
 /// </summary>
 /// <param name="controller">Base controller.</param>
 /// <param name="source">IQueryable source.</param>
 /// <returns></returns>
 public static PagingResult Paging(this ControllerBase controller, IQueryable source)
 {
     return(new PagingResult(source));
 }
コード例 #10
0
 public static void SetJsonCookie <T>(this ControllerBase controllerBase, string key, T value, int?expireTime)
 {
     controllerBase.Response.SetJsonCookie <T>(key, value, expireTime);
 }
コード例 #11
0
 public static T GetJsonCookie <T>(this ControllerBase controllerBase, string key) where T : class
 {
     //read cookie from Request object
     return(controllerBase.Request.GetJsonCookie <T>(key));
 }
 public static ActionResult ValidateAndBadRequest(this ControllerBase controller, object model = null, bool mapModel = false)
 {
     controller.UpdateValidations(model, mapModel);
     return(controller.BadRequest(controller.ModelState));
 }
コード例 #13
0
 /// <summary>
 /// Send <paramref name="request"/> through <see cref="IMediator"/>.
 /// </summary>
 /// <typeparam name="TResponse">Response type.</typeparam>
 /// <param name="controller">Controller.</param>
 /// <param name="request">Request.</param>
 /// <returns>Response from request.</returns>
 public static Task <TResponse> SendRequest <TResponse>(
     this ControllerBase controller,
     IRequest <TResponse> request)
 => controller.Mediator().Send(request);
コード例 #14
0
 /// <summary>
 /// Access to <see cref="IMediator"/>.
 /// </summary>
 /// <param name="controller">Controller.</param>
 /// <returns>Mediator.</returns>
 public static IMediator Mediator(this ControllerBase controller)
 => (IMediator)controller.HttpContext.RequestServices.GetService(typeof(IMediator));
 /// <summary>
 /// Creates a <see cref="HTTPVersionNotSupportedResult"/> object that produces a HTTP Version Not Supported (505) response.
 /// </summary>
 /// <param name="controller">MVC controller instance.</param>
 /// <param name="value">The precondition failed value to format in the entity body.</param>
 /// <returns>The created <see cref="HTTPVersionNotSupportedResult"/> for the response.</returns>
 public static HTTPVersionNotSupportedResult HTTPVersionNotSupported(this ControllerBase controller, object value)
 => new HTTPVersionNotSupportedResult(value);
コード例 #16
0
 /// <summary>
 /// Returns a HTTP 200 OK with a paging result set from an IQueryable.
 /// </summary>
 /// <typeparam name="T">Collection type of source.</typeparam>
 /// <param name="controller">Base controller.</param>
 /// <param name="source">IQueryable source.</param>
 /// <returns></returns>
 public static PagingResult <T> Paging <T>(this ControllerBase controller, IQueryable <T> source)
 {
     return(new PagingResult <T>(source));
 }
コード例 #17
0
        /// <summary>Create a HTTP action result from a service result.</summary>
        /// <typeparam name="T">The type of the result data.</typeparam>
        public static IActionResult ToActionResult <T>(this Result <T> result, Controller controller) =>
#if NETCOREAPP3_0_OR_GREATER
        result?.Status switch
        {
コード例 #18
0
 public static void SetStringCookie(this ControllerBase controllerBase, string key, string value, int?expireTime)
 {
     controllerBase.Response.SetStringCookie(key, value, expireTime);
 }