Exemple #1
0
        public void UpdateItems(Items item)
        {
            BusinessCartContract.Items businessItem = Mapper.Map <UICartContract.Items, BusinessCartContract.Items>(item);

            cartBL = new CartBL(new Credential {
                UserName = InterplayStorage.SelectedUser.UserName, Password = InterplayStorage.SelectedUser.Password
            });

            BusinessCartContract.Cart cart = null;

            // Open the cart while adding the first item to the cart
            if (CartInstance == null || CartInstance.id == null)
            {
                cart = cartBL.OpenCart();
                // dont use below mapper, its creating new objects, loosing the event handlers, so do it manually
                //_instance = this.ConvertToUICart(cart);
                UpdateUIContract(cart, _instance);
            }

            if (_instance.status == "OPEN" && _instance.type == "Cart")
            {
                cart = cartBL.AddItemsToCart(_instance.id, businessItem);
                // dont use below mapper, its creating new objects, loosing the event handlers, so do it manually
                //_instance = this.ConvertToUICart(cart);
                UpdateUIContract(cart, _instance);

                if (this.cartItemUpdated != null)
                {
                    this.cartItemUpdated.Invoke(_instance);
                }
            }
        }