Пример #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);
                }
            }
        }
Пример #2
0
 public BusinessCartContract.Cart DeleteItemsFromCart(string cartId, BusinessCartContract.Items deleteItems)
 {
     ProxyCartContract.Items   proxyItems   = Mapper.Map <BusinessCartContract.Items, ProxyCartContract.Items>(deleteItems);
     ProxyCartContract.Cart    cart         = this.cartService.DeleteItemsFromCart(cartId, proxyItems);
     BusinessCartContract.Cart businessCart = this.ConvertToBusinessCart(cart);
     return(businessCart);
 }
Пример #3
0
        private void UpdateUIContract(BusinessCartContract.Cart businessCart, UICartContract.Cart proxyCart)
        {
            proxyCart.id        = businessCart.id;
            proxyCart.userId    = businessCart.userId;
            proxyCart.created   = businessCart.created;
            proxyCart.status    = businessCart.status;
            proxyCart.type      = businessCart.type;
            proxyCart.cartId    = businessCart.cartId;
            proxyCart.lineItems = new List <LineItem>();

            foreach (BusinessCartContract.LineItem line in businessCart.lineItems)
            {
                UICartContract.LineItem UILineItem = new LineItem()
                {
                    articleID = line.articleID,
                    name      = line.name,
                    quantity  = line.quantity,
                    subTotal  = new SubTotal()
                    {
                        amount = line.subTotal.amount, currency = line.subTotal.currency
                    },
                    unitPrice = new UnitPrice()
                    {
                        amount = line.unitPrice.amount, currency = line.unitPrice.currency
                    }
                };

                proxyCart.lineItems.Add(UILineItem);
            }

            proxyCart.subTotal = new SubTotal2()
            {
                amount = businessCart.subTotal.amount, currency = businessCart.subTotal.currency
            };
        }
Пример #4
0
 public BusinessCartContract.Cart AddItemsToCart(string cartId, BusinessCartContract.Items addItems)
 {
     ProxyCartContract.Items   proxyItems   = Mapper.Map <BusinessCartContract.Items, ProxyCartContract.Items>(addItems);
     ProxyCartContract.Cart    cart         = this.cartService.AddItemsToCart(cartId, proxyItems);
     BusinessCartContract.Cart businessCart = this.ConvertToBusinessCart(cart);
     return(businessCart);
 }
Пример #5
0
        public void LoadCartInstance(BusinessCartContract.Cart cart)
        {
            UpdateUIContract(cart, _instance);

            if (activeCartLoaded != null)
            {
                activeCartLoaded.Invoke(_instance);
            }
        }
Пример #6
0
 private UICartContract.Cart ConvertToUICart(BusinessCartContract.Cart businessCart)
 {
     UICartContract.Cart proxyCart = Mapper.Map <BusinessCartContract.Cart, UICartContract.Cart>(businessCart);
     return(proxyCart);
 }
Пример #7
0
 private BusinessCartContract.Cart ConvertToBusinessCart(UICartContract.Cart proxyCart)
 {
     BusinessCartContract.Cart businessCart = Mapper.Map <UICartContract.Cart, BusinessCartContract.Cart>(proxyCart);
     return(businessCart);
 }
Пример #8
0
 public BusinessCartContract.Cart AbandonCart(string cartId)
 {
     ProxyCartContract.Cart    proxyCart = this.cartService.AbandonActiveCart(cartId);
     BusinessCartContract.Cart cart      = this.ConvertToBusinessCart(proxyCart);
     return(cart);
 }
Пример #9
0
 public BusinessCartContract.Cart CheckOutCart(string cartId)
 {
     ProxyCartContract.Cart    proxyCart = this.cartService.CheckOutCart(cartId);
     BusinessCartContract.Cart cart      = this.ConvertToBusinessCart(proxyCart);
     return(cart);
 }
Пример #10
0
 public BusinessCartContract.Cart OpenCart()
 {
     ProxyCartContract.Cart    cart         = this.cartService.OpenCart();
     BusinessCartContract.Cart businessCart = this.ConvertToBusinessCart(cart);
     return(businessCart);
 }