示例#1
0
        public static List <GroupItemsOutOfStockInfo> AddGroupItemsToCart(GroupProductCartInfo itemCartObj, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                string   UserName   = aspxCommonObj.UserName;
                string[] itemIDs    = itemCartObj.CartItemIDs.Split(',');
                string[] itemPrices = itemCartObj.CartItemPrices.Split(',');
                string[] itemQtys   = itemCartObj.CartItemQtys.Split(',');
                string[] itemSKUs   = itemCartObj.CartItemSKUs.Split(',');
                List <GroupItemsOutOfStockInfo> listItems = new List <GroupItemsOutOfStockInfo>();

                for (int count = 0; count < itemIDs.Length; count++)
                {
                    int                ItemID;
                    decimal            ItemPrice;
                    int                ItemQty;
                    string             ItemSKU = string.Empty;
                    string             AllowRealTimeNotifications = string.Empty;
                    StoreSettingConfig ssc = new StoreSettingConfig();
                    AllowRealTimeNotifications = ssc.GetStoreSettingsByKey(StoreSetting.AllowRealTimeNotifications, aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName);
                    if ((itemIDs[count].Trim() != "") && (itemPrices[count].Trim() != "") && (itemPrices[count].Trim() != "") && (itemSKUs[count].Trim() != ""))
                    {
                        ItemID    = Convert.ToInt32(itemIDs[count]);
                        ItemPrice = Convert.ToDecimal(itemPrices[count]);
                        ItemQty   = Convert.ToInt32(itemQtys[count]);
                        ItemSKU   = itemSKUs[count];
                        int retValue = AspxCommonProvider.AddItemstoCart(ItemID, ItemPrice, ItemQty, true, aspxCommonObj);
                        if (retValue == 1)
                        {
                            listItems.Add(new GroupItemsOutOfStockInfo(retValue, ItemID, ItemSKU, false));
                        }
                        else if (retValue == 2)
                        {
                            listItems.Add(new GroupItemsOutOfStockInfo(retValue, ItemID, ItemSKU, true));
                        }
                        else
                        {
                            bool isOutOfStock = AspxCommonProvider.CheckItemOutOfStock(ItemID, string.Empty, aspxCommonObj);
                            if (isOutOfStock == true)
                            {
                                listItems.Add(new GroupItemsOutOfStockInfo(retValue, ItemID, ItemSKU, true));
                            }
                            else
                            {
                                listItems.Add(new GroupItemsOutOfStockInfo(retValue, ItemID, ItemSKU, false));
                            }
                        }
                    }
                }

                return(listItems);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public static List<GroupItemsOutOfStockInfo> AddGroupItemsToCart(GroupProductCartInfo itemCartObj, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                string UserName = aspxCommonObj.UserName;
                string[] itemIDs = itemCartObj.CartItemIDs.Split(',');
                string[] itemPrices = itemCartObj.CartItemPrices.Split(',');
                string[] itemQtys = itemCartObj.CartItemQtys.Split(',');
                string[] itemSKUs = itemCartObj.CartItemSKUs.Split(',');
                List<GroupItemsOutOfStockInfo> listItems = new List<GroupItemsOutOfStockInfo>();

                for (int count = 0; count < itemIDs.Length; count++)
                {
                    int ItemID;
                    decimal ItemPrice;
                    int ItemQty;
                    string ItemSKU = string.Empty;
                    string AllowRealTimeNotifications = string.Empty;
                    StoreSettingConfig ssc = new StoreSettingConfig();
                    AllowRealTimeNotifications = ssc.GetStoreSettingsByKey(StoreSetting.AllowRealTimeNotifications, aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName);
                    if ((itemIDs[count].Trim() != "") && (itemPrices[count].Trim() != "") && (itemPrices[count].Trim() != "") && (itemSKUs[count].Trim() != ""))
                    {
                        ItemID = Convert.ToInt32(itemIDs[count]);
                        ItemPrice = Convert.ToDecimal(itemPrices[count]);
                        ItemQty = Convert.ToInt32(itemQtys[count]);
                        ItemSKU = itemSKUs[count];
                        int retValue = AspxCommonProvider.AddItemstoCart(ItemID, ItemPrice, ItemQty, true, aspxCommonObj);
                        if (retValue == 1)
                        {
                            listItems.Add(new GroupItemsOutOfStockInfo(retValue, ItemID, ItemSKU, false));
                        }
                        else if (retValue == 2)
                        {
                            listItems.Add(new GroupItemsOutOfStockInfo(retValue, ItemID, ItemSKU, true));

                        }
                        else
                        {
                            bool isOutOfStock = AspxCommonProvider.CheckItemOutOfStock(ItemID, string.Empty, aspxCommonObj);
                            if (isOutOfStock == true)
                            {
                                listItems.Add(new GroupItemsOutOfStockInfo(retValue, ItemID, ItemSKU, true));
                            }
                            else
                            {
                                listItems.Add(new GroupItemsOutOfStockInfo(retValue, ItemID, ItemSKU, false));
                            }

                        }
                    }
                }

                return listItems;
            }
            catch (Exception e)
            {
                throw e;
            }
        }