Example #1
0
        public Task <int> SaveCredentialAsync(SocialMediaCredential credential)
        {
            //ID = 0 , default value >> new user
            if (credential.ID == 0)
            {
                return(_database.InsertAsync(credential));
            }

            //Update user
            return(_database.UpdateAsync(credential));
        }
Example #2
0
        async private void toolbarItemAdd_Clicked(object sender, EventArgs e)
        {
            Credential newCredential = newCredential = new Credential();
            // create new credential
            string result = await DisplayActionSheet("Choose a credential type from the following:", "Cancel", null, Credential.credentialTypes);

            if (!string.IsNullOrWhiteSpace(result) && result.ToLower() != "cancel")
            {
                switch (result)
                {
                case "Default":
                    break;

                case "Social Media":
                    newCredential = new SocialMediaCredential();
                    break;

                case "Banking":
                    newCredential = new BankCredential();
                    break;

                case "Wifi":
                    newCredential = new WifiCredential();
                    break;

                default:
                    await DisplayAlert("Error", "Invalid credential type", "ok");

                    break;
                }
                await Clipboard.SetTextAsync(string.Empty);

                searchBar.Text = string.Empty;
                await Navigation.PushAsync(new CredentialDetailPage(newCredential, _credentials));
            }
        }