Ejemplo n.º 1
0
    public static int CheckCurrencyCart()
    {
        Class_Order  _order  = new Class_Order();
        string       anonID  = HttpContext.Current.Request.AnonymousID;
        TBOrder_temp _cookie = _order.GetEncodedDataOrder(anonID);
        string       _token  = "";

        if (_cookie == null)
        {
            return(0);
        }
        else
        {
            _token = _cookie.EncodedData;
            dynamic tmp = (OurClass.DecryptToken(_token) as IDictionary <string, dynamic>);
            if ((tmp as Dictionary <string, dynamic>).ContainsKey("IDCurrency"))
            {
                return(tmp["IDCurrency"]);
            }
            else
            {
                return(0);
            }
        }
    }
Ejemplo n.º 2
0
    public ReturnData AJAX_SaveShippingToCart(int idShipping)
    {
        try
        {
            //var cartCookies = HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()];
            Class_Order order       = new Class_Order();
            var         cartCookies = order.GetEncodedDataOrder(HttpContext.Current.Request.AnonymousID);
            if (cartCookies == null)
            {
                return(ReturnData.MessageFailed("Invalid token", null));
            }

            DataClassesDataContext db       = new DataClassesDataContext();
            Class_Shipping         shipping = new Class_Shipping();

            var     token      = cartCookies.EncodedData;
            dynamic CartData   = OurClass.DecryptToken(token);
            dynamic address    = CartData["DeliveryAddress"];
            int     idDistrict = address["IDDistrict"];

            dynamic shippingData   = shipping.Dynamic_GetShipping_ByIDShipping(idShipping);
            dynamic resultShipping = new Dictionary <string, dynamic>();

            decimal totalPrice = 0;
            decimal price      = 0;

            totalPrice = Class_Currency.GetPriceConversionCurrency(shippingData.Price * Math.Ceiling((decimal)CartData["TotalWeight"]));
            price      = Class_Currency.GetPriceConversionCurrency(shippingData.Price);
            if (CartData["TotalWeight"] < 1)
            {
                totalPrice = Class_Currency.GetPriceConversionCurrency(shippingData.Price);
            }

            resultShipping["IDCarrier"]   = shippingData.IDCarrier;
            resultShipping["IDShipping"]  = shippingData.IDShipping;
            resultShipping["IDDistrict"]  = shippingData.IDDistrict;
            resultShipping["Image"]       = shippingData.Image;
            resultShipping["Name"]        = shippingData.Name;
            resultShipping["Price"]       = price;
            resultShipping["Information"] = shippingData.Information;
            resultShipping["TotalPrice"]  = totalPrice;

            CartData["Shipping"] = resultShipping;
            token = OurClass.EncryptToken(CartData);
            //HttpContext.Current.Response.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()].Value = token;
            order.SaveEncodeDataOrder(HttpContext.Current.Request.AnonymousID, token);
            return(ReturnData.MessageSuccess("OK", CartData));
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Ejemplo n.º 3
0
    public ReturnData AJAX_Insert_ToCart(int idPaymentMethod)
    {
        try
        {
            Class_Order order = new Class_Order();
            //var cartCookies = HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()];
            var cartCookies = order.GetEncodedDataOrder(HttpContext.Current.Request.AnonymousID);
            if (cartCookies == null)
            {
                return(ReturnData.MessageFailed("Invalid token", null));
            }

            DataClassesDataContext db       = new DataClassesDataContext();
            Class_Shipping         shipping = new Class_Shipping();

            var     token      = cartCookies.EncodedData;
            dynamic CartData   = OurClass.DecryptToken(token);
            dynamic address    = CartData["DeliveryAddress"];
            int     idDistrict = address["IDDistrict"];

            dynamic paymentData = Dynamic_GetDetail_ByIDPayment_Method(idPaymentMethod);

            CartData["PaymentMethod"] = paymentData;
            token = OurClass.EncryptToken(CartData);
            //HttpContext.Current.Response.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()].Value = token;
            order.SaveEncodeDataOrder(HttpContext.Current.Request.AnonymousID, token);
            return(ReturnData.MessageSuccess("OK", CartData));
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }