public HttpResponseMessage Get_Bus_Locations() { string body = Request.Content.ReadAsStringAsync().Result; GetBusLocationsRequestModel request = JsonConvert.DeserializeObject <GetBusLocationsRequestModel>(body); GetBusLocationsResponseModel response = Get_Bus_Locations_Implementation(request); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new StringContent(response.ToString(), Encoding.UTF8, ContentTypes.Json); return(result); }
public HttpResponseMessage PossibleLocations() { string body = Request.Content.ReadAsStringAsync().Result; LocationsRequestModel locationsRequestModel = JsonConvert.DeserializeObject <LocationsRequestModel>(body); GetBusLocationsRequestModel getBusLocationsRequestModel = new GetBusLocationsRequestModel(); getBusLocationsRequestModel.Session = new Model.obilet.Abstract.Json.JsonSession(); getBusLocationsRequestModel.Session.DeviceID = locationsRequestModel.Auth.DeviceKey; getBusLocationsRequestModel.Session.SessionID = locationsRequestModel.Auth.SessionKey; getBusLocationsRequestModel.Date = DateTime.Now; getBusLocationsRequestModel.Language = "tr-TR"; getBusLocationsRequestModel.Data = (locationsRequestModel.Data.Query == "") ? null : locationsRequestModel.Data.Query; GetBusLocationsResponseModel getBusLocationsResponseModel = Get_Bus_Locations_Implementation(getBusLocationsRequestModel); LocationsDataModel locationsDataModel = new LocationsDataModel(); locationsDataModel.Locations = new List <JsonLocation>(); foreach (Model.obilet.Abstract.Json.JsonBusLocation busLocation in getBusLocationsResponseModel.Data) { locationsDataModel.Locations.Add(new JsonLocation() { ID = busLocation.ID, Name = busLocation.Name, Search = busLocation.Name.ToLower().Replace("(", "").Replace(")", "") }); } LocationsResponseModel result = new LocationsResponseModel() { Meta = new JsonMeta() { Status = "success", Message = "Everything is fine" }, Data = locationsDataModel }; string content = JsonConvert.SerializeObject(result); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StringContent(content, Encoding.UTF8, ContentTypes.Json); return(response); }