public void AddProductTest()
        {
            //  dbSetUp();
            ProductMgr target = new ProductMgr(); // TODO: Initialize to an appropriate value

            // Target product-------------
            Product product = new Product();
            product.ProductID = "CB-100";
            product.ProductName = "Corned Beef";
            product.UnitID = 1;
            product.QuantityReceived = 12;
            product.UnitPrice = 30;
            product.CategoryID = 1;
            product.Description = "Canned Beef";
            product.SupplierCode = "MT-100";

            //-------------
            try
            {
               target.AddProduct(product);
            }
            catch (ProductMgrException e)
            {
                Assert.Fail(e.ToString());//force fail of test
            }
        }
        public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
               // db.Products.Add(product);
                //db.SaveChanges();
                ProdMgr.AddProduct(product);
                return RedirectToAction("Index");
            }

            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "name", product.CategoryID);
            ViewBag.SupplierCode = new SelectList(db.Suppliers, "SupplierCode", "SupplierName", product.SupplierCode);
            ViewBag.UnitID = new SelectList(db.Units, "UnitID", "name", product.UnitID);
            return View(product);
        }
 //method for updating a product
 public void UpdateProduct(Product product)
 {
     db.Entry(product).State = EntityState.Modified;
     db.SaveChanges();
 }
 //Here is the once-per-class call to initialize the log object
 //private static readonly log4net.ILog log =
 //log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 //service for adding product information
 public void AddProduct(Product product)
 {
     db.Products.Add(product);
     db.SaveChanges();
 }
 public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         //db.Entry(product).State = EntityState.Modified;
        // db.SaveChanges();
         ProdMgr.UpdateProduct(product);
         return RedirectToAction("Index");
     }
     ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "name", product.CategoryID);
     ViewBag.SupplierCode = new SelectList(db.Suppliers, "SupplierCode", "SupplierName", product.SupplierCode);
     ViewBag.UnitID = new SelectList(db.Units, "UnitID", "name", product.UnitID);
     return View(product);
 }
        public void UpdateProductTest()
        {
            ProductMgr target = new ProductMgr(); // TODO: Initialize to an appropriate value

            // Target product-------------
            Product product = new Product();
            product.ProductID = "CB-100";
            product.ProductName = "CB Chicken";
            product.UnitID = 1;
            product.QuantityReceived = 12;
            product.UnitPrice = 30;
            product.CategoryID = 1;
            product.Description = "Chicken";
            //-------------
            try
            {
             target.UpdateProduct(product);

            }
            catch (ProductMgrException e)
            {
                Assert.Fail(e.ToString());//force fail of test
            }
        }
        public void SearchProductTest()
        {
            Product product = new Product();

            ProductMgr target = new ProductMgr(); // TODO: Initialize to an appropriate value
            try
            {

               product = target.SearchProduct("CB-100");

            }
            catch (ProductMgrException e)
            {
                Assert.Fail(e.ToString());//force fail of test
            }
        }