// GET: Inventory/Create
        public ActionResult Create()
        {
            var product = db.Products.Select(s => new InventoryCreateVM()
            {
                ProductId   = s.Id,
                ProductName = s.ProductName
            });


            var model = new InventoryCreateVM();

            model.ProductSelectList = new SelectList(product, "ProductId", "ProductName");
            return(View(model));
        }
        public ActionResult Create(Inventory inventory)
        {
            if (ModelState.IsValid)
            {
                db.Inventories.Add(inventory);
                db.SaveChanges();

                // add qty to product table
                var product = db.Products.FirstOrDefault(p => p.Id == inventory.ProductId);
                if (product != null)
                {
                    product.CurrentQTY += inventory.InitialQTY;
                }
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            var model = new InventoryCreateVM();

            return(View(model));
        }