public bool AddSleeveToAccount(int id) { try { var req = new UpdateUserSleevesRequest(); req.Add(new ApiSleeve() { Id = id }); var c = new ApiClient(); AuthorizedResponse <int[]> result; result = Program.LobbyClient.IsConnected == false?c.AddUserSleeves(Prefs.Username, Prefs.Password.Decrypt(), req) : c.AddUserSleeves(Program.LobbyClient.Username, Program.LobbyClient.Password, req); if (result == null || result.Authorized == false || result.Response == null) { WindowManager.GrowlWindow.AddNotification(new ErrorNotification("There was a problem adding the sleeve to your account. Please check your internet settings.")); return(false); } if (result.Response.Contains(id)) { return(true); } } catch (Exception e) { Log.Error("AddSleeveToAccount", e); } WindowManager.GrowlWindow.AddNotification(new ErrorNotification("There was a problem adding the sleeve to your account. Please check your internet settings.")); return(false); }
public bool AddSleeveToAccount(int id) { try { var req = new UpdateUserSleevesRequest(); req.Add(new ApiSleeve() { Id = id }); var c = new ApiClient(); AuthorizedResponse<int[]> result; result = Program.LobbyClient.IsConnected == false ? c.AddUserSleeves(Prefs.Username, Prefs.Password.Decrypt(), req) : c.AddUserSleeves(Program.LobbyClient.Username, Program.LobbyClient.Password, req); if (result == null || result.Authorized == false || result.Response == null) { WindowManager.GrowlWindow.AddNotification(new ErrorNotification("There was a problem adding the sleeve to your account. Please check your internet settings.")); return false; } if (result.Response.Contains(id)) return true; } catch (Exception e) { Log.Error("AddSleeveToAccount", e); } WindowManager.GrowlWindow.AddNotification(new ErrorNotification("There was a problem adding the sleeve to your account. Please check your internet settings.")); return false; }
public AuthorizedResponse <int[]> AddUserSleeves(string username, string password, UpdateUserSleevesRequest req) { var client = Client; var resp = client.PostAsJsonAsync( "api/user/addsleeves?sleeveusername="******"&sleevepassword="******"Server Error"); } var list = resp.Content.ReadAsAsync <int[]>().Result; if (list == null) { throw new Exception("Response data is invalid\n" + resp.Content.ReadAsStringAsync().Result); } return(new AuthorizedResponse <int[]>(list, true)); }