public static void AddProductVersion(Product product, int versionId) { //see if already exists in cart Simplicity.Data.Version version = ProductBO.GetVersion(versionId); ShoppingItem shoppingItem = new ShoppingItem(); shoppingItem.ProductEntity = product; shoppingItem.VersionEntity = version; shoppingItem.DurationInMonths = WebConstants.DEFAULT_DURATION; shoppingItem.Quantity = version.MinUsers; AddShoppingItem(shoppingItem); }
public static void AddProductDetail(Product product, int productDetailId, int versionId) { ProductDetail productDetail = ProductBO.GetProductDetail(productDetailId); Simplicity.Data.Version version = ProductBO.GetVersion(versionId); ShoppingItem shoppingItem = new ShoppingItem(); shoppingItem.ProductEntity = product; shoppingItem.ProductDetailEntity = productDetail; shoppingItem.VersionEntity = version; shoppingItem.DurationInMonths = WebConstants.DEFAULT_DURATION; shoppingItem.Quantity = version.MinUsers; AddShoppingItem(shoppingItem); }
public static void AddShoppingItem(ShoppingItem shoppingItem) { List<ShoppingItem> shoppingItems = null; if (HttpContext.Current.Session[WebConstants.Session.TROLLEY] != null) { shoppingItems = (List<ShoppingItem>)HttpContext.Current.Session[WebConstants.Session.TROLLEY]; } else { shoppingItems = new List<ShoppingItem>(); } ReplaceShoppingItem(shoppingItems, shoppingItem); HttpContext.Current.Session[WebConstants.Session.TROLLEY] = shoppingItems; }
public static ShoppingItem Load(WishList wishList) { ShoppingItem shoppingItem = new ShoppingItem(); shoppingItem.ProductEntity = wishList.Product; shoppingItem.DurationInMonths = wishList.Duration; shoppingItem.Quantity = wishList.Quantity; shoppingItem.WishListItemId = wishList.WishListID; shoppingItem.VersionEntity = wishList.Version; shoppingItem.ProductDetailEntity = wishList.ProductDetail; return shoppingItem; }
private static void ReplaceShoppingItem(List<ShoppingItem> shoppingItems, ShoppingItem shoppingItemToAdd) { bool added = false; foreach (ShoppingItem shoppingItem in shoppingItems) { // if it is a product detail then it will have detail and version as well. // both items should have the same set therefore it is imp to check for that. if (shoppingItemToAdd.ProductDetailEntity != null) { if (shoppingItemToAdd.ProductDetailEntity != null && shoppingItemToAdd.VersionEntity != null && shoppingItem.ProductDetailEntity != null && shoppingItem.VersionEntity != null) { if (shoppingItemToAdd.ProductDetailEntity.ProductDetailID == shoppingItem.ProductDetailEntity.ProductDetailID && shoppingItemToAdd.VersionEntity.VersionID == shoppingItem.VersionEntity.VersionID) { shoppingItem.Quantity += shoppingItemToAdd.Quantity; added = true; } } } else { //if it is version the detail should be null if (shoppingItemToAdd.ProductDetailEntity == null && shoppingItem.ProductDetailEntity == null && shoppingItemToAdd.VersionEntity != null && shoppingItem.VersionEntity != null && shoppingItemToAdd.VersionEntity.VersionID == shoppingItem.VersionEntity.VersionID) { shoppingItem.Quantity += shoppingItemToAdd.Quantity; added = true; } } } if (!added) { shoppingItems.Add(shoppingItemToAdd); } }
private List<ShoppingItem> GetItems() { List<ShoppingItem> shoppingItems = new List<ShoppingItem>(); ShoppingItem shoppingItem = new ShoppingItem(); int productId = int.Parse(Request[WebConstants.Request.PRODUCT_ID]); product = new ProductBO(ProductBO.GetProduct(productId)); shoppingItem.ProductEntity = product.ProductEnity; if (Request[WebConstants.Request.VERSION_ID] != null) { Simplicity.Data.Version version = ProductBO.GetVersion(int.Parse(Request[WebConstants.Request.VERSION_ID])); shoppingItem.VersionEntity = version; shoppingItem.Quantity = version.MinUsers; } shoppingItem.DurationInMonths = WebConstants.DEFAULT_DURATION; if (Request[WebConstants.Request.PRODUCT_DETAIL_ID] != null) { int productDetailId = int.Parse(Request[WebConstants.Request.PRODUCT_DETAIL_ID]); ProductDetail productDetail = ProductBO.GetProductDetail(productDetailId); shoppingItem.ProductDetailEntity = productDetail; } shoppingItems.Add(shoppingItem); return shoppingItems; }