Exemplo n.º 1
0
 //// POST: Admin/Product/Edit/5
 //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
 //// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
 //[HttpPost]
 //[ValidateAntiForgeryToken]
 //public ActionResult Edit([Bind(Include = "ID,Name,Code,MetaTitle,Description,Image,MoreImages,Price,PromotionPrice,IncludedVAT,Quantity,CategoryID,Detail,Warranty,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy,MetaKeywords,MetaDescriptions,Status,TopHot,ViewCount")] Product product, HttpPostedFileBase HinhAnh)
 //{
 //    //HttpPostedFileBase Image = null;
 //    if (ModelState.IsValid)
 //    {
 //        db.Entry(product).State = EntityState.Modified;
 //        if (product.Image != null)
 //        {
 //            HinhAnh.SaveAs(HttpContext.Server.MapPath("~/Content/images/")
 //                                                     + HinhAnh.FileName);
 //            product.Image = HinhAnh.FileName;
 //            //user.Image = userVal.Image;
 //        }
 //        db.SaveChanges();
 //        return RedirectToAction("Index");
 //    }
 //    ViewBag.CategoryID = new SelectList(db.ProductCategories, "ID", "Name", product.CategoryID);
 //    return View(product);
 //}
 IEnumerable <Product> GetAllProduct()
 {
     using (webQLCFCode db = new webQLCFCode())
     {
         return(db.Products.ToList <Product>());
     }
 }
Exemplo n.º 2
0
        public ActionResult Edit(Product product)
        {
            // try
            //{
            if (product.ImageUpload != null)
            {
                string fileName  = Path.GetFileNameWithoutExtension(product.ImageUpload.FileName);
                string extension = Path.GetExtension(product.ImageUpload.FileName);
                fileName      = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                product.Image = "/Assets/client/images/" + fileName;
                product.ImageUpload.SaveAs(Path.Combine(Server.MapPath("/Assets/client/images/"), fileName));
            }
            using (webQLCFCode db = new webQLCFCode())
            {
                if (product.ID == 0)
                {
                    db.Products.Add(product);
                    db.SaveChanges();
                }
                else
                {
                    db.Entry(product).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            // return Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllProduct()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet);
            //}
            //catch (Exception ex)
            //{

            //    return Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet);
            //}
            return(View(product));
        }
Exemplo n.º 3
0
 public ProductDao()
 {
     db = new webQLCFCode();
 }
Exemplo n.º 4
0
 public OrderDao()
 {
     db = new webQLCFCode();
 }
Exemplo n.º 5
0
 public UserDao()
 {
     db = new webQLCFCode();
 }