public void AddUser(string id) { if (users.Find(x => x.name == id) == null) { var user = new CloudAPI.AdminData() { name = id }; users.Add(user); StartCoroutine(cloud.PostAdmin(user, (long responseCode) => { Debug.Log("Admin added!"); }, (CloudAPI.ErrorDetails error) => { Debug.LogError(error); })); } else { Debug.Log("already registred"); } DestroyItems(); RenderList(); }
public IEnumerator DeleteAdmin(AdminData admin, Action <long> onSuccess, Action <ErrorDetails> onError) { return(WebRequest( RequestType.kDELETE, $"{baseURI}/admins", ConvertOnSuccess(onSuccess), onError, JSONRequestBody.FromObject(admin))); }
public IEnumerator PostAdmin(AdminData admin, Action <long> onSuccess, Action <ErrorDetails> onError) { yield return(new WaitForSeconds(waitDelay)); if (forcedError != null) { onError(forcedError); yield break; } admins.Add(admin); onSuccess(200); }
public IEnumerator DeleteAdmin(AdminData admin, Action <long> onSuccess, Action <ErrorDetails> onError) { yield return(new WaitForSeconds(waitDelay)); if (forcedError != null) { onError(forcedError); yield break; } int count = admins.RemoveAll((AdminData a) => { return(a.name == admin.name); }); if (count != 0) { onSuccess(200); } else { onError(GenProtocolErrorDetails(400)); } }