/// <summary>
        /// Remove um cartão de crédito da carteira
        /// </summary>
        /// <param name="number">Número do cartão</param>
        public void RemoveCreditCard(long number)
        {
            if (CreditCards.FirstOrDefault(a => a.Number == number) == null)
            {
                throw new InvalidOperationException("Cartão de crédito não encontrado");
            }

            var card = CreditCards.First(a => a.Number == number);

            _creditCards.Remove(card);
        }
        public Person Take(CreditCardDeactivateCommand command)
        {
            var creditCard = CreditCards.First(c => c.Id == command.CreditCardId);

            creditCard.Take(command);

            base.AddEvent(new PersonCreditCardUpdateDomainEvent
            {
                AggregateRootId = Id,
                CommandJson     = JsonConvert.SerializeObject(command),
                UserId          = command.UserId
            });

            return(this);
        }
        public Person Take(CreditCardDeleteCommand command)
        {
            var creditCard = CreditCards.First(e => e.Id == command.CreditCardId);

            this.CreditCards.Remove(creditCard);

            base.AddEvent(new PersonCreditCardDeleteDomainEvent
            {
                AggregateRootId = Id,
                CommandJson     = JsonConvert.SerializeObject(command),
                UserId          = command.UserId
            });

            return(this);
        }
        public override async void OnViewStarted(bool firstTime)
        {
            base.OnViewStarted(firstTime);

            if (firstTime)
            {
                _creditCardCompanies = new List <ListItem>
                {
                    new ListItem {
                        Display = Visa, Image = "visa"
                    },
                    new ListItem {
                        Display = MasterCard, Image = "mastercard"
                    },
                    new ListItem {
                        Display = Amex, Image = "amex"
                    },
                    new ListItem {
                        Display = VisaElectron, Image = "visa_electron"
                    },
                    new ListItem {
                        Display = Discover, Image = "discover"
                    },
                    new ListItem {
                        Display = CreditCardGeneric, Image = "credit_card_generic"
                    }
                };

                using (this.Services().Message.ShowProgress())
                {
                    await GetCreditCards();

                    CreditCardSelected = CreditCards.First(cc => cc.IsDefault.Value).Id.Value;
                }
            }
            else
            {
                await GetCreditCards();
            }
        }