// GET: Country_Photos/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index")); } Country_Photos country_Photos = db.Country_Photos.Find(id); if (country_Photos == null) { return(HttpNotFound()); } return(View(country_Photos)); }
public ActionResult DeleteConfirmed(int id) { Country_Photos country_Photos = db.Country_Photos.Find(id); db.Country_Photos.Remove(country_Photos); db.SaveChanges(); FileInfo F = new FileInfo(Server.MapPath("~/Uploads/Country_Photos/" + id + ".jpg")); if (F.Exists) { F.Delete(); } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ID,Description,Country_ID")] Country_Photos country_Photos, HttpPostedFileBase Photo) { try { if (ModelState.IsValid && Photo != null) { country_Photos.Description_en = DEL.TranslateText(country_Photos.Description, "ar|en"); db.Country_Photos.Add(country_Photos); db.SaveChanges(); Photo.SaveAs(Server.MapPath("~/Uploads/Country_Photos/" + country_Photos.ID + ".jpg")); ViewBag.Done = "تم الاضافة"; } }catch (Exception ex) { ViewBag.error = ex.Message; } return(View(country_Photos)); }
public ActionResult Edit([Bind(Include = "ID,Description,Country_ID")] Country_Photos country_Photos, HttpPostedFileBase Photo) { try { if (ModelState.IsValid) { country_Photos.Description_en = DEL.TranslateText(country_Photos.Description, "ar|en"); db.Entry(country_Photos).State = EntityState.Modified; db.SaveChanges(); if (Photo != null) { Photo.SaveAs(Server.MapPath("~/Uploads/Country_Photos/" + country_Photos.ID + ".jpg")); } ViewBag.Done = "تم التعديل"; } }catch (Exception ex) { ViewBag.error = ex.Message; } return(View(country_Photos)); }