/// <summary> /// Adds a new item to a existing cart /// </summary> /// <remarks>If the item alredy exists in the cart, then only its quantity /// is updated</remarks> public void AddToCart(CartDS.CartItemsDataTable cartItems, int productId, int quantity) { try { ProductBusinessObject productBO = new ProductBusinessObject(); ProductDS products = new ProductDS(); productBO.GetProductById(products, productId); if (cartItems.Rows.Count > 0) { DataRow[] selectedItems = cartItems.Select("productID=" + productId); if (selectedItems.Length > 0) { ((CartDS.CartItem)selectedItems[0]).Quantity += quantity; } else { cartItems.AddCartItem(quantity, productId, products.Products[0].ModelName, products.Products[0].UnitCost); } } else { cartItems.AddCartItem(quantity, productId, products.Products[0].ModelName, products.Products[0].UnitCost); } } catch (Exception e) { throw new ApplicationException(ResourceManager.GetString("RES_ExceptionCantAddCartItem"), e); } }
/// <summary> /// Gets all products in the catalog /// </summary> public ProductDS GetCatalogProducts() { ProductDS productDS = new ProductDS(); try { ProductBusinessObject productBO = new ProductBusinessObject(); productBO.GetAllProducts(productDS, 0, 0); } catch (Exception e) { State[STATE_EXCEPTION] = e; State.NavigateValue = "error"; Navigate(); } return(productDS); }
/// <summary> /// Gets all products in the catalog /// </summary> public ProductDS GetCatalogProducts() { ProductDS productDS = new ProductDS(); try { ProductBusinessObject productBO = new ProductBusinessObject(); // fill the products dataset will all of the products in the database productBO.GetAllProducts(productDS, 0, 0); } catch (Exception e) { State[STATE_EXCEPTION] = e; State.NavigateValue = "fail"; Navigate(); } return(productDS); }