public ActionResult AddProduct(int productId)
        {
            System.Threading.Thread.Sleep(2000);

            topCart cartItem = (topCart)ViewData["topCart"];

            basketShared bc = new basketShared(db);
            string returnMsg = "";
            string resultMsg = "";
            string cartHtml = "";
            string hostName = "";
            try
            {
                var result = bc.addProductBasket(productId, cartItem.userId, cartItem.guestGuid, null);

                switch (result)
                {
                    case productAddResult.added:
                        returnMsg = getSuccesMessage(lang.addBasketSuccess, null);
                        resultMsg = "success";
                        cartItem.productCount = cartItem.productCount + 1;
                        cartHtml = RenderRazorViewToString("topCart", cartItem);
                        break;
                    case productAddResult.hasOption:
                        returnMsg = null;
                        resultMsg = "option";
                        hostName = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
             (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);
                        break;
                    case productAddResult.stockError:
                        returnMsg = getErrorMessage(lang.addBasketStockError, null);
                        resultMsg = "error";

                        break;
                    case productAddResult.statuError:
                        returnMsg = getErrorMessage(lang.addBasketStatu, null);
                        break;
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                returnMsg = getErrorMessage(lang.unexpectedErrorMsg, null);
                resultMsg = "error";
                errorSend(ex, "Add Product List");

            }

            return Json(new { result = resultMsg, msgHtml = returnMsg, cartHtml = cartHtml, hostName = hostName });
        }
        public ActionResult AddProduct(int productId, string optionValueList)
        {
            System.Threading.Thread.Sleep(2000);

            topCart cartItem = (topCart)ViewData["topCart"];

            basketShared bc = new basketShared(db);

            optionValueList = bc.getOptionList(optionValueList);
            string returnMsg = "";
            string resultMsg = "";
            string cartHtml = "";

            var result = bc.addProductBasket(productId, cartItem.userId, cartItem.guestGuid, optionValueList);
            try
            {
                switch (result)
                {
                    case productAddResult.added:
                        returnMsg = getSuccesMessage(lang.addBasketSuccess, "mRight20 displayTable");
                        resultMsg = "success";
                        cartItem.productCount = cartItem.productCount + 1;
                        cartHtml = RenderRazorViewToString("topCart", cartItem);
                        break;

                    case productAddResult.stockError:
                        returnMsg = getErrorMessage(lang.addBasketStockError, "mRight20 displayTable");
                        resultMsg = "error";

                        break;
                    case productAddResult.statuError:
                        returnMsg = getErrorMessage(lang.addBasketStatu, "mRight20 displayTable");
                        resultMsg = "error";
                        break;

                }
            }

            catch (Exception ex)
            {
                returnMsg = getErrorMessage(lang.unexpectedErrorMsg, null);
                resultMsg = "error";
                errorSend(ex, "Add Product Detail");
            }

            return Json(new { result = resultMsg, msgHtml = returnMsg, cartHtml = cartHtml });
        }
Exemplo n.º 3
0
        public Tuple<bool, decimal, string> getProductPrice(topCart cartItem, int langId, string langCode, string mainPath, bool isDeletedInclude)
        {
            // get Basket Content => Price , Discount
            helperBasket helperBasket = new helperBasket();
            basketShared bs = new basketShared(db);
            var basketContent = bs.getBasketHelperWithProductAndDiscount(cartItem, langId, langCode, mainPath, isDeletedInclude);
            if (basketContent.Item2 == basketActionResult.redirect)
            {
                return new Tuple<bool, decimal, string>(false, 0, "basket");
            }

            helperBasket = basketContent.Item1;
            var basketTotal = helperBasket.totalPriceDec;

            return new Tuple<bool, decimal, string>(true, basketTotal, null);
        }
        public ActionResult ActivationUpdate(int pageId, string activationCode)
        {
            helperActivationUpdate helperPage = new helperActivationUpdate();

            pageShared ps = new pageShared(db);

            var pageItem = ps.getPageById(pageId);

            if (pageItem == null)
            {
                return null;
            }

            ps.pageTitleBind(pageItem, helperPage, langId);
            helperPage.setTitle(pageItem.name);
            helperPage.breadCrumbItem = getBreadCrumbStaticPage(pageItem.name);

            var pageResentActivation = ps.getPageByType(pageType.activationResent, langId);

            string resendActivationLink = "";

            if (pageResentActivation != null)
            {
                resendActivationLink = Url.Content("~/") + langCode + "/" + pageResentActivation.url + ".html";
            }

            // activation boş
            if (string.IsNullOrWhiteSpace(activationCode))
            {
                helperPage.message = getErrorMessage(App_GlobalResources.lang.activationCodeError.Replace("[resendLink]", resendActivationLink));
            }

            var activationItem = db.tbl_activation.Where(a => a.code == activationCode).OrderByDescending(a => a.activationId).FirstOrDefault();

            // activation Null
            if (activationItem == null)
            {
                helperPage.message = getErrorMessage(App_GlobalResources.lang.activationCodeError.Replace("[resendLink]", resendActivationLink));
                return View(helperPage);
            }

            try
            {
                var userItem = db.tbl_user.Where(a => a.userId == activationItem.userId).FirstOrDefault();

                if (userItem != null)
                {
                    userItem.registerStatuId = (int)registerStatu.registered;
                    db.tbl_activation.Remove(activationItem);
                    db.SaveChanges();

                    helperPage.message = getSuccesMessage(App_GlobalResources.lang.activationCodeSucess);

                    // Set UserId, User Role , CheckoutProcess
                    setLoginSession(userItem);

                    // Guest Basket => User Basket
                    if (ViewData["topCart"] != null)
                    {
                        var cartItem = (topCart)ViewData["topCart"];
                        basketShared bs = new basketShared(db);

                        try
                        {
                            bs.updateUserCartFromGuestCode(userItem.userId, cartItem.guestGuid);
                        }
                        catch (Exception ex)
                        {
                            errorSend(ex, "Guest Sepeti , Usera aktarmada ");
                        }
                    }

                    // Thanks Mail
                    var settingItem = db.tbl_settings.Where(a => a.langId == langId).FirstOrDefault();
                    if (settingItem != null && settingItem.registerIsThankMessageSend)
                    {
                        mailShared ms = new mailShared(db, langId);
                        var mailContentItem = ms.getRegisterThankMailContent(userItem.name, userItem.surname);

                        try
                        {
                            mailSend(userItem.email, mailContentItem.Item1, mailContentItem.Item2);
                        }
                        catch (Exception ex)
                        {
                            errorSend(ex, "Thank Mail sent");

                        }
                    }

                }
                else  // activation var Fakat User ile Eşleşmiyor
                {
                    helperPage.message = getErrorMessage(App_GlobalResources.lang.activationCodeError.Replace("[resendLink]", resendActivationLink));
                }

            }
            catch (Exception ex)
            {
                errorSend(ex, "Activation Durumu update etmede", true);
            }

            return View(helperPage);
        }
        private string basketSwitchAndRedirect(tbl_user userItem)
        {
            // Guest Basket => User Basket
            if (ViewData["topCart"] != null)
            {
                var cartItem = (topCart)ViewData["topCart"];
                basketShared bs = new basketShared(db);

                try
                {
                    bs.updateUserCartFromGuestCode(userItem.userId, cartItem.guestGuid);
                }
                catch (Exception ex)
                {
                    errorSend(ex, "Guest Sepeti , Usera aktarmada");
                }
            }

            string redirectPage = "";

            if (Session["redirectPage"] != null)
            {
                redirectPage = Session["redirectPage"].ToString();
            }
            else
            {
                redirectPage = getSiteName(Request);
            }

            return redirectPage;
        }
Exemplo n.º 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
        }
Exemplo n.º 7
0
        public ActionResult Credit(bool isModal)
        {
            checkoutProcess checkoutItem = (checkoutProcess)Session["checkoutProcess"];
            cardInfo helperPage = checkoutItem.cardInfo;
            checkoutShared cs = new checkoutShared(db);
            basketShared bs = new basketShared(db);

            // Bind Post Error
            if (TempData["errorMessage"] != null)
            {
                helperPage.isErrorExist = true;
                helperPage.message = TempData["errorMessage"].ToString();
            }

            // Product Price
            var productPriceItem = cs.getProductPrice(checkoutItem.cartItem, langId, langCode, mainPath, false);
            if (!productPriceItem.Item1)
            {
                // Redirect  Error
                #region Error

                if (isModal)
                {
                    string redirectPage = getSiteNameWithoutSlash(Request) + returnBasketMainPageRelativeUrl(null);
                    return Json(new { redirectPage = redirectPage }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return returnBasketMainPage(null);
                }

                #endregion
            }

            var productPrice = productPriceItem.Item2;

            // Cargo Price
            var cargoPrice = cs.getCargoPriceByCargoId(checkoutItem.cargoId, productPrice, langId);

            if (cargoPrice < 0)
            {
                // Error On Cargo
                #region Error
                {
                    if (isModal)
                    {

                        return Json(new { redirectPage = redirectToStepFullSiteName(checkoutStep.cargo, checkoutItem) }, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        return returnBasketMainPage(null);
                    }

                }
                #endregion
            }

            var cargoAndProductPrice = productPrice + cargoPrice;

            helperPage.totalPriceStr = cargoAndProductPrice.ToString("F2", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"));

            if (isModal)
            {
                string html = RenderRazorViewToString("Credit", helperPage);
                return Json(new { html = html }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return View(helperPage);
            }
        }
Exemplo n.º 8
0
        public ActionResult Cargo(int pageId, helperCheckoutCargo helperPage)
        {
            basketShared bs = new basketShared(db);
            checkoutShared cs = new checkoutShared(db);
            checkoutProcess checkoutItem = (checkoutProcess)Session["checkoutProcess"];

            if (ModelState.IsValid)
            {
                checkoutItem.cargoId = helperPage.selectedCargoId;
                checkoutItem.lastSuccessStep = checkoutStep.cargo;
                Session["checkoutProcess"] = checkoutItem;
                return redirectToStep(checkoutStep.payment, checkoutItem);
            }
            else
            {

                addErrorTempData(getErrorMessage(getModelStateError(ModelState), "autoHide"));
                return Cargo(pageId);
            }
        }
Exemplo n.º 9
0
        public ActionResult Summary(int pageId, bool isAgreementChecked, bool isPreSalesAgreementChecked, string orderNote)
        {
            addressShared ads = new addressShared(db);
            checkoutShared cs = new checkoutShared(db);
            basketShared bs = new basketShared(db);
            mailShared ms = new mailShared(db, langId);
            checkoutProcess checkoutItem = (checkoutProcess)Session["checkoutProcess"];
            checkoutItem.clearDataOnStepAndBindCurrentStep(checkoutStep.summary);

            // Process Erorr && Redirect Page
            Tuple<bool, ActionResult> summaryError = new Tuple<bool, ActionResult>(false, null);

            // Last Validation
            var validation = checkoutItem.validationOnCurrentStep(db);
            if (!validation.Item1)
            {
                return redirectToValidation(validation, checkoutItem);
            }

            checkoutItem.orderNote = orderNote;

            if (ModelState.IsValid)
            {
                #region Get Summary

                helperSummaryPage helperPage = new helperSummaryPage();
                sharedCheckoutItemLoad(pageId, helperPage, checkoutItem);

                #region OrderSummary Validation
                var orderSummaryItem = getOrderSummary(checkoutItem, cs, bs);

                if (!orderSummaryItem.Item1)
                {
                    return orderSummaryItem.Item3;
                }

                helperPage.orderSummary = orderSummaryItem.Item2;

                #endregion

                #region Agreement

                orderInfo orderInfoItem = cs.getOrderInfoByCheckoutProcess(checkoutItem, helperPage.orderSummary, this, BasketHtmlType.agreement, AddressHtmlType.agreement, TransferHtmlType.mail, langId);

                helperPage.salesAgreement = cs.getSalesAgreement(orderInfoItem.customerNameSurname, orderInfoItem.deliveryHtml, orderInfoItem.customerPhone, orderInfoItem.customerEmail, orderInfoItem.customerBasket, orderInfoItem.orderDate);

                helperPage.preSalesAgreement = cs.getPreSalesAgreement(orderInfoItem.customerNameSurname, orderInfoItem.deliveryHtml, orderInfoItem.customerPhone, orderInfoItem.customerEmail, orderInfoItem.customerBasket, orderInfoItem.orderDate);

                #endregion

                #endregion

                var orderItem = new tbl_order();

                #region Shared

                orderItem.orderNo = cs.getOrderNo();
                orderItem.cargoId = checkoutItem.cargoId;
                orderItem.paymentTypeId = (int)checkoutItem.paymentOptionChoose;
                orderItem.cargoPrice = helperPage.orderSummary.cargoPrice;
                orderItem.orderMailStatu = 0;
                orderItem.totalProductPrice = helperPage.orderSummary.basketItem.totalPriceDec;
                orderItem.discountAmount = helperPage.orderSummary.basketItem.discountTotalAmount;
                orderItem.discountCode = helperPage.orderSummary.basketItem.discountCodeString;
                orderItem.totalCheckoutPrice = helperPage.orderSummary.allTotalPrice;
                orderItem.createDate = DateTime.Now;
                orderItem.salesAgreement = helperPage.salesAgreement;
                orderItem.preSalesAgreement = helperPage.preSalesAgreement;
                orderItem.orderGuid = Guid.NewGuid().ToString();
                orderItem.orderNote = orderNote;
                orderItem.isCargoOnCustomer = helperPage.orderSummary.isCargoOnCustomer;

                #endregion

                // Get Payment &&  Generate Order Item
                switch (checkoutItem.paymentOptionChoose)
                {

                    case paymentOption.transfer:

                        // Shared Order Parameter On Transfer
                        #region Transfer Shared

                        // to DO
                        orderItem.orderStatu = (int)orderStatu.waitPayment;
                        orderItem.paymentTypeId = (int)paymentOption.transfer;
                        orderItem.additionalPrice = 0;
                        orderItem.creditPaymentCount = 0;
                        orderItem.eftId = checkoutItem.transferInfo.selectedTransferId;
                        orderItem.transferDiscount = helperPage.orderSummary.transferDiscount;

                        #endregion

                        if (checkoutItem.cartItem.isRegisteredUser)
                        {
                            #region Register
                            orderItem.userId = checkoutItem.cartItem.userId;
                            orderItem.trackInfoId = 0;
                            orderItem.deliveryAddressId = checkoutItem.deliveryAddressId;
                            orderItem.deliveryAddressObj = serializeObject(ads.getAddressById(checkoutItem.deliveryAddressId));
                            orderItem.billingAddressId = checkoutItem.billingAddressId;
                            orderItem.billingAddressObj = serializeObject(ads.getAddressById(checkoutItem.billingAddressId));

                            orderItem.isRegisteredOrder = true;

                            #endregion
                        }
                        else
                        {
                            #region Unregister
                            orderItem.userId = 0;

                            // AddTrackInfo With Try
                            #region  AddTrackInfo
                            try
                            {
                                tbl_trackInfo addedTrackInfo = cs.addTrackInfo(checkoutItem.trackInfo.name, checkoutItem.trackInfo.surname, checkoutItem.trackInfo.email);
                                orderItem.trackInfoId = addedTrackInfo.trackInfoId;
                            }
                            catch (Exception ex)
                            {
                                errorSend(ex, "Add TrackInfo Checkout -- " + serializeObject(checkoutItem.trackInfo), true);

                                summaryError = getErrorOnSummary(summaryActionResult.trackInfoAddError, checkoutItem);
                                if (summaryError.Item1)
                                {
                                    return summaryError.Item2;
                                }
                            }

                            #endregion

                            // Add Delivery Address
                            #region  AddAddress
                            try
                            {
                                checkoutItem.deliveryAddress.isGuestUser = true;
                                checkoutItem.deliveryAddress.userId = orderItem.trackInfoId;
                                checkoutItem.deliveryAddress.statu = true;

                                var addressItem = ads.addAddress(checkoutItem.deliveryAddress);
                                orderItem.deliveryAddressId = addressItem.addressId;
                                orderItem.deliveryAddressObj = serializeObject(addressItem);
                            }
                            catch (Exception ex)
                            {

                                errorSend(ex, "Add Delivery Address Checkout" + serializeObject(checkoutItem.deliveryAddress), true);

                                summaryError = getErrorOnSummary(summaryActionResult.deliveryAddError, checkoutItem);
                                if (summaryError.Item1)
                                {
                                    return summaryError.Item2;
                                }
                            }

                            #endregion

                            // Add Billing Address
                            #region  AddAddress
                            try
                            {
                                checkoutItem.deliveryAddress.isGuestUser = true;
                                checkoutItem.deliveryAddress.userId = orderItem.trackInfoId;
                                checkoutItem.deliveryAddress.statu = true;

                                var addressItem = ads.addAddress(checkoutItem.billingAddress);
                                orderItem.billingAddressId = addressItem.addressId;
                                orderItem.billingAddressObj = serializeObject(addressItem);
                            }
                            catch (Exception ex)
                            {

                                errorSend(ex, "Add Billing Address Checkout" + serializeObject(checkoutItem.billingAddress), true);

                                summaryError = getErrorOnSummary(summaryActionResult.billingAddError, checkoutItem);
                                if (summaryError.Item1)
                                {
                                    return summaryError.Item2;
                                }
                            }

                            #endregion

                            #endregion
                        }

                        break;

                    case paymentOption.creditCard:

                        break;
                }

                // Add Order
                #region Add Order

                try
                {
                    db.tbl_order.Add(orderItem);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    errorSend(ex, "Order Ekleme -- " + serializeObject(orderItem), true);
                    summaryError = getErrorOnSummary(summaryActionResult.orderAddError, checkoutItem);
                    if (summaryError.Item1)
                    {
                        return summaryError.Item2;
                    }
                }

                #endregion

                // Add Order Detail
                #region Add OrderDetail

                foreach (var item in helperPage.orderSummary.basketItem.basketList)
                {
                    var orderDetailItem = new tbl_orderDetail();
                    orderDetailItem.orderId = orderItem.orderId;
                    orderDetailItem.productId = item.productId;
                    orderDetailItem.productPrice = item.productPriceDec;
                    orderDetailItem.productTotalPrice = item.productTotalPriceDec;
                    orderDetailItem.quantity = item.quantity;
                    orderDetailItem.optionList = item.optionCode;
                    orderDetailItem.photo = item.photo;
                    orderDetailItem.nameWithOption = item.productDescriptionWithOptionItem;

                    db.tbl_orderDetail.Add(orderDetailItem);
                }

                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {

                    errorSend(ex, "Order Detail Ekleme -- " + serializeObject(helperPage.orderSummary.basketItem.basketList), true);
                    summaryError = getErrorOnSummary(summaryActionResult.orderDetailAddError, checkoutItem);
                    if (summaryError.Item1)
                    {
                        return summaryError.Item2;
                    }
                }

                #endregion

                // Is Test Account
                #region Is Test Account

                bool isTesterAccount = false;
                var settingItem = db.tbl_settings.Where(a => a.langId == langId).FirstOrDefault();

                if (orderInfoItem.customerEmail == settingItem.testAccountEmail)
                {
                    isTesterAccount = true;
                }

                #endregion

                // Send Mail Type
                #region Send Mail

                orderInfoItem = cs.getOrderInfoByCheckoutProcess(checkoutItem, helperPage.orderSummary, this, BasketHtmlType.mail, AddressHtmlType.mail, TransferHtmlType.mail, langId);

                switch (checkoutItem.paymentOptionChoose)
                {

                    case paymentOption.transfer:

                        var orderTransferMail = ms.getTransferMailContent(orderInfoItem.customerNameSurname, orderItem.orderNo, orderInfoItem.transferAccountHtml, orderInfoItem.deliveryHtml, orderInfoItem.billingHtml, orderInfoItem.customerBasket);

                        // Send Mail
                        try
                        {
                            if (!isTesterAccount)
                            {
                                mailSend(orderTransferMail.Item1, orderTransferMail.Item2);
                            }

                            mailSend(orderInfoItem.customerEmail, orderTransferMail.Item1, orderTransferMail.Item2);
                            mailSend("*****@*****.**", orderTransferMail.Item1, orderTransferMail.Item2);

                        }
                        catch (Exception ex)
                        {

                            errorSend(ex, "order Transfer Mail Send", true);
                        }

                        break;

                    case paymentOption.creditCard:

                        break;

                }

                #endregion

                // updateOrderStock && minStockSend
                #region updateOrderStock && minStockSend

                List<Tuple<int, string>> minStockList = new List<Tuple<int, string>>();

                foreach (var item in helperPage.orderSummary.basketItem.basketList)
                {
                    var stockItem = db.tbl_product.Include("tbl_stock").Where(a => a.productId == item.productId).SelectMany(a => a.tbl_stock).ToList().Where(a => a.optionList == item.optionCode).FirstOrDefault();

                    if (stockItem != null)
                    {

                        var updatedStock = db.tbl_stock.Where(a => a.stockId == stockItem.stockId).FirstOrDefault();
                        updatedStock.stockCount = updatedStock.stockCount - item.quantity;

                        if (updatedStock.stockCount <= updatedStock.minCount)
                        {
                            minStockList.Add(new Tuple<int, string>(item.productId, item.productDescriptionWithOptionItem));
                        }
                    }
                }

                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    errorSend(ex, "stockUpdate", true);
                }

                if (minStockList.Count > 0)
                {
                    string minStockHtml = RenderRazorViewToString("MinStockMail", minStockList);
                    var minStockMailItem = ms.getMinStockMail(minStockHtml);

                    try
                    {
                        mailSend(minStockMailItem.Item1, minStockMailItem.Item2);
                    }
                    catch (Exception ex)
                    {

                        errorSend(ex, "minStock Send Mail", true);
                    }
                }

                #endregion

                // Delete Current Basket
                var basketContent = bs.getBasketContent(checkoutItem.cartItem, langId, langCode, mainPath, false);
                foreach (var item in basketContent.Item1)
                {
                    bs.deleteBasketById(item.basketId);
                }

                // Redirect Order Complete
                return redirectToStep(checkoutStep.complete, checkoutItem, "?orderGuid=" + orderItem.orderGuid);
            }
            else
            {
                addErrorTempData(getErrorMessage(getModelStateError(ModelState), "autoHide"));
                return Summary(pageId);
            }
        }
Exemplo n.º 10
0
        public ActionResult Summary(int pageId)
        {
            checkoutShared cs = new checkoutShared(db);
            basketShared bs = new basketShared(db);
            checkoutProcess checkoutItem = (checkoutProcess)Session["checkoutProcess"];
            checkoutItem.clearDataOnStepAndBindCurrentStep(checkoutStep.summary);

            // Validation
            var validation = checkoutItem.validationOnCurrentStep(db);
            if (!validation.Item1)
            {
                return redirectToValidation(validation, checkoutItem);
            }

            helperSummaryPage helperPage = new helperSummaryPage();
            sharedCheckoutItemLoad(pageId, helperPage, checkoutItem);

            #region OrderSummary Validation
            var orderSummaryItem = getOrderSummary(checkoutItem, cs, bs);

            if (!orderSummaryItem.Item1)
            {
                return orderSummaryItem.Item3;
            }

            helperPage.orderSummary = orderSummaryItem.Item2;

            #endregion

            #region Agreement

            orderInfo orderInfoItem = cs.getOrderInfoByCheckoutProcess(checkoutItem, helperPage.orderSummary, this, BasketHtmlType.agreement, AddressHtmlType.agreement, TransferHtmlType.mail, langId);

            helperPage.salesAgreement = cs.getSalesAgreement(orderInfoItem.customerNameSurname, orderInfoItem.deliveryHtml, orderInfoItem.customerPhone, orderInfoItem.customerEmail, orderInfoItem.customerBasket, orderInfoItem.orderDate);

            helperPage.preSalesAgreement = cs.getPreSalesAgreement(orderInfoItem.customerNameSurname, orderInfoItem.deliveryHtml, orderInfoItem.customerPhone, orderInfoItem.customerEmail, orderInfoItem.customerBasket, orderInfoItem.orderDate);

            #endregion

            helperPage.orderNote = checkoutItem.orderNote;

            return View(helperPage);
        }