public PaymentCardPresenter(PaymentCardDTO paymentCardDTO)
        {
            this.HolderName    = paymentCardDTO.HolderName;
            this.CardNumber    = paymentCardDTO.CardNumber;
            this.stripecardId  = paymentCardDTO.StripeCardId;
            this.PaymentCardId = paymentCardDTO.PaymentCardId;


            DeleteCardCommand = new Command(async() =>
            {
                var deleted = await CardDataStore.DeletePaymentCard(paymentCardId.ToString());

                if (deleted)
                {
                    var cardDeleteStripeResult = await stripeServiceDS.DeleteCardFromCustomer(App.LogUser.StripeUserId, this.StipeCardId);

                    if (cardDeleteStripeResult)
                    {
                        MessagingCenter.Send <PaymentCardPresenter>(this, "PaymencardDeleteMsg");
                    }
                }


                //await Shell.Current.GoToAsync($"{EditCardPage.Route}");
            });
        }
Beispiel #2
0
        public async Task <IEnumerable <PaymentCardDTO> > GetCardDTOFromUser(Guid userId)
        {
            var cards = await _context.PaymentCards.Where(c => c.UserId == userId).ToListAsync();

            List <PaymentCardDTO> paymentCardDTOs = new List <PaymentCardDTO>();

            foreach (var item in cards)
            {
                try
                {
                    string cardlastfour = item.CardNumber.Substring((item.CardNumber.Length - 4));
                    var    cardDtO      = new PaymentCardDTO()
                    {
                        CardNumber    = "●●●●" + cardlastfour,
                        HolderName    = item.HolderName,
                        StripeCardId  = item.StripeCardId,
                        PaymentCardId = item.PaymentCardId
                    };

                    paymentCardDTOs.Add(cardDtO);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            return(paymentCardDTOs);
        }
        public async Task <ActionResult> CreatePaymentCard(PaymentCardDTO paymentCardDTO)
        {
            // Get the userId from the token
            var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            var user = await _repo.GetUserById(userId);

            var paymentCard = _mapper.Map <PaymentCard>(paymentCardDTO);

            paymentCard.CurrencyType = "cad";

            user.PaymentCard = paymentCard;

            _repo.Update(user);

            // if the repo is saved successfully, return NoContent
            if (await _repo.SaveAll())
            {
                var paymentCardToReturn = _mapper.Map <PaymentCardDTO>(paymentCard);
                return(Ok(paymentCardToReturn));
            }

            return(BadRequest("Could not add the parking lot"));
        }