public ActionResult DeleteConfirmed(int id) { ProductGalary productgalary = db.ProductGalaries.Find(id); db.ProductGalaries.Remove(productgalary); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(ProductGalary productgalary) { if (ModelState.IsValid) { db.Entry(productgalary).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productgalary)); }
// // GET: /Admin/Delete/5 public ActionResult Delete(int id = 0) { ProductGalary productgalary = db.ProductGalaries.Find(id); if (productgalary == null) { return(HttpNotFound()); } return(View(productgalary)); }
public ActionResult Upload(ProductGalary IG) { if (IG.File.ContentLength > (2 * 1024 * 1024)) { ModelState.AddModelError("CustomError", "File size must be less than 2MB"); return(View(IG)); } if (!(IG.File.ContentType == "image/jpeg" || IG.File.ContentType == "image/gif")) { ModelState.AddModelError("CustomError", "File type must be jpg or gif"); return(View()); } IG.Model = IG.Model; IG.Brand = IG.Brand; IG.Description = IG.Description; IG.Price = IG.Price; IG.FileName = IG.File.FileName; IG.ImageSize = IG.File.ContentLength; byte[] data = new byte[IG.File.ContentLength]; IG.File.InputStream.Read(data, 0, IG.File.ContentLength); IG.ImageData = data; using (MyDatabaseEntities dc = new MyDatabaseEntities()) { dc.ProductGalaries.Add(IG); dc.SaveChanges(); } return(RedirectToAction("Index")); }