public ActionResult Create(PhotoGalleries gallery) { HttpPostedFileBase file = Request.Files["ImageURL"]; if (string.IsNullOrWhiteSpace(gallery.ImageDescription)) { ViewBag.MessageFail = "Fotoğraf açıklaması boş bırakılamaz!"; return(View()); } string galleryID = Request.QueryString["ID"]; if (galleryID == null) { if (file == null || file.FileName == "") { ViewBag.MessageFail = "Fotoğraf boş bırakılamaz!"; return(View()); } bool result = Helper.SaveImg(file, out string path); gallery.Status = true; gallery.ImageURL = path; bool result2 = Helper.Insert(gallery); if (result2) { ViewBag.Message = "Fotoğraf başarıyla eklendi."; return(View()); } else { ViewBag.MessageFail = "Fotoğraf kaydedilirken bir hata meydana geldi."; return(View()); } } else { PhotoGalleries oldGal = help.GetPhotoGallery(long.Parse(galleryID)); bool result = false; string path = ""; if (file != null && file.FileName != "") { result = Helper.SaveImg(file, out path); } if (result) { oldGal.ImageURL = path; } oldGal.ImageDescription = gallery.ImageDescription; Helper.Update(oldGal); ViewBag.Message = "Fotoğraf başarıyla güncellendi."; return(View(oldGal)); } }
public bool UpdateGallery(PhotoGalleries gallery) { bool result = false; var sql = "Update PhotoGalleries set ImageURL=@url,ImageDescription=@desc,Status=@status where ID=@id;"; int resultExecuteNonQuery = con.Execute(sql, new { url = gallery.ImageURL, desc = gallery.ImageDescription, status = true }); if (resultExecuteNonQuery == 1) { result = true; } return(result); }
public bool AddGallery(PhotoGalleries gallery) { bool result = false; var sql = "INSERT INTO PhotoGalleries (ImageURL,ImageDescription,Status) values (@url,@desc,@status);"; int resultExecuteNonQuery = con.Execute(sql, new { url = gallery.ImageURL, desc = gallery.ImageDescription, status = true }); if (resultExecuteNonQuery == 1) { result = true; } return(result); }
public ActionResult Create(long?ID) { if (ID != null) { PhotoGalleries gallery = help.GetPhotoGallery((long)ID); if (gallery == null) { return(HttpNotFound()); } return(View(gallery)); } return(View()); }
public ActionResult Delete() { string ID = Request.QueryString["ID"]; if (ID == null) { return(HttpNotFound()); } PhotoGalleries gal = help.GetPhotoGallery(long.Parse(ID)); if (gal == null) { return(HttpNotFound()); } Helper.Delete(gal); return(Redirect("/Galleries/Index?Status=DeleteSuccess")); }