Beispiel #1
0
 public DeleteResult Delete(Guid id)
 {
     try
     {
         Connector.IsTransaction = true;
         PartnerCardDTO card   = ReadById(id);
         bool           result = false;
         if (card != null)
         {
             CardService cardService = new CardService();
             cardService.Delete(card.Partner.StripeId, card.StripeId);
             result = Repository.Delete(id);
             Connector.CommitTransaction();
         }
         else
         {
             Connector.RollbackTransaction();
         }
         return(result ? DeleteResult.OK : DeleteResult.NotFound);
     }
     catch (Exception exception)
     {
         Connector.RollbackTransaction();
         throw exception;
     }
 }
        public IActionResult DeleteCard(int id, int boardId)
        {
            if (!ModelState.IsValid) RedirectToAction("Index", "Board", new { id = boardId });

            _cardService.Delete(id);

            return RedirectToAction("Index", "Board", new { id = boardId });
        }
Beispiel #3
0
        public void RemoveCard(string customerId, string cardId)
        {
            StripeConfiguration.ApiKey = secretkey;
            var service = new CardService();
            var card    = service.Delete(customerId, cardId);

            Console.WriteLine($"Card: {JsonConvert.SerializeObject(card)}");
        }
        public int Delete(int cardId)
        {
            var     map  = mapper.CreateMapper();
            CardDTO card = CardService.Get(cardId);
            int     i    = CardService.Delete(card);

            return(i);
        }
Beispiel #5
0
        public static Card RemoveCard(string cusId, string cardId)
        {
            // Set your secret key: remember to change this to your live secret key in production
            // See your keys here: https://dashboard.stripe.com/Card/apikeys
            StripeConfiguration.SetApiKey(SecretKey);
            var service    = new CardService();
            var cardDelete = service.Delete(cusId, cardId);

            return(cardDelete);
        }
Beispiel #6
0
        public IActionResult Delete(string id)
        {
            var card = _cardService.Get(id);

            if (card == null)
            {
                return(NotFound());
            }
            _cardService.Delete(id);
            return(NoContent());
        }
Beispiel #7
0
        public static void DeletePaymentOption(string customerId, string cardId)
        {
            StripeConfiguration.ApiKey = Constants.StripeKey;

            var service = new CardService();

            service.Delete(
                customerId,
                cardId
                );
        }
Beispiel #8
0
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         svc.Delete(id);
         SuccessResponse resp = new SuccessResponse();
         return(Request.CreateResponse(HttpStatusCode.OK, resp));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
        public void DeleteShouldCallDeleteInDalOnce()
        {
            //Arrange
            var          mockRepository = new Mock <ICardRepository>();
            var          mockMapper     = new Mock <IMapper>();
            ICardService service        = new CardService(mockMapper.Object, mockRepository.Object);

            mockRepository.Setup(x => x.DeleteAsync(1)).ReturnsAsync(It.IsAny <int>);

            //Act
            service.Delete(1);

            //Assert
            mockRepository.Verify(x => x.Delete(1), Times.Once);
        }
        /// <inheritdoc />
        /// <exception cref="UserNotFoundException">Thrown when the user is not found</exception>
        /// <exception cref="PaymentMethodNotFoundException">Thrown when the users payment method was not found</exception>
        public async Task RemovePaymentMethod(RemovePaymentMethodBody removePaymentMethodBody)
        {
            var userWithPayments =
                await ApplicationContext.Users.Include(x => x.PaymentMethods)
                .FirstOrDefaultAsync(x => x.Id == removePaymentMethodBody.UserId);

            if (userWithPayments == null)
            {
                throw new UserNotFoundException();
            }

            var paymentMethod =
                userWithPayments.PaymentMethods.FirstOrDefault(
                    x => x.StripeCardId == removePaymentMethodBody.PaymentId);

            if (paymentMethod == null)
            {
                throw new PaymentMethodNotFoundException();
            }

            bool paymentWasDefault = paymentMethod.IsDefault;

            var service = new CardService();

            try
            {
                // request card delete from the Stripe api
                service.Delete(userWithPayments.StripeCustomerId, paymentMethod.StripeCardId);

                // remove the payment method and set first to default if the removed card was the default
                ApplicationContext.PaymentMethods.Remove(paymentMethod);
                if (paymentWasDefault)
                {
                    userWithPayments.PaymentMethods.First().IsDefault = true;
                }

                await ApplicationContext.SaveChangesAsync();
            }
            catch (Exception e)
            {
                Logger.LogInformation(e.Message);
                throw;
            }
        }
        public void DeleteCard_IsNotNull()
        {
            //Arrenge
            int status        = 1;
            var cardViewModel = new CardViewModel();
            var cardRepoMock  = new Mock <ICardRepository>();

            cardRepoMock.Setup(r => r.DeleteAsync(It.IsAny <int>())).ReturnsAsync(status);
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });
            IMapper mapper        = mappingConfig.CreateMapper();
            var     walletService = new CardService(mapper, cardRepoMock.Object);

            //Act
            var result = walletService.Delete(cardViewModel.WalletId);

            //Assert
            Assert.IsNotNull(result);
        }
        public void DeleteCard_Success_CallsRepositoryWithCorrectParameters()
        {
            //Arrenge
            int status        = 1;
            var cardViewModel = new CardViewModel()
            {
                WalletId = 1
            };
            var cardRepoMock = new Mock <ICardRepository>();

            cardRepoMock.Setup(r => r.DeleteAsync(It.IsAny <int>())).ReturnsAsync(status);
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });
            IMapper mapper      = mappingConfig.CreateMapper();
            var     cardService = new CardService(mapper, cardRepoMock.Object);

            //Act
            var result = cardService.Delete(cardViewModel.WalletId);

            //Assert
            cardRepoMock.Verify(r => r.Delete(It.Is <int>(id => id == cardViewModel.WalletId)), Times.Once);
        }
 public void Delete(long id)
 {
     service.Delete(id, LoggedUser);
 }
Beispiel #14
0
 public string DeleteCard(int id)
 => _cardService.Delete(id);