public ActionResult AddProduct(product_productType_ViewModel model, System.Web.HttpPostedFileWrapper image)
 {
     if (ModelState.IsValid)
     {
         db.products.Add(new product {
             name       = model.product_name, unit_price = model.unit_price, promotion_price = model.promotion_price
             , image    = image.FileName,
             @new       = model.@new, unit = model.unit, description = model.description, id_product_type = model.id_product_type,
             created_at = System.DateTime.Now,
             updated_at = System.DateTime.Now
         });
         image.SaveAs(Server.MapPath(Path.Combine("~/image/product/", image.FileName)));
         db.SaveChanges();
         return(RedirectToAction(actionName: "Index", controllerName: "AdminProduct"));
     }
     return(View(model));
 }
        public ActionResult Edit(product_productType_ViewModel model, System.Web.HttpPostedFileWrapper image)
        {
            var obj = db.products.FirstOrDefault(x => x.id_product == model.id_product);

            obj.name            = model.product_name;
            obj.unit_price      = model.unit_price;
            obj.promotion_price = model.promotion_price;
            if (image != null)
            {
                obj.image = image.FileName;
                image.SaveAs(Server.MapPath(Path.Combine("~/image/product/", image.FileName)));
            }
            obj.id_product_type = model.id_product_type;
            obj.@new            = model.@new;
            obj.unit            = model.unit;

            obj.updated_at      = System.DateTime.Now;
            db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index", "AdminProduct"));
        }