private async void submitButtonClick(object sender, EventArgs e) { RelativeLayout rootLayout = FindViewById <RelativeLayout>(Resource.Id.add_user_board_game_view); loading.showLoadingView(rootLayout); BoardGame submitedBoardGame = getBoardGameObject(); bool exists = await checkIfTitleUnique(submitedBoardGame.Title); if (exists) { loading.hideLoadingView(rootLayout); Toast.MakeText(Application.Context, "This Board Game Already Exists", ToastLength.Long).Show(); return; } submitedBoardGame.Thumbnail = saveThumbnailAndReturnPath(submitedBoardGame.Title); submitedBoardGame.PhotoPaths = saveUserPhotosAndReturnPaths(submitedBoardGame.Title); string jsonData = JsonConvert.SerializeObject(submitedBoardGame, Formatting.None); ApiConnection apiConnection = new ApiConnection(); await apiConnection.sendRequest("api/boardgames/add/" + AppSharedPreferences.getUserNameFromSharedPreferences(), jsonData, Method.POST); loading.hideLoadingView(rootLayout); Finish(); }
public async Task <bool> checkIfTitleUnique(String title) { ApiConnection apiConnection = new ApiConnection(); var response = await apiConnection.sendRequest("api/boardgames/" + title + "/user/" + AppSharedPreferences.getUserNameFromSharedPreferences(), null, Method.GET); System.Diagnostics.Debug.WriteLine("Garfield"); System.Diagnostics.Debug.WriteLine(response.Content); bool exists = bool.Parse(response.Content); return(exists); }
public async Task <String> downloadUserBoardData() { ApiConnection apiConnection = new ApiConnection(); var request = await apiConnection.sendRequest("api/boardgames/user/" + AppSharedPreferences.getUserNameFromSharedPreferences(), null, RestSharp.Method.GET); return(request.Content); }