public HttpResponseMessage GetShippingAddress() { ShippingAddressService shippingaddressservice = new ShippingAddressService(); List <ShippingAddress> shippingaddress = shippingaddressservice.Read(); string shippingaddressJSON = JsonConvert.SerializeObject(shippingaddress, Formatting.Indented); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(shippingaddressJSON, Encoding.UTF8, "application/json"); return(response); }
public HttpResponseMessage GetShippingAddress(string key) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Unused); ShippingAddressService shippingaddressservice = new ShippingAddressService(); List <ShippingAddress> shippingAddress = shippingaddressservice.Read(); int id = shippingaddressservice.GetIndex(key); if (id != -1) { ShippingAddress sa = shippingAddress[id]; string shippingaddressJSON = JsonConvert.SerializeObject(sa, Formatting.Indented); response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StringContent(shippingaddressJSON, Encoding.UTF8, "application/json"); } else { response = new HttpResponseMessage(HttpStatusCode.ExpectationFailed); response.Content = new StringContent("Error", Encoding.UTF8, "application/json"); } return(response); }