Exemplo n.º 1
0
 public bool edit(Photo photo)
 {
     try
     {
         DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Photo));
         MemoryStream mem = new MemoryStream();
         ser.WriteObject(mem, photo);
         string data = Encoding.UTF8.GetString(mem.ToArray());
         WebClient webClient = new WebClient();
         webClient.Headers["content-type"] = "application/json";
         webClient.Encoding = Encoding.UTF8;
         webClient.UploadString(BASE_URL + "/edit", "PUT", data);
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 2
0
 public bool create(Photo photo)
 {
     try
     {
         DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Photo));
         MemoryStream mem = new MemoryStream();
         ser.WriteObject(mem, photo);
         string data = Encoding.UTF8.GetString(mem.ToArray());
         WebClient webClient = new WebClient();
         webClient.Headers["content-type"] = "application/json";
         webClient.Encoding = Encoding.UTF8;
         webClient.UploadString(BASE_URL + "/create", "POST", data);
         return true;
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("create " + ex.Message);
         return false;
     }
 }