Exemple #1
0
        /// <summary>
        /// Update product in inventory async
        /// </summary>
        /// <param name="product">Product In Inventory</param>
        /// <returns>Response Message</returns>
        public async Task <ResponseMessage> UpdateProductInInventoryAsync(ProductInInventory product)
        {
            try
            {
                string responseData = "";
                using (var httpClient = new HttpClient {
                    BaseAddress = this._ShipHeroUri
                })
                {
                    product.Token = this._AccessToken;
                    string productOutput = JsonConvert.SerializeObject(product);

                    using (var content = new StringContent(productOutput, Encoding.Default, "application/json"))
                    {
                        using (var response = await httpClient.PostAsync("v1/general-api/update-inventory/", content))
                        {
                            responseData = await response.Content.ReadAsStringAsync();
                        }
                    }

                    var responseApi = JsonConvert.DeserializeObject <ResponseMessage>(responseData);

                    return(responseApi);
                }
            }
            catch (Exception e)
            {
                throw new ShipHeroException("UpdateProductInInventoryAsync", e.Message);
            }
        }
Exemple #2
0
        public async Task <int> Create(T entity, byte[] error)
        {
            int status = 0;

            if (typeof(T) == typeof(Inventory))
            {
                Inventory inventory = (Inventory)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addInventory(inventory, error, _ConnectionString));
            }
            if (typeof(T) == typeof(ProductInInventory))
            {
                ProductInInventory product = (ProductInInventory)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addProductToInventory(product, error, _ConnectionString));
            }
            if (typeof(T) == typeof(Product))
            {
                Product product = (Product)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addProduct(product, error, _ConnectionString));
            }

            if (typeof(T) == typeof(Order))
            {
                Order order = (Order)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addOrder(order, error, _ConnectionString));
            }

            if (typeof(T) == typeof(ProductInOrder))
            {
                ProductInOrder product = (ProductInOrder)(object)(entity);
                status = await Task.Run(() => Warehouse_Wrapper.addProductToOrder(product, error, _ConnectionString));
            }

            if (typeof(T) == typeof(Customer))
            {
                Customer customer = (Customer)(object)entity;
                if (_ConnectionString != null)
                {
                    status = await Task.Run(() => Crm_Wrapper.AddCustomer(customer, error, _ConnectionString));
                }
            }

            if (typeof(T) == typeof(Opportunity))
            {
                Opportunity opportunity = (Opportunity)(object)(entity);
                status = await Task.Run(() => Crm_Wrapper.AddOpportunity(opportunity, error, _ConnectionString));
            }

            if (typeof(T) == typeof(OpportunityProduct))
            {
                OpportunityProduct product = (OpportunityProduct)(object)(entity);
                status = await Task.Run(() => Crm_Wrapper.AddOpportunityProduct(product, error, _ConnectionString));
            }

            return(status);
        }
Exemple #3
0
        public async Task <ActionResult <string> > EditProductInInventory(ProductInInventory product)
        {
            byte[] error  = new byte[500];
            int    status = await _inventoryProductRepository.EditProductInInventory(product, error);

            string z = System.Text.Encoding.ASCII.GetString(error);

            if (status != 0)
            {
                return(BadRequest(z.Remove(z.IndexOf('\0'))));
            }
            else
            {
                return(Ok("successfuly added"));
            }
        }
 public static extern int editProductInInventory(ProductInInventory product, byte[] error, ConnectionString connectionString);