public IEnumerator Update <T> (T item, Action <IRestResponse <T> > callback = null) where T : new() { string id = null; // Check if model uses the 'IDataModel' Interface to get id property, otherwise try Refelection (using 'Model' helper). IDataModel model = item as IDataModel; if (model != null) { id = model.GetId(); } else if (Model.HasField(item, "id")) { var x = Model.GetField(item, "id"); id = x.GetValue(item) as string; } else { Debug.LogError("Unable to get 'id' data model property"); } if (string.IsNullOrEmpty(id)) { Debug.LogError("Error 'id' value is missing"); yield return(null); } string url = string.Format("{0}/{1}{2}/{3}", _client.AppUrl, URI_TABLES, _name, id); ZumoRequest request = new ZumoRequest(_client, url, Method.PATCH); request.AddBody(item); Debug.Log("Update Request Url: " + url + " patch:" + item); yield return(request.request.Send()); request.ParseJson <T> (callback); }
public IEnumerator Update <T>(T item, Action <IRestResponse <T> > callback = null) where T : new() { string id = null; // Check if item uses the 'IDataModel' Interface to get 'id' property, otherwise try Refelection (using Reflection helper). IDataModel model = item as IDataModel; if (model != null) { id = model.GetId(); } else if (ReflectionHelper.HasField(item, "id")) { var x = ReflectionHelper.GetField(item, "id"); id = x.GetValue(item) as string; } else { Debug.LogError("Unable to get 'id' data model property"); } if (string.IsNullOrEmpty(id)) { Debug.LogError("Error 'id' value is missing"); yield return(null); } string url = TableUrl(_name, id); ZumoRequest request = new ZumoRequest(url, Method.PATCH, true, _client.User); request.AddBody(item); Debug.Log("Update Request Url: " + url + " patch:" + item); yield return(request.Request.Send()); request.ParseJson <T>(callback); }
public void Update <T>(T item, Action <IRestResponse <T> > callback = null) where T : new() { string id = null; // Check if model uses the 'IDataModel' Interface to get id property, otherwise try Refelection (using 'Model' helper). IDataModel model = item as IDataModel; if (model != null) { id = model.GetId(); } else if (Model.HasProperty(item, "id")) { var x = Model.GetProperty(item, "id"); id = x.GetValue(item, null) as string; } else { Debug.LogError("Unable to get 'id' data model property"); } if (string.IsNullOrEmpty(id)) { Debug.LogError("Error 'id' value is missing"); return; } string uri = URI_TABLES + _name + "/" + id; ZumoRequest request = new ZumoRequest(_client, uri, Method.PATCH); Debug.Log("Update Request Uri: " + uri); request.AddBody(item); _client.ExecuteAsync <T>(request, callback); }