Example #1
0
        public Boolean ConvertToOrder(Boolean debugMode = false)
        {
            var itemList = GetCartItemList();

            if (IsValidated() && itemList.Count > 0)
            {
                PurchaseTypeCode = "ORDER";
                if (base.PurchaseInfo.GetXmlProperty("genxml/createddate") == "")
                {
                    base.PurchaseInfo.SetXmlProperty("genxml/createddate", DateTime.Now.ToString(CultureInfo.GetCultureInfo(Utils.GetCurrentCulture())), TypeCode.DateTime);
                }
                if (base.PurchaseInfo.GetXmlProperty("genxml/ordernumber") == "")
                {
                    base.PurchaseInfo.SetXmlProperty("genxml/ordernumber", StoreSettings.Current.Get("orderprefix") + DateTime.Today.Year.ToString("").Substring(2, 2) + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00") + _cartId);
                }

                Save();
                var ordData = new OrderData(PortalId, base.PurchaseInfo.ItemID);
                ordData.OrderStatus = "010";
                if (ordData.EditMode == "") // don't update if we are in edit mode, we dont; want manager email to be altered.
                {
                    // if the client has updated the email address, link this back to DNN profile. (We assume they alway place there current email address on th order.)
                    var objUser = UserController.GetUserById(PortalSettings.Current.PortalId, ordData.UserId);
                    if (objUser != null && objUser.Email != ordData.EmailAddress)
                    {
                        var clientData = new ClientData(PortalId, ordData.UserId);
                        clientData.UpdateEmail(ordData.EmailAddress);
                    }
                    var addrData            = new AddressData(ordData.UserId.ToString());
                    var billAddr            = ordData.GetBillingAddress();
                    var selectedbilladdrIdx = billAddr.GetXmlProperty("genxml/dropdownlist/selectaddress");
                    if (!Utils.IsNumeric(selectedbilladdrIdx))
                    {
                        selectedbilladdrIdx = "-1";
                    }
                    addrData.AddAddress(billAddr, Convert.ToInt32(selectedbilladdrIdx));
                    var shipAddr            = ordData.GetShippingAddress();
                    var selectedShipaddrIdx = billAddr.GetXmlProperty("genxml/dropdownlist/selectaddress");
                    if (!Utils.IsNumeric(selectedShipaddrIdx))
                    {
                        selectedShipaddrIdx = "-1";
                    }
                    addrData.AddAddress(shipAddr, Convert.ToInt32(selectedShipaddrIdx));
                }
                ordData.Save();

                if (StoreSettings.Current.DebugModeFileOut)
                {
                    OutputDebugFile("debug_convertedcart.xml");
                }
                Exists = false;
                return(true);
            }
            return(false);
        }
Example #2
0
        public Boolean ConvertToOrder(Boolean debugMode = false)
        {
            var itemList = GetCartItemList();

            if (IsValidated() && itemList.Count > 0)
            {
                PurchaseTypeCode = "ORDER";
                if (base.PurchaseInfo.GetXmlProperty("genxml/createddate") == "")
                {
                    base.PurchaseInfo.SetXmlProperty("genxml/createddate", DateTime.Now.ToString("O"), TypeCode.DateTime);
                }
                if (base.PurchaseInfo.GetXmlProperty("genxml/ordernumber") == "")
                {
                    base.PurchaseInfo.SetXmlProperty("genxml/ordernumber", StoreSettings.Current.Get("orderprefix") + DateTime.Today.Year.ToString("").Substring(2, 2) + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00") + _cartId);
                }

                Save();
                var orderPortalId = PortalId;
                if (StoreSettings.Current.GetBool("shareorders"))
                {
                    orderPortalId = -1;
                }
                var ordData = new OrderData(orderPortalId, base.PurchaseInfo.ItemID);
                if (orderPortalId == -1)
                {
                    // shared order, so save the orginal portal
                    ordData.PurchaseInfo.SetXmlProperty("genxml/createdportalid", PortalId.ToString(""));
                }

                ordData.OrderStatus = "010";
                if (ordData.EditMode == "") // don't update if we are in edit mode, we dont; want manager email to be altered.
                {
                    // if the client has updated the email address, link this back to DNN profile. (We assume they alway place there current email address on th order.)
                    //var objUser = UserController.GetUserById(PortalSettings.Current.PortalId, ordData.UserId);
                    //if (objUser != null && objUser.Email != ordData.EmailAddress)
                    //{
                    //    var clientData = new ClientData(PortalId, ordData.UserId);
                    //    clientData.UpdateEmail(ordData.EmailAddress);
                    //}
                    // ++++++ Assumption Wrong!!! never assume!!  ++++++++++
                    // This also leads to problem is using the email form the username,
                    //   people don;t understand why their login isn't working when they haven't specificlly change the email address on the site!!


                    var addrData            = new AddressData(ordData.UserId.ToString());
                    var billAddr            = ordData.GetBillingAddress();
                    var selectedbilladdrIdx = billAddr.GetXmlProperty("genxml/dropdownlist/selectaddress");
                    if (!Utils.IsNumeric(selectedbilladdrIdx))
                    {
                        selectedbilladdrIdx = "-1";
                    }
                    addrData.AddAddress(billAddr, Convert.ToInt32(selectedbilladdrIdx));
                    var shipAddr            = ordData.GetShippingAddress();
                    var selectedShipaddrIdx = shipAddr.GetXmlProperty("genxml/dropdownlist/selectshipaddress");
                    if (!Utils.IsNumeric(selectedShipaddrIdx))
                    {
                        selectedShipaddrIdx = "-1";
                    }
                    addrData.AddAddress(shipAddr, Convert.ToInt32(selectedShipaddrIdx));
                }
                ordData.Save();

                if (StoreSettings.Current.DebugModeFileOut)
                {
                    OutputDebugFile("debug_convertedcart.xml");
                }
                Exists = false;
                return(true);
            }
            return(false);
        }
Example #3
0
        public Boolean ConvertToOrder(Boolean debugMode = false)
        {
            var itemList = GetCartItemList();
            if (IsValidated() && itemList.Count > 0)
            {
                PurchaseTypeCode = "ORDER";
                if (base.PurchaseInfo.GetXmlProperty("genxml/createddate") == "") base.PurchaseInfo.SetXmlProperty("genxml/createddate", DateTime.Now.ToString(CultureInfo.GetCultureInfo(Utils.GetCurrentCulture())), TypeCode.DateTime);
                if (base.PurchaseInfo.GetXmlProperty("genxml/ordernumber") == "") base.PurchaseInfo.SetXmlProperty("genxml/ordernumber", StoreSettings.Current.Get("orderprefix") + DateTime.Today.Year.ToString("").Substring(2, 2) + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00") + _cartId);

                Save();
                var ordData = new OrderData(PortalId, base.PurchaseInfo.ItemID);
                ordData.OrderStatus = "010";
                if (ordData.EditMode == "") // don't update if we are in edit mode, we dont; want manager email to be altered.
                {
                    // if the client has updated the email address, link this back to DNN profile. (We assume they alway place there current email address on th order.)
                    var objUser = UserController.GetUserById(PortalSettings.Current.PortalId, ordData.UserId);
                    if (objUser != null && objUser.Email != ordData.EmailAddress)
                    {
                        var clientData = new ClientData(PortalId, ordData.UserId);
                        clientData.UpdateEmail(ordData.EmailAddress);
                    }
                    var addrData = new AddressData(ordData.UserId.ToString());
                    var billAddr = ordData.GetBillingAddress();
                    var selectedbilladdrIdx = billAddr.GetXmlProperty("genxml/dropdownlist/selectaddress");
                    if (!Utils.IsNumeric(selectedbilladdrIdx)) selectedbilladdrIdx = "-1";
                    addrData.AddAddress(billAddr, Convert.ToInt32(selectedbilladdrIdx));
                    var shipAddr = ordData.GetShippingAddress();
                    var selectedShipaddrIdx = billAddr.GetXmlProperty("genxml/dropdownlist/selectaddress");
                    if (!Utils.IsNumeric(selectedShipaddrIdx)) selectedShipaddrIdx = "-1";
                    addrData.AddAddress(shipAddr, Convert.ToInt32(selectedShipaddrIdx));
                }
                ordData.Save();

                if (StoreSettings.Current.DebugModeFileOut) OutputDebugFile("debug_convertedcart.xml");
                Exists = false;
                return true;
            }
            return false;
        }