Пример #1
0
        public bool Post(PaymentApiModel paymentData)
        {
            // Order order = paymentData.PaymentData.Order;

            if (paymentData.Card.Id == 0)
            {
                Card card = new Card()
                {
                    cardholderName = paymentData.Card.cardholderName,
                    cvv            = paymentData.Card.cvv,
                    cardNumber     = paymentData.Card.cardNumber,
                    expiryDate     = paymentData.Card.expiryDate
                };

                cardRepository.SaveCard(card);
                cardRepository.Commit();
            }
            else
            {
                Card card = cardRepository.GetById(paymentData.Card.Id);
            }

            Customer customer = new Customer()
            {
                cardId = cardRepository.GetByCredentials(paymentData.Card.cardholderName, paymentData.Card.cvv, paymentData.Card.cardNumber).Id,
                Name   = paymentData.Customer.Name
            };

            customerRepository.SaveCustomer(customer);
            customerRepository.Commit();

            //TODO : VOIR POURQUOI CET ENCULAY DE EF NE VEUX PAS METTRE A JOUR LORDERID VTFF IL EST 58
            PaymentData newPayment = new PaymentData()
            {
                Customer = customer,
                OrderId  = paymentData.PaymentData.OrderId
            };

            paymentRepository.SavePayment(newPayment);
            paymentRepository.Commit();

            return(true);
        }