Exemplo n.º 1
0
        public async Task <bool> UpdateInventory(int itemId, int warehouseId, InventoryUpdateModel price)
        {
            string productUrl = Util.FormatUrl(Consts.INVENTORY_UPDATEINVENTORYBYSKUWAREHOUSE);

            productUrl = productUrl.Replace("{{skuId}}", itemId.ToString());
            productUrl = productUrl.Replace("{{warehouseId}}", warehouseId.ToString());

            var priceModel   = JsonConvert.SerializeObject(price);
            var httpResponse = await PutToUri(productUrl, new StringContent(priceModel));

            return(httpResponse.IsSuccessStatusCode);
        }
Exemplo n.º 2
0
        public ActionResult AddIngredients(InventoryUpdateModel inventoryUpdateModel)
        {
            var jsonResult = new JsonResult();

            if (Session["loggedIn"] != null || m_helper.Login(inventoryUpdateModel.LoginDetails, Constants.ODBCString))
            {
                var connectionString = Constants.ODBCString;
                using (var dbConnection = new ODBConnection(connectionString))
                    using (var persister = new ODBCPersister(dbConnection))
                    {
                        var count = int.Parse(persister.ExecuteScalar(string.Format(m_helper.GetQueryValue("checkCafeteriaManagerVendorID"), inventoryUpdateModel.InventoryModel.CafeteriaVendorID)).ToString());
                        if (count > 0)
                        {
                            // if it exists
                            var itemExists = int.Parse(persister.ExecuteScalar(string.Format(m_helper.GetQueryValue("checkStoreHouseInventoryItem"), inventoryUpdateModel.InventoryModel.IngredientID)).ToString()) > 0;
                            if (itemExists)
                            {
                                //update updateStoreHouseInventory
                                persister.ExecuteNonQueryCmd("StoreHouseInventory", string.Format(m_helper.GetQueryValue("updateStoreHouseInventory"),
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientID,
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientName,
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientQuantity,
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientQuantityUnit,
                                                                                                  "instock",
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientID));
                            }
                            else
                            {
                                persister.ExecuteNonQueryCmd("StoreHouseInventory", string.Format(m_helper.GetQueryValue("insertStoreHouseInventory"),
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientID,
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientName,
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientQuantity,
                                                                                                  inventoryUpdateModel.InventoryModel.IngredientQuantityUnit,
                                                                                                  "instock",
                                                                                                  inventoryUpdateModel.InventoryModel.CafeteriaVendorID));
                            }
                        }
                        else
                        {
                            var msg = "You are not previliged to complete this action";
                            jsonResult.Data = new { msg };
                        }
                    }
            }
            else
            {
                var msg = "Unable to Login";
                jsonResult.Data = new { msg };
            }

            return(jsonResult);
        }