diff --git a/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host.config b/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host.config index 1a32a56..b527993 100644 --- a/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host.config +++ b/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host.config @@ -2,7 +2,6 @@ - diff --git a/F4SDM42WebApi/F4SD - M42WebApi.csproj b/F4SDM42WebApi/F4SD - M42WebApi.csproj index 80c5320..61434e1 100644 --- a/F4SDM42WebApi/F4SD - M42WebApi.csproj +++ b/F4SDM42WebApi/F4SD - M42WebApi.csproj @@ -13,7 +13,7 @@ false 6673a25d-33d6-4072-91d9-abed4be1a966 C4ITF4SD*.* - 1.4.0.9 + 1.4.0.10 true diff --git a/F4SDM42WebApi/F4SDM42WebApiController.cs b/F4SDM42WebApi/F4SDM42WebApiController.cs index 196e3bd..ede0285 100644 --- a/F4SDM42WebApi/F4SDM42WebApiController.cs +++ b/F4SDM42WebApi/F4SDM42WebApiController.cs @@ -296,7 +296,11 @@ namespace C4IT.F4SD public async Task getPickup(string name, [FromUri] EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, [FromUri] Int32 group = -1) { await Task.Delay(0); - EntityEnumeration enumerationTemp = GetEnumeration(name, mode); + var pickupName = ResolvePickupName(name); + if (string.IsNullOrWhiteSpace(pickupName)) + return HttpResponseExtensions.CreateResponse(Request, HttpStatusCode.BadRequest, "Pickup name is required."); + + EntityEnumeration enumerationTemp = GetEnumeration(pickupName, mode); var vals = enumerationTemp.Values; if (group > -1) @@ -395,6 +399,7 @@ namespace C4IT.F4SD private EntityEnumeration GetEnumeration(string name, EntityEnumerationVisibilityMode mode) { + name = name?.Trim(); var dataTable = GetEnumerationProvider().GetEnumeration(name, GetVisibilityFilter(mode)); if (dataTable == null) throw new InvalidOperationException($"Enumeration '{name}' was not found."); @@ -427,6 +432,20 @@ namespace C4IT.F4SD }; } + private string ResolvePickupName(string routeName) + { + if (!string.IsNullOrWhiteSpace(routeName)) + return routeName.Trim(); + + var pathSegment = Request?.RequestUri?.Segments? + .LastOrDefault(segment => !string.IsNullOrWhiteSpace(segment) && segment != "/"); + + if (string.IsNullOrWhiteSpace(pathSegment)) + return null; + + return Uri.UnescapeDataString(pathSegment.Trim('/')); + } + private static bool? GetVisibilityFilter(EntityEnumerationVisibilityMode mode) { switch (mode)