public List <int> GetShoppingCartIDByInventoryType(int inventoryType, int userID, int campaignID = 0) { return(ShoppingCartInfoProvider.GetShoppingCarts(SiteContext.CurrentSiteID) .OnSite(SiteContext.CurrentSiteID) .WhereEquals("ShoppingCartUserID", userID) .WhereEquals("ShoppingCartCampaignID", campaignID) ?.ToList().Select(x => x.ShoppingCartID).ToList()); }
/// <summary> /// Get all Cusromers / Distributers list based on product ID /// </summary> /// <param name="productID">Producct skuid</param> private void BindCustomersList(int productID) { try { List <AddressInfo> myAddressList = GetMyAddressBookList(); if (myAddressList.Count > 0) { List <int> shoppingCartIDs = ShoppingCartInfoProvider.GetShoppingCarts() .WhereIn("ShoppingCartDistributorID", myAddressList.Select(g => g.AddressID).ToList()) .WhereEquals("ShoppingCartInventoryType", InventoryType) .Select(x => x.ShoppingCartID).ToList(); List <ShoppingCartItemInfo> cartItems = ShoppingCartItemInfoProvider.GetShoppingCartItems() .WhereIn("ShoppingCartID", shoppingCartIDs) .WhereEquals("SKUID", productID) .ToList(); gvCustomersCart.DataSource = myAddressList .Distinct() .Select(g => { var cartItem = cartItems .Where(k => k.GetValue("CartItemDistributorID", default(int)) == g.AddressID && k.SKUID == productID) .FirstOrDefault(); return(new { g.AddressID, g.AddressPersonalName, IsSelected = cartItem?.CartItemUnits > 0, ShoppingCartID = cartItem?.ShoppingCartID ?? default(int), SKUID = cartItem?.SKUID ?? default(int), SKUUnits = cartItem?.CartItemUnits ?? default(int) }); }) .ToList(); gvCustomersCart.Columns[1].HeaderText = AddressIDText; gvCustomersCart.Columns[2].HeaderText = AddressPersonalNameText; gvCustomersCart.DataBind(); } else { lblError.Text = ResHelper.GetString("Kadena.AddToCart.DistributorError"); lblError.Visible = true; } } catch (Exception ex) { EventLogProvider.LogException("CustomerCartOperations.ascx.cs", "BindCustomersList()", ex); } }
public string UpdateCartQuantity(Distributor distributorData) { if (distributorData.ItemQuantity < 1) { throw new Exception(ResHelper.GetString("KDA.Cart.Update.MinimumQuantityError", LocalizationContext.CurrentCulture.CultureCode)); } var shoppingCartItem = ShoppingCartItemInfoProvider.GetShoppingCartItemInfo(distributorData.CartItemId); if (distributorData.InventoryType == 1) { var shoppingCartIDs = ShoppingCartInfoProvider.GetShoppingCarts().WhereEquals("ShoppingCartUserID", distributorData.UserID).WhereEquals("ShoppingCartInventoryType", 1).ToList().Select(x => x.ShoppingCartID).ToList(); var shoppingcartItems = ShoppingCartItemInfoProvider.GetShoppingCartItems().WhereIn("ShoppingCartID", shoppingCartIDs).WhereEquals("SKUID", shoppingCartItem.SKUID).ToList(); int totalItems = 0; shoppingcartItems.ForEach(cartItem => { if (cartItem != null && cartItem.CartItemID != distributorData.CartItemId) { totalItems += cartItem.CartItemUnits; } }); var sku = SKUInfoProvider.GetSKUInfo(shoppingCartItem.SKUID); var currentProduct = DocumentHelper.GetDocuments(campaignClassName).WhereEquals("NodeSKUID", sku.SKUID).Columns("CampaignsProductID").FirstOrDefault(); var productHasAllocation = currentProduct != null?productProvider.IsProductHasAllocation(currentProduct.GetValue <int>("CampaignsProductID", default(int))) : false; var allocatedQuantityItem = GetAllocatedProductQuantityForUser(currentProduct.GetValue <int>("CampaignsProductID", default(int)), distributorData.UserID); var allocatedQuantity = allocatedQuantityItem != null?allocatedQuantityItem.GetValue <int>("Quantity", default(int)) : default(int); if (sku.SKUAvailableItems < totalItems + distributorData.ItemQuantity) { throw new Exception(ResHelper.GetString("KDA.Cart.Update.InsufficientStockMessage", LocalizationContext.CurrentCulture.CultureCode)); } else if (allocatedQuantity < totalItems + distributorData.ItemQuantity && productHasAllocation) { throw new Exception(ResHelper.GetString("Kadena.AddToCart.AllocatedProductQuantityError", LocalizationContext.CurrentCulture.CultureCode)); } } if (shoppingCartItem != null) { shoppingCartItem.CartItemUnits = distributorData.ItemQuantity; shoppingCartItem.Update(); return(ResHelper.GetString("KDA.Cart.Update.Success")); } else { throw new Exception(ResHelper.GetString("KDA.Cart.Update.Failure", LocalizationContext.CurrentCulture.CultureCode)); } }
public List <int> GetShoppingCartIDs(WhereCondition where) { return(ShoppingCartInfoProvider.GetShoppingCarts().Where(where) .Select(x => x.ShoppingCartID).ToList()); }
public List <int> GetUserShoppingCartIDs(int userID) { return(ShoppingCartInfoProvider.GetShoppingCarts(SiteContext.CurrentSiteID).WhereEquals("ShoppingCartUserID", userID)?.ToList().Select(x => x.ShoppingCartID).ToList()); }
public List <int> GetCampaingShoppingCartIDs(int campaignID) { return(ShoppingCartInfoProvider.GetShoppingCarts(SiteContext.CurrentSiteID).WhereEquals("ShoppingCartCampaignID", campaignID)?.ToList().Select(x => x.ShoppingCartID).ToList()); }
public List <int> GetUserIDsWithShoppingCart(int campaignID, int productType) { return(ShoppingCartInfoProvider.GetShoppingCarts().WhereEquals("ShoppingCartCampaignID", campaignID) .WhereEquals("ShoppingCartInventoryType", productType).ToList().Select(x => x.ShoppingCartUserID).Distinct().ToList()); }