示例#1
0
        public ServiceResult AddToCart(string cartUUID, string inventoryUUID, float quantity)
        {
            if (string.IsNullOrWhiteSpace(inventoryUUID))
            {
                return(ServiceResponse.Error("Invalid inventory item id."));
            }

            if (quantity <= 0)
            {
                return(ServiceResponse.Error("Invalid quantity."));
            }

            StoreManager storeManager = new StoreManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            //todo return the shopping cart so the client is upto date.
            ServiceResult res = storeManager.AddToCart(cartUUID, inventoryUUID, quantity);

            if (res.Code != 200)
            {
                return(res);
            }

            ShoppingCart cart = storeManager.GetCart(cartUUID);

            if (cart == null)
            {
                return(ServiceResponse.Error("Could not retrieve cart."));
            }

            return(ServiceResponse.OK("", cart));
        }