Example #1
0
        public object SaveUserOrder(List <OrderListBAL> CartList)
        {
            string ListOfCourse  = "";
            string ListOfCourse1 = "";
            string ListOfCourse2 = "";
            string ListOfCourse3 = "";
            string ListOfCourse4 = "";

            UserCartInfo objUserCartInfo = new UserCartInfo();

            var          objReturn   = new object();
            PackagesBAL  obj         = new PackagesBAL();
            OrderListBAL objOrder    = new OrderListBAL();
            int          id          = obj.SaveCard(CartList[0].UserCardDetail);
            decimal      TotalAmount = CartList.Sum(u => u.Price);

            objUserCartInfo.Subtotal   = TotalAmount.ToString();
            objUserCartInfo.OrderTotal = TotalAmount.ToString();
            objUserCartInfo.Quantity   = "1";
            objUserCartInfo.Term       = "12";

            objUserCartInfo.Coptr = "";

            if (CartList[0].CouponCode != "" && !string.IsNullOrEmpty(CartList[0].CouponCode))
            {
                CoupansBAL objCB = new CoupansBAL();
                DataTable  dt    = objCB.VerifyCoupon(CartList[0].CouponCode);
                if (dt.Rows.Count > 0)
                {
                    objUserCartInfo.CouponCode = CartList[0].CouponCode;
                    if (Convert.ToInt32(dt.Rows[0]["CoupanTypeId"].ToString()) == 1)
                    {
                        objUserCartInfo.CupCodeAmount = ((TotalAmount * Convert.ToDecimal(dt.Rows[0]["CoupanValue"]) / 100)).ToString();
                        TotalAmount = TotalAmount - (TotalAmount * Convert.ToDecimal(dt.Rows[0]["CoupanValue"]) / 100);
                        objUserCartInfo.OrderTotal = TotalAmount.ToString();
                    }
                    if (Convert.ToInt32(dt.Rows[0]["CoupanTypeId"].ToString()) == 2)
                    {
                        objUserCartInfo.CupCodeAmount = (Convert.ToDecimal(dt.Rows[0]["CoupanValue"])).ToString();
                        TotalAmount = TotalAmount - (Convert.ToDecimal(dt.Rows[0]["CoupanValue"]));
                        objUserCartInfo.OrderTotal = TotalAmount.ToString();
                    }
                    //objUserCartInfo.CupCodeAmount = ((TotalAmount * Convert.ToInt32(dt.Rows[0]["CoupanValue"]) / 100)).ToString();
                    //TotalAmount = TotalAmount - (TotalAmount * Convert.ToInt32(dt.Rows[0]["CoupanValue"]) / 100);
                    //objUserCartInfo.OrderTotal = TotalAmount.ToString();
                }


                //objUserCartInfo.Coptr = "<tr class='gmail_msg'><td style='padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:48%' class='gmail_msg' bgcolor=''><font style='font-family:arial,sans serif;font-size:11' class='gmail_msg'>Coupon Code: &nbsp; (" + objUserCartInfo.CouponCode + ") </font></td><td style='padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:18%' class='gmail_msg' bgcolor=''><font style='font-family:arial,sans serif;font-size:11' class='gmail_msg'>&nbsp;</font></td><td style='padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:20%' class='gmail_msg' bgcolor=''><font style='font-family:arial,sans serif;font-size:11' class='gmail_msg'>&nbsp;</font></td><td style='padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:right;vertical-align:top;width:14%' class='gmail_msg' bgcolor=''><font style='font-family:arial,sans serif;font-size:11;font-weight:bold' class='gmail_msg'>" + objUserCartInfo.CupCodeAmount + "</font></td></tr>";

                /* Code updated 21-06-2017 */
                objUserCartInfo.Coptr = "<tr style='mso-yfti-irow: 4'><td width=298 colspan=2 valign=top style='width: 223.85pt; border: none; border-left: solid #CCCCCC 1.0pt; mso-border-left-alt: solid #CCCCCC .75pt; background: whitesmoke; padding: 4.5pt 0in 4.5pt 0in'><p class='MsoNormal' align='right' style='margin-bottom: 0in; margin-bottom: .0001pt; text-align: right; line-height: normal'><span style='font-size: 10.5pt; font-family: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'; color: #666666'>Coupon Code: &nbsp; (" + objUserCartInfo.CouponCode + ")<o:p></o:p></span></p></td><td width='282' colspan='2' valign='top' style='width: 211.15pt; border: none; border-right: solid #CCCCCC 1.0pt; mso-border-right-alt: solid #CCCCCC .75pt; background: whitesmoke; padding: 4.5pt 7.5pt 4.5pt 0in'><p class='MsoNormal' align='right' style='margin-bottom: 0in; margin-bottom: .0001pt; text-align: right; line-height: normal'><span style='font-family: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'; color: #666666'>- $" + objUserCartInfo.CupCodeAmount + "<o:p></o:p></span></p></td></tr>";
            }


            DataTable dtTestMode = obj.GetConfiguration("PaymentGateway", "MerchantInfo", "ssl_test_mode");
            bool      processed  = true;
            CCProcess objProcess = new CCProcess();

            if (dtTestMode.Rows[0]["Value"].ToString() == "true")
            {
                processed = objProcess.ProcessPayment(string.Concat(CartList[0].UserCardDetail._CardNumber), string.Concat(CartList[0].UserCardDetail._Expiry.Split('/')), TotalAmount.ToString("N2"), CartList[0].UserCardDetail.CV, CartList[0].UserCardDetail.CardName, "110074", CartList[0].UserCardDetail.CardName, "Sort Louisiana Course Purchase", "Hrs", "1");
            }

            int i = 0;

            if (processed)
            {
                foreach (OrderListBAL objC in CartList)
                {
                    objC.UserID       = CartList[0].UserCardDetail.UserId;
                    objC.CartId       = CartList[0].CartId;
                    objC.CardDetailId = id;
                    objC.PurchaseType = CartList[0].PurchaseType;
                    objC.Subtotal     = Convert.ToDecimal(objUserCartInfo.Subtotal);
                    objC.Discount     = Convert.ToDecimal(objUserCartInfo.CupCodeAmount);
                    objC.GrantTotal   = Convert.ToDecimal(objUserCartInfo.OrderTotal);
                    DataTable PurchaseOrderId = objOrder.SaveUserOrder(objC);

                    objUserCartInfo.PurchaseType = CartList[0].PurchaseType;


                    var UserInfo = obj.GetUserDetails(objC.UserID, objC.CourseID);

                    objUserCartInfo.PurchaseOrderId = PurchaseOrderId.Rows[0][0].ToString();

                    string Amount = "";

                    if (objUserCartInfo.PurchaseType == "Repurchase")
                    {
                        Amount = UserInfo[i].RenewCoursePrice;
                    }
                    else
                    {
                        Amount = UserInfo[i].CoursePrice;
                    }


                    ListOfCourse1 = "<tr class=\"gmail_msg\"><td colspan=\"3\" style=\"padding-left:10px;padding-right:10px;padding-top:10px;padding-bottom:2px;text-align:left;vertical-align:top\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11;font-weight:bold\" class=\"gmail_msg\">" + UserInfo[i].CourseName + "</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:10px;padding-bottom:2px;text-align:right;vertical-align:top;width:14%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11;font-weight:bold\" class=\"gmail_msg\">$" + Amount + "</font></td></tr>";
                    ListOfCourse2 = "<tr class=\"gmail_msg\"><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:48%\" class=\"gmail_msg\" bgcolor=\"\"><a href=\"javascript:void(0);\" class=\"gmail_msg\" target=\"_blank\"><img src='" + UserInfo[i].CourseImageFile + "' alt=\"img\" class=\"gmail_msg\" border=\"0\" width=\"20%\"></a></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:18%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">Quantity:</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:20%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">" + objUserCartInfo.Quantity + "&nbsp;plan(s)</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:right;vertical-align:top;width:14%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">&nbsp;</font></td></tr>";
                    ListOfCourse3 = "<tr class=\"gmail_msg\"><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:48%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">&nbsp;</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:18%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">Term:</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:20%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">" + objUserCartInfo.Term + " Month(s)</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:right;vertical-align:top;width:14%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">&nbsp;</font></td></tr>";
                    ListOfCourse4 = "<tr class=\"gmail_msg\"><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:48%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">&nbsp;</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:18%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">&nbsp;</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:left;vertical-align:top;width:20%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">&nbsp;</font></td><td style=\"padding-left:10px;padding-right:10px;padding-top:2px;padding-bottom:2px;text-align:right;vertical-align:top;width:14%\" class=\"gmail_msg\" bgcolor=\"\"><font style=\"font-family:arial,sans serif;font-size:11\" class=\"gmail_msg\">&nbsp;</font></td></tr>";

                    ListOfCourse += ListOfCourse1 + ListOfCourse2 + ListOfCourse3 + ListOfCourse4;


                    ListOfCourse1 = "";
                    ListOfCourse2 = "";
                    ListOfCourse3 = "";
                    ListOfCourse4 = "";
                    i             = i + 1;

                    objReturn = new { type = "Success", Message = "Thank you for purchasing course" };
                }


                objUserCartInfo.ListOfCourses = ListOfCourse;


                if (objUserCartInfo.PurchaseType == "Repurchase")
                {
                    obj.SendMailForPO(CartList[0].UserID, 10, null, objUserCartInfo);
                }
                else
                {
                    obj.SendMailForPO(CartList[0].UserID, 3, null, objUserCartInfo);
                }



                ListOfCourse = "";
            }
            else
            {
                objReturn = new { type = "Failure", Message = objProcess.RXMessage };
            }

            return(objReturn);
        }
Example #2
0
        public DataTable VerifyCouponCode(string CouponCode)
        {
            CoupansBAL objCoupansBAL = new CoupansBAL();

            return(objCoupansBAL.VerifyCoupon(CouponCode));
        }