public static int SavePharmacy(Pharmacy item) { // JsonSerializerSettings jsonSerSet = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; // string json = JsonConvert.SerializeObject( item, Formatting.Indented,jsonSerSet); // var bytes = Encoding.Default.GetBytes (json); // // Pharmacy afterUpload = null; // // using (WebClient wb = new WebClient ()) { // wb.Headers.Add(HttpRequestHeader.ContentType, @"application/json"); // var response = wb.UploadData ("http://sbl-logisapp.rhcloud.com/pharmacy", @"POST", bytes); // // string pharmacy = Encoding.Default.GetString (response); // afterUpload = JsonConvert.DeserializeObject<Pharmacy> (pharmacy); // } return(PharmacyRepository.SavePharmacy(item)); }
public static int DeletePharmacy(int id) { RestClient _restClient = new RestClient(); var request = new RestRequest(@"http://sbl-logisapp.rhcloud.com/pharmacy/{id}", Method.DELETE); request.AddUrlSegment("id", "" + id); // Console.WriteLine ("Executing '{0}' request to '{1}'...", request.Method, _restClient.BuildUri (request)); var response = _restClient.Execute(request); if (response.StatusCode == HttpStatusCode.NotFound) { throw new Exception("Build does not exist for ID: " + id); } // CheckForError(response); // CheckForExpectedStatusCode(response, HttpStatusCode.NoContent); return(PharmacyRepository.DeletePharmacy(id)); }
public static IList <Pharmacy> GetPharmacies(string search = @"", int num = -1) { if (string.IsNullOrEmpty(search)) { if (num == -1) { return(new List <Pharmacy> (PharmacyRepository.GetPharmacies())); } else { return(new List <Pharmacy> (PharmacyRepository.GetPharmacies(num))); } } else { return(new List <Pharmacy> (PharmacyRepository.GetPharmacies(search))); } }
public static IList <Pharmacy> GetPharmacies(int[] ids) { return(new List <Pharmacy> (PharmacyRepository.GetPharmacies(ids))); }
public static IList <Pharmacy> GetPharmacies(int page = 0, int num = 10) { return(new List <Pharmacy> (PharmacyRepository.GetPharmacies(page * num, num))); }
public static Pharmacy GetPharmacy(int id) { return(PharmacyRepository.GetPharmacy(id)); }
public static void Refresh() { PharmacyRepository.Refresh(); }