コード例 #1
0
        public static int AddItemstoCartFromDetail(AddItemToCartInfo AddItemToCartObj, AspxCommonInfo aspxCommonObj, GiftCard giftCardDetail, CartKit kitInfo)
        {
            try
            {
                StoreSettingConfig ssc = new StoreSettingConfig();
                if (AspxCartController.CheckItemCart(AddItemToCartObj.ItemID, aspxCommonObj.StoreID, aspxCommonObj.PortalID, AddItemToCartObj.CostVariantIDs))
                {
                    int cartItemId = 0;
                    if (AddItemToCartObj.IsKitItem)
                    {
                        //if kit type
                        //logic
                        // serialize
                        //   kitInfo.Data into string and save it db and also description
                        //++price and weight will be from kit info it contains total configured price and weight
                        JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                        string kitconfigureddata             = json_serializer.Serialize(kitInfo.Data);

                        List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPUS(aspxCommonObj);
                        parameter.Add(new KeyValuePair <string, object>("@ItemID", AddItemToCartObj.ItemID));
                        parameter.Add(new KeyValuePair <string, object>("@Price", kitInfo.Price));
                        parameter.Add(new KeyValuePair <string, object>("@Weight", kitInfo.Weight));
                        parameter.Add(new KeyValuePair <string, object>("@Quantity", AddItemToCartObj.Quantity));
                        parameter.Add(new KeyValuePair <string, object>("@CostVariantsValueIDs", AddItemToCartObj.CostVariantIDs));
                        parameter.Add(new KeyValuePair <string, object>("@KitDescription", kitInfo.Description));
                        parameter.Add(new KeyValuePair <string, object>("@KitData", kitconfigureddata));
                        SQLHandler sqlH = new SQLHandler();
                        cartItemId = sqlH.ExecuteAsScalar <int>("dbo.usp_Aspx_AddToCart", parameter);
                    }
                    else
                    {
                        List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPUS(aspxCommonObj);
                        parameter.Add(new KeyValuePair <string, object>("@ItemID", AddItemToCartObj.ItemID));
                        parameter.Add(new KeyValuePair <string, object>("@Price", AddItemToCartObj.Price));
                        parameter.Add(new KeyValuePair <string, object>("@Weight", AddItemToCartObj.Weight));
                        parameter.Add(new KeyValuePair <string, object>("@Quantity", AddItemToCartObj.Quantity));
                        parameter.Add(new KeyValuePair <string, object>("@CostVariantsValueIDs", AddItemToCartObj.CostVariantIDs));
                        parameter.Add(new KeyValuePair <string, object>("@KitDescription", null));
                        parameter.Add(new KeyValuePair <string, object>("@KitData", null));
                        SQLHandler sqlH = new SQLHandler();
                        cartItemId = sqlH.ExecuteAsScalar <int>("dbo.usp_Aspx_AddToCart", parameter);
                    }

                    if (AddItemToCartObj.IsGiftCard == true && giftCardDetail != null)
                    {
                        List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >();
                        param.Add(new KeyValuePair <string, object>("@CartItemId", cartItemId));
                        param.Add(new KeyValuePair <string, object>("@ItemId", AddItemToCartObj.ItemID));
                        param.Add(new KeyValuePair <string, object>("@GiftCardTypeId", giftCardDetail.GiftCardTypeId));
                        param.Add(new KeyValuePair <string, object>("@GiftCardGraphicsId", giftCardDetail.GraphicThemeId));
                        param.Add(new KeyValuePair <string, object>("@Amount", giftCardDetail.Price));
                        param.Add(new KeyValuePair <string, object>("@GiftCardCode", giftCardDetail.GiftCardCode));
                        param.Add(new KeyValuePair <string, object>("@RecipientName", giftCardDetail.RecipientName));
                        param.Add(new KeyValuePair <string, object>("@RecipientEmail", giftCardDetail.RecipientEmail));
                        param.Add(new KeyValuePair <string, object>("@SenderName", giftCardDetail.SenderName));
                        param.Add(new KeyValuePair <string, object>("@SenderEmail", giftCardDetail.SenderEmail));
                        param.Add(new KeyValuePair <string, object>("@Messege", giftCardDetail.Messege));
                        param.Add(new KeyValuePair <string, object>("@StoreId", aspxCommonObj.StoreID));
                        param.Add(new KeyValuePair <string, object>("@PortalId", aspxCommonObj.PortalID));
                        param.Add(new KeyValuePair <string, object>("@CultureName", aspxCommonObj.CultureName));
                        param.Add(new KeyValuePair <string, object>("@UserName", aspxCommonObj.UserName));
                        SQLHandler sqlH = new SQLHandler();
                        sqlH.ExecuteNonQuery("usp_Aspx_AddGiftCard", param);
                    }
                    return(1);
                }
                else
                {
                    if (bool.Parse(ssc.GetStoreSettingsByKey(StoreSetting.AllowOutStockPurchase, aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName)))
                    {
                        int cartItemId = 0;
                        if (AddItemToCartObj.IsKitItem)
                        {
                            List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPUS(aspxCommonObj);
                            parameter.Add(new KeyValuePair <string, object>("@ItemID", AddItemToCartObj.ItemID));
                            parameter.Add(new KeyValuePair <string, object>("@Price", AddItemToCartObj.Price));
                            parameter.Add(new KeyValuePair <string, object>("@Weight", AddItemToCartObj.Weight));
                            parameter.Add(new KeyValuePair <string, object>("@Quantity", AddItemToCartObj.Quantity));
                            parameter.Add(new KeyValuePair <string, object>("@CostVariantsValueIDs", AddItemToCartObj.CostVariantIDs));
                            parameter.Add(new KeyValuePair <string, object>("@KitDescription", null));
                            parameter.Add(new KeyValuePair <string, object>("@KitData", null));
                            SQLHandler sqlH = new SQLHandler();
                            cartItemId = sqlH.ExecuteAsScalar <int>("dbo.usp_Aspx_AddToCart", parameter);
                        }
                        else
                        {
                            List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPUS(aspxCommonObj);
                            parameter.Add(new KeyValuePair <string, object>("@ItemID", AddItemToCartObj.ItemID));
                            parameter.Add(new KeyValuePair <string, object>("@Price", AddItemToCartObj.Price));
                            parameter.Add(new KeyValuePair <string, object>("@Weight", AddItemToCartObj.Weight));
                            parameter.Add(new KeyValuePair <string, object>("@Quantity", AddItemToCartObj.Quantity));
                            parameter.Add(new KeyValuePair <string, object>("@CostVariantsValueIDs", AddItemToCartObj.CostVariantIDs));
                            parameter.Add(new KeyValuePair <string, object>("@KitDescription", null));
                            parameter.Add(new KeyValuePair <string, object>("@KitData", null));
                            SQLHandler sqlH = new SQLHandler();
                            cartItemId = sqlH.ExecuteAsScalar <int>("dbo.usp_Aspx_AddToCart", parameter);
                        }


                        if (AddItemToCartObj.IsGiftCard == true && giftCardDetail != null)
                        {
                            List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >();
                            param.Add(new KeyValuePair <string, object>("@CartItemId", cartItemId));
                            param.Add(new KeyValuePair <string, object>("@ItemId", AddItemToCartObj.ItemID));
                            param.Add(new KeyValuePair <string, object>("@GiftCardTypeId", giftCardDetail.GiftCardTypeId));
                            param.Add(new KeyValuePair <string, object>("@GiftCardGraphicsId", giftCardDetail.GraphicThemeId));
                            param.Add(new KeyValuePair <string, object>("@Amount", giftCardDetail.Price));
                            param.Add(new KeyValuePair <string, object>("@GiftCardCode", giftCardDetail.GiftCardCode));
                            param.Add(new KeyValuePair <string, object>("@RecipientName", giftCardDetail.RecipientName));
                            param.Add(new KeyValuePair <string, object>("@RecipientEmail", giftCardDetail.RecipientEmail));
                            param.Add(new KeyValuePair <string, object>("@SenderName", giftCardDetail.SenderName));
                            param.Add(new KeyValuePair <string, object>("@SenderEmail", giftCardDetail.SenderEmail));
                            param.Add(new KeyValuePair <string, object>("@Messege", giftCardDetail.Messege));
                            param.Add(new KeyValuePair <string, object>("@StoreId", aspxCommonObj.StoreID));
                            param.Add(new KeyValuePair <string, object>("@PortalId", aspxCommonObj.PortalID));
                            param.Add(new KeyValuePair <string, object>("@CultureName", aspxCommonObj.CultureName));
                            param.Add(new KeyValuePair <string, object>("@UserName", aspxCommonObj.UserName));
                            SQLHandler sqlH = new SQLHandler();
                            sqlH.ExecuteNonQuery("usp_Aspx_AddGiftCard", param);
                        }
                        return(1);
                    }
                    else
                    {
                        return(2);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #2
0
        public static int AddItemstoCartFromDetail(AddItemToCartInfo AddItemToCartObj, AspxCommonInfo aspxCommonObj, GiftCard giftCardDetail)
        {
            try
            {
                StoreSettingConfig ssc = new StoreSettingConfig();
                if (AspxCartController.CheckItemCart(AddItemToCartObj.ItemID, aspxCommonObj.StoreID, aspxCommonObj.PortalID, AddItemToCartObj.CostVariantIDs))
                {
                    List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPUS(aspxCommonObj);
                    parameter.Add(new KeyValuePair <string, object>("@ItemID", AddItemToCartObj.ItemID));
                    parameter.Add(new KeyValuePair <string, object>("@Price", AddItemToCartObj.Price));
                    parameter.Add(new KeyValuePair <string, object>("@Weight", AddItemToCartObj.Weight));
                    parameter.Add(new KeyValuePair <string, object>("@Quantity", AddItemToCartObj.Quantity));
                    parameter.Add(new KeyValuePair <string, object>("@CostVariantsValueIDs", AddItemToCartObj.CostVariantIDs));
                    SQLHandler sqlH       = new SQLHandler();
                    int        cartItemId = sqlH.ExecuteAsScalar <int>("dbo.usp_Aspx_AddToCart", parameter);

                    if (AddItemToCartObj.IsGiftCard == true && giftCardDetail != null)
                    {
                        List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >();
                        param.Add(new KeyValuePair <string, object>("@CartItemId", cartItemId));
                        param.Add(new KeyValuePair <string, object>("@ItemId", AddItemToCartObj.ItemID));
                        param.Add(new KeyValuePair <string, object>("@GiftCardTypeId", giftCardDetail.GiftCardTypeId));
                        param.Add(new KeyValuePair <string, object>("@GiftCardGraphicsId", giftCardDetail.GraphicThemeId));
                        param.Add(new KeyValuePair <string, object>("@Amount", giftCardDetail.Price));
                        param.Add(new KeyValuePair <string, object>("@GiftCardCode", giftCardDetail.GiftCardCode));
                        param.Add(new KeyValuePair <string, object>("@RecipientName", giftCardDetail.RecipientName));
                        param.Add(new KeyValuePair <string, object>("@RecipientEmail", giftCardDetail.RecipientEmail));
                        param.Add(new KeyValuePair <string, object>("@SenderName", giftCardDetail.SenderName));
                        param.Add(new KeyValuePair <string, object>("@SenderEmail", giftCardDetail.SenderEmail));
                        param.Add(new KeyValuePair <string, object>("@Messege", giftCardDetail.Messege));
                        param.Add(new KeyValuePair <string, object>("@StoreId", aspxCommonObj.StoreID));
                        param.Add(new KeyValuePair <string, object>("@PortalId", aspxCommonObj.PortalID));
                        param.Add(new KeyValuePair <string, object>("@CultureName", aspxCommonObj.CultureName));
                        param.Add(new KeyValuePair <string, object>("@UserName", aspxCommonObj.UserName));

                        sqlH.ExecuteNonQuery("usp_Aspx_AddGiftCard", param);
                    }
                    return(1);
                }
                else
                {
                    if (bool.Parse(ssc.GetStoreSettingsByKey(StoreSetting.AllowOutStockPurchase, aspxCommonObj.StoreID, aspxCommonObj.PortalID, aspxCommonObj.CultureName)))
                    {
                        List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPUS(aspxCommonObj);
                        parameter.Add(new KeyValuePair <string, object>("@ItemID", AddItemToCartObj.ItemID));
                        parameter.Add(new KeyValuePair <string, object>("@Price", AddItemToCartObj.Price));
                        parameter.Add(new KeyValuePair <string, object>("@Weight", AddItemToCartObj.Weight));
                        parameter.Add(new KeyValuePair <string, object>("@Quantity", AddItemToCartObj.Quantity));
                        parameter.Add(new KeyValuePair <string, object>("@CostVariantsValueIDs", AddItemToCartObj.CostVariantIDs));
                        SQLHandler sqlH       = new SQLHandler();
                        int        cartItemId = sqlH.ExecuteAsScalar <int>("dbo.usp_Aspx_AddToCart", parameter);
                        if (AddItemToCartObj.IsGiftCard == true && giftCardDetail != null)
                        {
                            List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >();
                            param.Add(new KeyValuePair <string, object>("@CartItemId", cartItemId));
                            param.Add(new KeyValuePair <string, object>("@ItemId", AddItemToCartObj.ItemID));
                            param.Add(new KeyValuePair <string, object>("@GiftCardTypeId", giftCardDetail.GiftCardTypeId));
                            param.Add(new KeyValuePair <string, object>("@GiftCardGraphicsId", giftCardDetail.GraphicThemeId));
                            param.Add(new KeyValuePair <string, object>("@Amount", giftCardDetail.Price));
                            param.Add(new KeyValuePair <string, object>("@GiftCardCode", giftCardDetail.GiftCardCode));
                            param.Add(new KeyValuePair <string, object>("@RecipientName", giftCardDetail.RecipientName));
                            param.Add(new KeyValuePair <string, object>("@RecipientEmail", giftCardDetail.RecipientEmail));
                            param.Add(new KeyValuePair <string, object>("@SenderName", giftCardDetail.SenderName));
                            param.Add(new KeyValuePair <string, object>("@SenderEmail", giftCardDetail.SenderEmail));
                            param.Add(new KeyValuePair <string, object>("@Messege", giftCardDetail.Messege));
                            param.Add(new KeyValuePair <string, object>("@StoreId", aspxCommonObj.StoreID));
                            param.Add(new KeyValuePair <string, object>("@PortalId", aspxCommonObj.PortalID));
                            param.Add(new KeyValuePair <string, object>("@CultureName", aspxCommonObj.CultureName));
                            param.Add(new KeyValuePair <string, object>("@UserName", aspxCommonObj.UserName));

                            sqlH.ExecuteNonQuery("usp_Aspx_AddGiftCard", param);
                        }
                        return(1);
                    }
                    else
                    {
                        return(2);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }