This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var queryString = HttpUtility.ParseQueryString(context.Request.RequestUri.Query); | |
| var brandName = queryString.Get("brand"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int offset = 0; | |
| int limit = 0; | |
| var queryString = HttpUtility.ParseQueryString(context.Request.RequestUri.Query); | |
| if(queryString.Count == 0) return; | |
| int.TryParse(queryString.Get("offset"), out offset); | |
| int.TryParse(queryString.Get("limit"), out limit); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Get our returned entityModel from the response | |
| IEnumerable model = null; | |
| context.Response.TryGetContentValue(out model); | |
| if (model == null) return; | |
| //Change response if limit or offset is not zero | |
| IEnumerable result = null; | |
| if ((limit + offset) > 0) | |
| { | |
| result = model.Take(limit).Skip(offset); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var objectContent = context.ActionContext?.Response?.Content as ObjectContent; | |
| if (objectContent != null) | |
| objectContent.Value = result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PagingFilter : ActionFilterAttribute | |
| { | |
| public override void OnActionExecuted(HttpActionExecutedContext context) | |
| { | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PagingFilter : ActionFilterAttribute | |
| { | |
| public override void OnActionExecuted(HttpActionExecutedContext context) | |
| { | |
| int offset = 0; | |
| int limit = 0; | |
| var queryString = HttpUtility.ParseQueryString(context.Request.RequestUri.Query); | |
| if(queryString.Count == 0) return; | |
| int.TryParse(queryString.Get("offset"), out offset); | |
| int.TryParse(queryString.Get("limit"), out limit); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| config.Filters.Add(new PagingFiler()); | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| .EnableSwaggerUi(c => | |
| { | |
| ... | |
| c.InjectJavaScript(thisAssembly, "YourAssemblyName.YourFolder.removeTryItOutButton.js"); | |
| ... | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .EnableSwaggerUi(c => | |
| { | |
| ... | |
| c.CustomAsset("index", thisAssembly, "YourAssemblyName.YourFolder.index.html"); | |
| ... | |
| }); |