public static LinkResult CreateLink(this HttpRequestMessage request, string routeName, object routeValues, HateoasType type, bool isTemplate, HateoasMethodType method) { string rel = string.Empty; switch (type) { case HateoasType.Self: rel = "self"; CorrectRouteValues(request, routeValues); break; case HateoasType.Start: rel = "start"; break; case HateoasType.Item: rel = "item"; break; case HateoasType.Collection: rel = "collection"; break; case HateoasType.Previous: rel = "previous"; CorrectRouteValues(request, routeValues); break; case HateoasType.Next: rel = "next"; CorrectRouteValues(request, routeValues); break; case HateoasType.First: rel = "first"; CorrectRouteValues(request, routeValues); break; case HateoasType.Last: rel = "last"; CorrectRouteValues(request, routeValues); break; case HateoasType.Create: rel = "create"; break; case HateoasType.Edit: rel = "edit"; break; case HateoasType.Delete: rel = "delete"; break; case HateoasType.Related: rel = "related"; break; } return(CreateLink(request, routeName, routeValues, rel, isTemplate, method)); }
public static LinkResult CreateLink(this HttpRequestMessage request, string routeName, object routeValues, HateoasType type, bool isTemplate) { return(CreateLink(request, routeName, routeValues, type, false, HateoasMethodType.GET)); }
public static LinkResult CreateLink(this HttpRequestMessage request, string routeName, object routeValues, HateoasType type) { return(CreateLink(request, routeName, routeValues, type, false)); }
public static LinkResult CreateLink(this HttpRequestMessage request, string routeName, HateoasType type, HateoasMethodType method) { return(CreateLink(request, routeName, null, type, false, method)); }
public static LinkResult CreateLink <T, U>(this HttpRequestMessage request, string routeName, PaggingResult <T> result, PaggingCriteria <U> pagging, HateoasType type, HateoasMethodType method) { if (type == HateoasType.Self) { if (result != null) { if (pagging == null) { return(CreateLink(request, routeName, new Dictionary <string, object>(), HateoasType.Self, false, method)); } else { var routeValues = new Dictionary <string, object>() { { "limit", pagging.Limit }, { "offset", pagging.Offset } }; return(CreateLink(request, routeName, routeValues, HateoasType.Self, false, method)); } } } if (type == HateoasType.Previous) { int offset = (pagging != null ? pagging.Offset : 0); int limit = (pagging != null ? pagging.Limit : PaggingCriteria <T> .MaxQtyByQueryPage); if (offset > 0) { var routeValues = new Dictionary <string, object>() { { "limit", limit }, { "offset", offset - 1 } }; return(CreateLink(request, routeName, routeValues, HateoasType.Previous, false, method)); } } if (type == HateoasType.First) { int offset = (pagging != null ? pagging.Offset : 0); int limit = (pagging != null ? pagging.Limit : PaggingCriteria <T> .MaxQtyByQueryPage); if (offset > 0) { var routeValues = new Dictionary <string, object>() { { "limit", limit }, { "offset", 0 } }; return(CreateLink(request, routeName, routeValues, HateoasType.First, false, method)); } } if (type == HateoasType.Next) { int offset = (pagging != null ? pagging.Offset : 0); int limit = (pagging != null ? pagging.Limit : PaggingCriteria <T> .MaxQtyByQueryPage); if (offset < result.Summary.TotalPages - 1) { var routeValues = new Dictionary <string, object>() { { "limit", limit }, { "offset", offset + 1 } }; return(CreateLink(request, routeName, routeValues, HateoasType.Next, false, method)); } } if (type == HateoasType.Last) { int offset = (pagging != null ? pagging.Offset : 0); int limit = (pagging != null ? pagging.Limit : PaggingCriteria <T> .MaxQtyByQueryPage); if (offset < result.Summary.TotalPages - 1) { var routeValues = new Dictionary <string, object>() { { "limit", limit }, { "offset", result.Summary.TotalPages } }; return(CreateLink(request, routeName, routeValues, HateoasType.Last, false, method)); } } return(null); }
public static LinkResult CreateLink <T, U>(this HttpRequestMessage request, string routeName, PaggingResult <T> result, PaggingCriteria <U> pagging, HateoasType type) { return(CreateLink <T, U>(request, routeName, result, pagging, type, HateoasMethodType.GET)); }