public async Task <VanLocationSearchModel> GetVanLocations(VanLocationSearchModel model) { var url = LogisticsApiUri + "/VanLocation/GetVanLocations?" + GetFilterStringForVanLocation(model); var result = await GetOdataResultFromApi(url); var searchResultCount = 0; if (result.Count != null) { int.TryParse(result.Count.ToString(), out searchResultCount); } model.TotalRows = searchResultCount; model.VanLocationSearchResult.Clear(); model.VanLocationSearchResult.AddRange(result.Items.Select(item => JsonConvert.DeserializeObject <VanLocationDto>(item.ToString()))); return(model); }
private string GetFilterStringForVanLocation(VanLocationSearchModel vanLocationSearchModel) { var filterString = ""; if (vanLocationSearchModel != null) { if (!string.IsNullOrWhiteSpace(vanLocationSearchModel.RegistrationNumber)) { if (string.IsNullOrWhiteSpace(filterString)) { filterString = ODataFilterConstant.Filter + $"RegistrationNumber eq '{vanLocationSearchModel.RegistrationNumber}'"; } else { filterString += $" and RegistrationNumber eq '{vanLocationSearchModel.RegistrationNumber}'"; } } else if (!string.IsNullOrWhiteSpace(vanLocationSearchModel.EmployeeRef)) { if (string.IsNullOrWhiteSpace(filterString)) { filterString = ODataFilterConstant.Filter + $"EmployeeRef eq '{vanLocationSearchModel.EmployeeRef}'"; } else { filterString += $" and EmployeeRef eq '{vanLocationSearchModel.EmployeeRef}'"; } } else if (!string.IsNullOrWhiteSpace(vanLocationSearchModel.FilterText)) { if (string.IsNullOrWhiteSpace(filterString)) { filterString = ODataFilterConstant.Filter + $" substringof('{vanLocationSearchModel.FilterText}',Name) eq true"; } else { filterString += $" and substringof('{vanLocationSearchModel.FilterText}',Name) eq true"; } filterString += $" and substringof('{vanLocationSearchModel.FilterText}',RegistrationNumber) eq true"; } AddPageSizeNumberAndSortingInFilterString(vanLocationSearchModel, ref filterString); } return(filterString); }
public IActionResult TrackOperative(string propertyreference, string operativecode) { var model = new VanLocationSearchModel { EmployeeRef = operativecode }; var van = _propertyFacadeApiClient.GetVanLocations(model).Result.VanLocationSearchResult.FirstOrDefault(); var property = _propertyFacadeApiClient.GetPropertyDetailView(propertyreference).Result; var route = new DeliveryRouteDto(); if (van != null) { route.SourceLongitude = van.Longitude; route.SourceLatitude = van.Latitude; } if (property?.Latitude != null && property.Longitude.HasValue) { route.DestinationLatitude = (double)property.Latitude.Value; route.DestinationLongitude = (double)property.Longitude.Value; } return(View("TrackOperative", route)); }
public async Task <VanLocationSearchModel> GetVanLocations(VanLocationSearchModel model) { return(await _propertyApiClient.GetVanLocations(model)); }