async Task SaveCharacter() { var isInsert = false; if (string.IsNullOrWhiteSpace(CharacterVM._id)) { CharacterVM._id = Guid.NewGuid().ToString(); isInsert = true; } var hpCharacter = CharacterVM.GetCharacter(); var success = 0; var useLocalStorage = Preferences.Get("UsingLocalStorage", true); if (useLocalStorage) { success = await App.Context.SaveItemAsync <HPCharacter>(hpCharacter, isInsert); } else { var service = new RESTService(); HPCharacter result; if (isInsert) { result = await service.AddCharacter(hpCharacter); } else { result = await service.EditCharacter(hpCharacter); } success = result != null ? 2 : 0; } await UserDialogs.Instance.AlertAsync((success > 0)? "Success!" : "Error!", "Saving...", "OK"); }