private async Task ExecuteAddCardCommand() { if (string.IsNullOrEmpty(CardName.DefaultString())) { await DisplayAlert("Information", "Enter the name!", "OK"); return; } if (string.IsNullOrEmpty(CardNumber.DefaultString())) { await DisplayAlert("Information", "Enter the card number!", "OK"); return; } if (CardNumber.DefaultString().Length < 16 || CardNumber.DefaultString().Length < 15) { await DisplayAlert("Information", "Incomplete card number!", "OK"); return; } if (!CreditCardHelper.IsValidCreditCardNumber(CardNumber)) { await DisplayAlert("Information", "Card number is invalid!", "OK"); return; } if (string.IsNullOrEmpty(CardExpirationDate.DefaultString())) { await DisplayAlert("Information", "Enter the expiration date!", "OK"); return; } if (string.IsNullOrEmpty(CardCVV.DefaultString())) { await DisplayAlert("Information", "Enter the secuity code!", "OK"); return; } var confirm = await DisplayAlert("Confirmation", "Confirm registration?", "YES", "NO"); if (confirm) { var card = new Card() { cardName = CardName, cardNumber = CardNumber.RemoveNonNumbers(), cardExpirationDate = CardExpirationDate, cardCVV = CardCVV, cardFlag = CardFlag }; card.cardFlag = CreditCardHelper.FindFlagCard(card.cardNumber); MessagingCenter.Send(this, "addCard", card); await PopupNavigation.Instance.PopAsync(true); } }