Hi I have this code snippet below:
Paypal paypal = new Paypal();
paypal.Invoice = transactionID;
paypal.TxnType = "";
paypal.CreateDate = DateTime.Now;
paypal.AmountPaid = payment;
paypal.PaymentStatusId = paymentStatus;
db.Paypals.Add(paypal);
db.SaveChanges();
// Order Does not Update
Order order = _orderRepository.GetOrderByOrderId(orderId);
order.OrderStatusId = OrderStatusConstant.Paid;
order.PurchasedDate = DateTime.Now;
order.LastModified = DateTime.Now;
order.PaypalIpnId = paypal.PaypalIpnId;
db.SaveChanges();
// Cart Does not Update
Cart cart = _cartRepository.GetCartByCartId(order.CartId);
cart.Completed = true;
db.SaveChanges();
Order and Cart entity does not update. But Paypal object is inserted. There are no errors or any exceptions thrown this is enclosed in a try..catch clause.
What seems to be the problem here? Repository codes returns object fine.
I see one thing in common here for Order and Cart and different for Paypal. Paypal is inserted using the context that is shown in the code, but Cart and Order are downloaded from the repository. Make sure that repository is using the same context.