public void Delete(Portfolio folio = null) { if (folio != null) { db.Portfolios.Remove(folio); db.SaveChanges(); } }
public ActionResult Create(Portfolio folio,HttpPostedFileBase file) { if (folio != null) { _db.Create(folio, file); return RedirectToAction("Index"); } else return View(); }
public ActionResult Edit(Portfolio folio,HttpPostedFileBase file) { if (ModelState.IsValid) { _db.Edit(folio, file); return RedirectToAction("Index"); } else return View(); }
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(); }
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(); }