public void InsertOrUpdate(tPaymentMessage user) { if (user.IDPaymentMessage == default(int)) { // New entity context.tPaymentMessages.InsertOnSubmit(user); } else { // Existing entity tPaymentMessage userToUpdate = Find(user.IDPaymentMessage); if (userToUpdate != null && userToUpdate.IDPaymentMessage > 0) { userToUpdate.IDDeal = user.IDDeal; userToUpdate.SMSCode = user.SMSCode; userToUpdate.Approved = user.Approved; } } context.SubmitChanges(); }
partial void DeletetPaymentMessage(tPaymentMessage instance);
partial void UpdatetPaymentMessage(tPaymentMessage instance);
partial void InserttPaymentMessage(tPaymentMessage instance);
private void detach_tPaymentMessages(tPaymentMessage entity) { this.SendPropertyChanging(); entity.tDeal = null; }
public ActionResult MakePayment(tDealBuyModel currentCheckoutData) { currentCheckoutData.Quantity = CommonUtils.Instance.ShoppingCart.Quantity; currentCheckoutData.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes; currentCheckoutData.MobilePhone = CommonUtils.Instance.ShoppingCart.MobilePhone; PaymentResultModel resModel = new PaymentResultModel(); resModel.IDDeal = currentCheckoutData.IDDeal; int UserID = (int)MembershipHelper.GetCurrenUser().ProviderUserKey; tOrder ordData = _orderRepository.GetOrderByIDDealIDUser(currentCheckoutData.IDDeal, UserID); tDeal currentDeal = _dealRepository.Find(currentCheckoutData.IDDeal); tDealBuyModel buyModel = GetBuyModel(currentDeal); if (ordData != null && ordData.tCoupon.ConsumeStatus == (int)Enums.enmCouponConsumeStatus.NotConsumed) { resModel.PaymentStatus = false; resModel.StatusMessage += "You have already bought this deal, please use it's coupon and try again"; ModelState.AddModelError("Error", resModel.StatusMessage); return View("Checkout", buyModel); } ValidateDeal(currentDeal); if (!ModelState.IsValid) { resModel.PaymentStatus = false; resModel.StatusMessage += "Deal Error"; ModelState.AddModelError("Error", resModel.StatusMessage); return View("Checkout", buyModel); } if (currentCheckoutData.Quantity < currentDeal.QuantityMinimum) { resModel.PaymentStatus = false; resModel.StatusMessage += "Minimum Quantity allowed :" + currentDeal.QuantityMinimum; ModelState.AddModelError("Error", resModel.StatusMessage); return View("Checkout", buyModel); } List<tCoupon> couponsForThisPartner = _couponRepository.GetListByIDPartnerNotUsedAndNotConsumed(currentDeal.IDPartner); if (couponsForThisPartner == null || couponsForThisPartner.Count == 0) { resModel.PaymentStatus = false; resModel.StatusMessage += "Coupon info could't be found, please contact web admin"; currentCheckoutData.currentDeal = currentDeal; ModelState.AddModelError("Error", resModel.StatusMessage); return View("Checkout", buyModel); } tCoupon currCouponToUse = couponsForThisPartner[0]; resModel.CouponCode = currCouponToUse.CustomCode; currCouponToUse.CouponStatus = (int)Enums.enmCouponStatus.Used; IPayment paymentAgent = new PaymentAgentBeelineKg(); decimal AmountToBePaid = CalculateAmountToBePaid(currentDeal, currentCheckoutData.Quantity); if (AmountToBePaid <= 0) { resModel.PaymentStatus = false; resModel.StatusMessage += "Please verify amount to be paid for this deal!"; ModelState.AddModelError("Error", resModel.StatusMessage); return View("Checkout", buyModel); } PaymentBLL pBLL = new PaymentBLL(); bool paymentResult = pBLL.MakePayment(AmountToBePaid, paymentAgent); resModel.StatusMessage = pBLL.StatusMessage; resModel.PaymentStatus = paymentResult; resModel.CouponCode = currCouponToUse.CustomCode; if (paymentAgent.GetType() == typeof(PaymentAgentBeelineKg)) { System.Guid uniqueID = Guid.NewGuid(); tPaymentMessage msg = new tPaymentMessage(); msg.UniqueID = uniqueID.ToString(); msg.IDDeal = currentCheckoutData.IDDeal; msg.IDUsed = UserID; msg.SMSCode = pBLL.PaymentCode; msg.DateAdded = DateTime.Now; msg.Approved = false; _paymentMessageRepository.InsertOrUpdate(msg); resModel.PaymentType = (int)Enums.enmPaymentType.BeelineKG; resModel.SMSUniqueID = uniqueID.ToString(); } else { //Burdan aşağısı sadece kredikartı için çalışır _couponRepository.InsertOrUpdate(currCouponToUse); tOrder order = new tOrder(); order.AmountPaid = AmountToBePaid; order.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes; order.IDCoupon = currCouponToUse.IDCoupon; order.IDDeal = currentDeal.IDDeal; order.IDUserBought = UserID; order.MobilePhoneNo = CommonUtils.Instance.ShoppingCart.MobilePhone; order.OrderNotes = currentCheckoutData.OrderNotes; CommonUtils.Instance.ShoppingCart.OrderNotes = currentCheckoutData.OrderNotes; order.OrderStatus = (int)Enums.enmOrderStatus.ToBePaid; order.PaymentType = (int)Enums.enmPaymentType.BeelineKG; order.Quantity = currentCheckoutData.Quantity; order.RefundStatus = (int)Enums.enmRefundStatus.OrderSuccessful; _orderRepository.InsertOrUpdate(order); if (paymentResult) { _orderRepository.Save(); _couponRepository.Save(); } } return View(resModel); }