示例#1
0
 public void Delete(Portfolio folio = null)
 {
     if (folio != null)
     {
         db.Portfolios.Remove(folio);
         db.SaveChanges();
     }
 }
示例#2
0
 public ActionResult Create(Portfolio folio,HttpPostedFileBase file)
 {
     if (folio != null)
     {
         _db.Create(folio, file);
         return RedirectToAction("Index");
     }
     else return View();
 }
示例#3
0
        public ActionResult Edit(Portfolio folio,HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {

               _db.Edit(folio, file);
                return RedirectToAction("Index");
            }
            else return View();
        }
示例#4
0
        public void Edit(Portfolio folio = null, HttpPostedFileBase file = null)
        {
            byte[] newdata = null;
                var fol = db.Portfolios.Find(folio.ID);
                fol.Title = folio.Title;
                fol.Description = folio.Description;
                fol.Price = folio.Price;
                if (file != null)
                {
                    fol.ImageMimeType = file.ContentType;
                    newdata = new WebImage(file.InputStream).Resize(1280, 1024).GetBytes();
                    fol.ImageData = newdata;
                }

            db.SaveChanges();
        }
示例#5
0
 public void Create(Portfolio folio = null, HttpPostedFileBase file = null)
 {
     byte[] newdata=null;
     if (folio != null)
     {
         var gall = new Portfolio();
         gall.Title = folio.Title;
         gall.Description = folio.Description;
         gall.Price = folio.Price;
         gall.ImageMimeType = file.ContentType;
         newdata = new WebImage(file.InputStream).Resize(1280, 1024).GetBytes();
         gall.ImageData = newdata;
         //new BinaryReader(file.InputStream).ReadBytes(file.ContentLength);
         db.Portfolios.Add(gall);
     }
     db.SaveChanges();
 }