Пример #1
0
        public void TestMethod1()
        {
            CheckoutController cc = new CheckoutController();
            checkoutProcess checkoutItem = new checkoutProcess(new System.Collections.Generic.List<checkoutPageItem>(), new ViewModel.Shared.topCart());

            string output = cc.serializeObject(checkoutItem);
            System.Diagnostics.Debug.WriteLine(output);
        }
Пример #2
0
        internal orderInfo getOrderInfoByCheckoutProcess(checkoutProcess checkoutItem, orderSummary helperPage, DbWithControllerWithMaster helperController, BasketHtmlType htmlType, AddressHtmlType addressType, TransferHtmlType transferType, int langId)
        {
            var ads = new addressShared(db);
            var us = new userShared(db);
            var item = new ViewModel.Checkout.Summary.orderInfo();

            // Kayıtlı Üye
            if (checkoutItem.cartItem.isRegisteredUser)
            {

                //customerNameSurname
                item.customerNameSurname = checkoutItem.cartItem.nameSurname;

                //customerEmail
                var userId = checkoutItem.cartItem.userId;
                item.customerEmail = us.getUserById(userId).email;

                //customer Delivery Adress
                item.deliveryHtml = ads.getAddressHtml(checkoutItem.deliveryAddressId, addressType, helperController);

                //customerPhone
                item.customerPhone = ads.getAddresPhoneByAddressId(checkoutItem.deliveryAddressId);

                // customer Billing Addres
                item.billingHtml = ads.getAddressHtml(checkoutItem.billingAddressId, addressType, helperController);
            }
            else
            {
                //customerNameSurname
                item.customerNameSurname = checkoutItem.trackInfo.name + " " + checkoutItem.trackInfo.surname;

                //customerEmail
                item.customerEmail = checkoutItem.trackInfo.email;

                //customer Delivery Adress
                item.deliveryHtml = ads.getAddressHtml(checkoutItem.deliveryAddress, addressType, helperController);

                //customerPhone
                item.customerPhone = checkoutItem.deliveryAddress.phone;

                // customer Billing Addres
                item.billingHtml = ads.getAddressHtml(checkoutItem.billingAddress, addressType, helperController);
            }

            item.orderDate = DateTime.Now.ToString("dd.MM.yyyy");
            item.customerBasket = getBasketListWithPlainHtml(helperPage, helperController, htmlType);
            item.transferAccountHtml = getTransferInfoHtml(checkoutItem.transferInfo.selectedTransferId, langId, helperController, transferType);

            return item;
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            DbWithController itemController = (DbWithController)filterContext.Controller;

            if (filterContext.Controller.ViewData["topCart"] != null)
            {
                topCart cartItem = (topCart)filterContext.Controller.ViewData["topCart"];
                checkoutProcess processItem = null;

                // StepLink Allways Update
                var stepLink = getCheckoutStepList(itemController.db, itemController.langId, itemController.langCode);

                // checkout normal adımları, öncesinde checkout objesi oluşmuş
                if (filterContext.RequestContext.HttpContext.Session["checkoutProcess"] != null)
                {
                    processItem = (checkoutProcess)filterContext.RequestContext.HttpContext.Session["checkoutProcess"];

                    if (!isCartSame(processItem.cartItem, cartItem))
                    {
                        processItem.isCartItemChange = true;
                        processItem.cartItem = cartItem;
                    }

                    processItem.stepLinkList = stepLink;

                } // ilk checkouta giren adam
                else
                {
                    // Right Step Link
                    processItem = new checkoutProcess(stepLink, cartItem);

                }

                filterContext.RequestContext.HttpContext.Session["checkoutProcess"] = processItem;
            }
            else
            {
                throw new Exception("CartItem Null geliyor.Chekout processin başlangıcı sessionCheckoutControl");
            }
        }
Пример #4
0
        public RedirectResult redirectToStep(checkoutStep step, checkoutProcess checkoutItem, string additionalQuery)
        {
            var redirectPageUrl = redirecToStepUrlRelative(step, checkoutItem);

            if (redirectPageUrl != null)
            {
                return Redirect(redirectPageUrl + additionalQuery);
            }

            return null;
        }
Пример #5
0
        public string redirecToStepUrlRelative(checkoutStep step, checkoutProcess checkoutItem)
        {
            if (step == checkoutStep.none)
            {
                return returnBasketMainPageRelativeUrl("update=onCheckout");
            }

            var redirectPage = checkoutItem.stepLinkList.Where(a => a.step == step).FirstOrDefault();

            if (redirectPage != null)
            {
                return Url.Content("~/" + redirectPage.url);
            }
            else
            {

                errorSend(new Exception("stepLinkList düzgün gelmiyor."), "", true);
                return null;
            }
        }
Пример #6
0
        public Tuple<bool, orderSummary, RedirectResult> getOrderSummary(checkoutProcess checkoutItem, checkoutShared cs, basketShared bs)
        {
            orderSummary helperItem = new orderSummary();

            #region Basket

            var basketContentItem = bs.getBasketHelperWithProductAndDiscount(checkoutItem.cartItem, langId, langCode, mainPath, false);
            if (basketContentItem.Item2 == basketActionResult.redirect)
            {
                return new Tuple<bool, orderSummary, RedirectResult>(false, null, returnBasketMainPage(null));
            }

            helperItem.basketItem = basketContentItem.Item1;

            // Product Price
            var productPrice = helperItem.basketItem.totalPriceDec;

            #endregion

            #region Cargo

            // Cargo Price
            decimal cargoPrice = 0;
            var cargoList = cs.getCargoItemList(helperItem.basketItem.totalPriceDec, langId, "en-US");
            var cargoItem = cargoList.Where(a => a.cargoId == checkoutItem.cargoId).FirstOrDefault();
            if (cargoItem != null)
            {
                if (cargoItem.isCargoOnCustomer)
                {
                    helperItem.cargoPriceStr = lang.checkoutCargoOnCustomer;
                    helperItem.isCargoOnCustomer = true;
                }
                else
                {
                    helperItem.cargoPriceStr = cargoItem.price.ToString("F2", helperItem.basketItem.priceStringFormat);
                    cargoPrice = cargoItem.price;

                }
            }
            else
            {

                return new Tuple<bool, orderSummary, RedirectResult>(false, null, redirectToStep(checkoutStep.cargo, checkoutItem));
            }

            #endregion

            #region Basket & Payment Option

            decimal allPriceTotal = 0;
            decimal additionalPrice = 0;

            helperItem.paymentOptionChoose = checkoutItem.paymentOptionChoose;

            // getPayment Type
            switch (checkoutItem.paymentOptionChoose)
            {
                case paymentOption.noAnswer:

                    redirectToStep(checkoutStep.payment, checkoutItem);
                    break;
                case paymentOption.transfer:

                    helperItem.paymentOptionChooseStr = lang.checkoutTransfer;
                    allPriceTotal = cargoPrice + productPrice;
                    checkoutItem.transferInfo.transferDiscount = cs.getTransferInfo(langId);
                    if (checkoutItem.transferInfo.transferDiscount.isDiscountExist)
                    {
                        helperItem.isTransferDiscountExist = true;
                        helperItem.transferDiscount = checkoutItem.transferInfo.transferDiscount.calcDiscountAmount(allPriceTotal);
                        helperItem.transferDiscountStr = helperItem.transferDiscount.ToString("F2", helperItem.basketItem.priceStringFormat) + " TL";
                        allPriceTotal = allPriceTotal - helperItem.transferDiscount;
                    }

                    break;
                case paymentOption.creditCard:

                    helperItem.paymentOptionChooseStr = lang.checkoutCrediCard;
                    var productAndCargoPrice = cargoPrice + productPrice;

                    // Has Taksit
                    if (checkoutItem.cardInfo.cardOption.creditOptionId != 0)
                    {
                        var optionItem = cs.getCardOptionList(langId, productAndCargoPrice, checkoutItem.cardInfo.creditCard, HelperSite.Pos.posType.standart, helperItem.basketItem.priceStringFormat, "TL").Where(a => a.bankPosOptionId == checkoutItem.cardInfo.cardOption.creditOptionId).FirstOrDefault();
                        if (optionItem != null)
                        {
                            allPriceTotal = optionItem.totalPrice;
                            additionalPrice = allPriceTotal - (cargoPrice + productPrice);
                            helperItem.paymentOptionChooseStr = helperItem.paymentOptionChooseStr + "(" + optionItem.monthStr + lang.checkoutInstallment + ")";
                        }
                        else
                        {

                            return new Tuple<bool, orderSummary, RedirectResult>(false, null, redirectToStep(checkoutStep.payment, checkoutItem));
                        }
                    }
                    else // No Taksit
                    {
                        if (checkoutItem.cardInfo.cardOption.creditOptionId == -1) // Not Choose Return
                        {
                            return new Tuple<bool, orderSummary, RedirectResult>(false, null, redirectToStep(checkoutStep.payment, checkoutItem));
                        }
                        else
                        {
                            helperItem.paymentOptionChooseStr = helperItem.paymentOptionChooseStr + "(" + lang.checkoutCash + ")";
                            allPriceTotal = cargoPrice + productPrice;
                        }
                    }

                    break;
                default:
                    return new Tuple<bool, orderSummary, RedirectResult>(false, null, redirectToStep(checkoutStep.payment, checkoutItem));

            }

            helperItem.productPrice = productPrice;
            helperItem.productPriceStr = productPrice.ToString("F2", helperItem.basketItem.priceStringFormat) + " TL";
            helperItem.cargoPrice = cargoPrice;
            helperItem.additionalPrice = additionalPrice;
            helperItem.allTotalPrice = allPriceTotal;

            helperItem.allTotalPriceStr = allPriceTotal.ToString("F2", helperItem.basketItem.priceStringFormat) + " TL";
            helperItem.additionalPriceStr = additionalPrice.ToString("F2", helperItem.basketItem.priceStringFormat) + " TL";

            return new Tuple<bool, orderSummary, RedirectResult>(true, helperItem, null);

            #endregion
        }
Пример #7
0
        public Tuple<bool, ActionResult> getErrorOnSummary(summaryActionResult result, checkoutProcess checkoutItem)
        {
            switch (result)
            {
                case summaryActionResult.trackInfoAddError:
                case summaryActionResult.deliveryAddError:
                case summaryActionResult.billingAddError:
                case summaryActionResult.orderAddError:
                case summaryActionResult.orderDetailAddError:

                    addErrorTempData(getErrorMessage(App_GlobalResources.lang.orderErrorOnSaveOrder));
                    return new Tuple<bool, ActionResult>(true, redirectToStep(checkoutStep.error, checkoutItem));

                case summaryActionResult.posCodeError:

                    addErrorTempData(getErrorMessage(App_GlobalResources.lang.orderErrorOnPayment));
                    return new Tuple<bool, ActionResult>(true, redirectToStep(checkoutStep.summary, checkoutItem));

                case summaryActionResult.posError:

                    addErrorTempData(getErrorMessage(App_GlobalResources.lang.orderErrorPaymentInfoWrong));
                    return new Tuple<bool, ActionResult>(true, redirectToStep(checkoutStep.payment, checkoutItem));

            }

            return new Tuple<bool, ActionResult>(false, null);
        }
Пример #8
0
        public void sharedCheckoutItemLoad(int pageId, helperCheckoutShared pageHelper, checkoutProcess checkoutItem)
        {
            pageShared ps = new pageShared(db);

            var pageItem = ps.getPageById(pageId);
            ps.pageTitleBind(pageItem, pageHelper, langId);
            pageHelper.detail = pageItem.detail;
            pageHelper.stepLinkList = checkoutItem.stepLinkList;
            pageHelper.activeStep = checkoutItem.currentStep;
            checkoutItem.lastSuccessStep = ((checkoutStep)((int)checkoutItem.currentStep - 1));

            if (TempData["errorMessage"] != null)
            {
                pageHelper.isMessageExist = true;
                pageHelper.message = TempData["errorMessage"].ToString();
            }
        }
Пример #9
0
 public RedirectResult redirectToValidation(Tuple<bool, string, checkoutStep> validation, checkoutProcess checkoutItem)
 {
     // Error Message
     if (validation.Item2 != null)
     {
         return redirectToStep(validation.Item3, checkoutItem, "?requiredMessage=" + validation.Item2);
     }
     else
     {
         return redirectToStep(validation.Item3, checkoutItem);
     }
 }
Пример #10
0
 public string redirectToStepFullSiteName(checkoutStep step, checkoutProcess checkoutItem)
 {
     return getSiteNameWithoutSlash(Request) + redirecToStepUrlRelative(step, checkoutItem);
 }
Пример #11
0
 public RedirectResult redirectToStep(checkoutStep step, checkoutProcess checkoutItem)
 {
     return redirectToStep(step, checkoutItem, null);
 }