public int GetPreBuyDemandCount(int SKUID) { return(ShoppingCartItemInfoProvider.GetShoppingCartItems() .OnSite(SiteContext.CurrentSiteID) .Where(x => x.SKUID.Equals(SKUID)) .Sum(x => x.CartItemUnits)); }
/// <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)); } }
protected double GetProductPricettc(object oid, object id) { int orderId = Convert.ToInt32(oid); double result = 0; ShoppingCartInfo cart = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId); if (cart != null) { string where = "SKUID = " + id; ShoppingCartItemInfo item = null; DataSet items = ShoppingCartItemInfoProvider.GetShoppingCartItems(where, null); if (!DataHelper.DataSourceIsEmpty(items)) { item = new ShoppingCartItemInfo(items.Tables[0].Rows[0]); result = item.UnitTotalPrice; } } return(System.Math.Round(result, 2)); }
public List <ShoppingCartItemInfo> GetShoppingCartItemsByCartIDs(List <int> shoppingCartIDs) { return(ShoppingCartItemInfoProvider.GetShoppingCartItems().WhereIn("ShoppingCartID", shoppingCartIDs) .ToList()); }