public ActionResult Buy(int? id) { if (id == null) id = 0; tDealBuyModel finalmodel = new tDealBuyModel(); tDeal deal = _dealRepository.Find((int)id); finalmodel.currentDeal = deal; finalmodel.Quantity = deal.QuantityMinimum; finalmodel.IDDeal = (int)id; return View(finalmodel); }
private tDealBuyModel GetBuyModel(tDeal currentDeal) { tDealBuyModel buyModel = new tDealBuyModel(); buyModel.currentDeal = currentDeal; buyModel.Quantity = CommonUtils.Instance.ShoppingCart.Quantity; buyModel.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes; buyModel.MobilePhone = CommonUtils.Instance.ShoppingCart.MobilePhone; return(buyModel); }
public ActionResult BuyProduct(tDealBuyModel currentCheckoutData) { if (ModelState.IsValid) { CommonUtils.Instance.ShoppingCart = new tShoppingCart(); CommonUtils.Instance.ShoppingCart.IDDeal = currentCheckoutData.IDDeal; CommonUtils.Instance.ShoppingCart.Quantity = currentCheckoutData.Quantity; CommonUtils.Instance.ShoppingCart.BuyerNotes = currentCheckoutData.BuyerNotes; CommonUtils.Instance.ShoppingCart.MobilePhone = currentCheckoutData.MobilePhone; return RedirectToAction("Checkout", "Deal"); } return View(currentCheckoutData); }
public ActionResult BuyProduct(tDealBuyModel currentCheckoutData) { if (ModelState.IsValid) { CommonUtils.Instance.ShoppingCart = new tShoppingCart(); CommonUtils.Instance.ShoppingCart.IDDeal = currentCheckoutData.IDDeal; CommonUtils.Instance.ShoppingCart.Quantity = currentCheckoutData.Quantity; CommonUtils.Instance.ShoppingCart.BuyerNotes = currentCheckoutData.BuyerNotes; CommonUtils.Instance.ShoppingCart.MobilePhone = currentCheckoutData.MobilePhone; return(RedirectToAction("Checkout", "Deal")); } return(View(currentCheckoutData)); }
public ActionResult Buy(int?id) { if (id == null) { id = 0; } tDealBuyModel finalmodel = new tDealBuyModel(); tDeal deal = _dealRepository.Find((int)id); finalmodel.currentDeal = deal; finalmodel.Quantity = deal.QuantityMinimum; finalmodel.IDDeal = (int)id; return(View(finalmodel)); }
public ActionResult Checkout() { int IDDeal = CommonUtils.Instance.ShoppingCart.IDDeal; tDeal currentDeal = _dealRepository.Find(IDDeal); tDealBuyModel buyModel = new tDealBuyModel(); buyModel.currentDeal = currentDeal; buyModel.IDDeal = IDDeal; buyModel.Quantity = CommonUtils.Instance.ShoppingCart.Quantity; buyModel.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes; buyModel.MobilePhone = CommonUtils.Instance.ShoppingCart.MobilePhone; //if (id == null) id = 0; //tDeal deal = _dealRepository.Find((int)id); //return View(deal); return(View(buyModel)); }
public ActionResult Checkout() { int IDDeal = CommonUtils.Instance.ShoppingCart.IDDeal; tDeal currentDeal = _dealRepository.Find(IDDeal); tDealBuyModel buyModel = new tDealBuyModel(); buyModel.currentDeal = currentDeal; buyModel.IDDeal = IDDeal; buyModel.Quantity = CommonUtils.Instance.ShoppingCart.Quantity; buyModel.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes; buyModel.MobilePhone = CommonUtils.Instance.ShoppingCart.MobilePhone; //if (id == null) id = 0; //tDeal deal = _dealRepository.Find((int)id); //return View(deal); return View(buyModel); }
private tDealBuyModel GetBuyModel(tDeal currentDeal) { tDealBuyModel buyModel = new tDealBuyModel(); buyModel.currentDeal = currentDeal; buyModel.Quantity = CommonUtils.Instance.ShoppingCart.Quantity; buyModel.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes; buyModel.MobilePhone = CommonUtils.Instance.ShoppingCart.MobilePhone; return buyModel; }
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); }
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)); }