コード例 #1
0
        //Todo optimize this process. Cache on client and cache here.
        // add better data retrieval..
        //
        private CartView GetCartView(ShoppingCart cart)
        {
            CartView cv = new CartView();

            try
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <ShoppingCart, CartView>();
                });

                IMapper mapper = config.CreateMapper();
                cv = mapper.Map <ShoppingCart, CartView>(cart);
            }
            catch (Exception ex)
            {
                SystemLogger logger = new SystemLogger(Globals.DBConnectionKey);
                logger.InsertException(ex, "StoreController", "GetCartView", ContextHelper.GetContextData());
                return(cv);
            }
            StoreManager storeManager = new StoreManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            cv.CartItems = storeManager.GetItemsInCart(cv.UUID);

            PriceManager cm = new PriceManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            cv.PriceRules = cm.GetPriceRules(cv.UUID, "shoppingcart");

            LocationManager lm   = new LocationManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            var             resb = lm.Get(cv.BillingLocationUUID);

            if (resb.Code == 200)
            {
                cv.BillingAddress = (Location)resb.Result;
            }

            if (cv.ShippingSameAsBiling == false)
            {
                var resc = lm.Get(cv.ShippingLocationUUID);
                if (resc.Code == 200)
                {
                    cv.ShippingAddress = (Location)resc.Result;
                }
            }

            return(cv);
        }
コード例 #2
0
        //Todo optimize this process. Cache on client and cache here.
        // add better data retrieval..
        //
        private CartView GetCartView(ShoppingCart cart)
        {
            CartView cv = new CartView();

            try
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <ShoppingCart, CartView>();
                });

                IMapper mapper = config.CreateMapper();
                cv = mapper.Map <ShoppingCart, CartView>(cart);
            }
            catch (Exception ex)
            {
                SystemLogger logger = new SystemLogger(Globals.DBConnectionKey);
                logger.InsertException(ex, "StoreController", "GetCartView", ContextHelper.GetContextData());
                return(cv);
            }
            StoreManager storeManager = new StoreManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            cv.CartItems = storeManager.GetItemsInCart(cv.UUID);

            PriceManager cm = new PriceManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            cv.PriceRules = cm.GetPriceRules(cv.UUID, "shoppingcart");

            LocationManager lm = new LocationManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            cv.BillingAddress = (Location)lm.GetBy(cv.BillingLocationUUID);

            if (cv.ShippingSameAsBiling == false)
            {
                cv.ShippingAddress = (Location)lm.GetBy(cv.ShippingLocationUUID);
            }

            return(cv);
        }