public AccreditationApplications getAccreditDetails(string accommoId) { string json = null; AccreditationApplications acc = null; try { WebClient webClient = new WebClient(); json = webClient.DownloadString(BASE_URL + "getAccreditDetails/" + accommoId); acc = JsonConvert.DeserializeObject <AccreditationApplications>(json); return(acc); } catch { return(null); } }
//Updates public string updateAccredApplication(AccreditationApplications application) { string response = ""; string data = null; try { DataContractJsonSerializer ser = new DataContractJsonSerializer( typeof(AccreditationApplications)); MemoryStream mem = new MemoryStream(); ser.WriteObject(mem, application); data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length); WebClient webClient = new WebClient(); webClient.Headers["Content-type"] = "application/json"; webClient.Encoding = Encoding.UTF8; response = webClient.UploadString(BASE_URL + "updateAccredApplication", "PUT", data); return(response); } catch (Exception e) { return(e.Message); } }
//Insertions public int applyForAccred(AccreditationApplications application) { string response = null; string data = null; try { DataContractJsonSerializer ser = new DataContractJsonSerializer( typeof(AccreditationApplications)); MemoryStream mem = new MemoryStream(); ser.WriteObject(mem, application); data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length); WebClient webClient = new WebClient(); webClient.Headers["Content-type"] = "application/json"; webClient.Encoding = Encoding.UTF8; response = webClient.UploadString(BASE_URL + "applyForAccred", "POST", data); return(Convert.ToInt32(response)); } catch (Exception) { return(-1); } }