Ejemplo n.º 1
0
 public FileResult ProductCategoryImgage(int id)
 {
     ProductCategory category = new ProductCategory();
     category = db.ProductCategories.Find(id);
     return File(category.Picture, "image/jpg");
 }
Ejemplo n.º 2
0
 public ActionResult AddProductCategory(ProductCategory model, HttpPostedFileBase file)
 {
     if (file != null)
     {
         System.IO.Stream stream = file.InputStream;
         byte[] buffer = new byte[stream.Length];
         stream.Read(buffer, 0, (int)stream.Length);
         stream.Close();
         model.Picture = buffer;
         model.AddTime = DateTime.Now;
         db.ProductCategories.Add(model);
         db.SaveChanges();
         return Redirect("/Admin/ProductCategoryManager");
     }
     else
     {
         return Redirect("/Admin/AdminMessage?msg=你填写信息不正确,请重新填写!");
     }
 }
Ejemplo n.º 3
0
 public ActionResult ShowProductCategoryImg(int id)
 {
     ProductCategory category = new ProductCategory();
     category = db.ProductCategories.Find(id);
     return File(category.Picture, "image/jpg");
 }
Ejemplo n.º 4
0
 public ActionResult ProductCategoryEdit(ProductCategory model, HttpPostedFileBase file)
 {
     ProductCategory category = new ProductCategory();
     category = db.ProductCategories.Find(model.ID);
     category.Content = model.Content;
     category.FatherID = model.FatherID;
     category.Priority = model.Priority;
     if (file != null)
     {
         System.IO.Stream stream = file.InputStream;
         byte[] buffer = new byte[stream.Length];
         stream.Read(buffer, 0, (int)stream.Length);
         stream.Close();
         category.Picture = buffer;
     }
     db.SaveChanges();
     return Redirect("/Admin/ProductCategoryManager");
 }
Ejemplo n.º 5
0
        public ActionResult ProductCategoryEdit(int id)
        {
            ProductCategory category = new ProductCategory();
            category = db.ProductCategories.Find(id);

            List<ProductCategory> categories = new List<ProductCategory>();
            categories = db.ProductCategories.Where(pc => (pc.FatherID == null || pc.FatherID == 0) && pc.Belong == (ProductBelong)category.Belong).ToList();
            ViewBag.LastProductCategories = categories;
            return View(category);
        }
Ejemplo n.º 6
0
 public ActionResult ProductCategoryDelete(int id)
 {
     try
     {
         ProductCategory category = new ProductCategory();
         category = db.ProductCategories.Find(id);
         List<ProductCategory> categories = new List<ProductCategory>();
         categories = db.ProductCategories.Where(pc => pc.FatherID == id).ToList();
         foreach (var item in categories)
         {
             item.FatherID = 0;
         }
         db.ProductCategories.Remove(category);
         db.SaveChanges();
         return Content("ok");
     }
     catch
     {
         return Content("err");
     }
 }