public string BuildLocationFilter(GetLocationFromBody locationFromBody) { var filter = $"st eq '{locationFromBody.Site}'"; var escapedFilter = Uri.EscapeUriString(filter); return(escapedFilter); }
public async Task <Result <LocationSiteModel> > GetLocation(GetLocationFromBody getLocationFromBody) { var filter = _filterBuildService.BuildLocationFilter(getLocationFromBody); var response = await _eccSetupRestApi.GetLocation($"{UrlsConfig.EccSetup}{UrlsConfig.EccSetupOperations.GetLocation(_apiVersion, filter)}"); if (response.StatusCode == HttpStatusCode.OK) { var contentAsString = await response.Content.ReadAsStringAsync(); var locationsModel = _jsonService.DeserializeObject <LocationsModel>(contentAsString); var locationModel = _locationBuildService.BuildLocation(locationsModel); return(Result.Ok(locationModel)); } else { return(Result.Fail <LocationSiteModel>("Error on getting location")); } }
public async Task <IActionResult> GetLocation([FromBody] GetLocationFromBody getLocationFromBody) { var result = await _mobileService.GetLocation(getLocationFromBody); if (result.IsSuccess) { var data = result.Value; var response = new JsonResult(Envelope.Ok(data)); response.StatusCode = (int)HttpStatusCode.OK; return(response); } else { var response = new JsonResult(Envelope.Error(result.Error)); response.StatusCode = (int)HttpStatusCode.BadRequest; return(response); } }