public ActionResult UpdateSubGaleryImage(GalleryDetails item) { bool res = true; try { using (AbcUEMDbEntities db = new AbcUEMDbEntities()) { HttpPostedFileBase file = Request.Files[0]; if (file.ContentLength > 0) { var path = Server.MapPath("~/Images/Gallery/Details/" + item.Id + ".jpg"); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } file.SaveAs(path); } var obj = db.GalleryDetails.Find(item.Id); db.Entry(obj).CurrentValues.SetValues(item); db.SaveChanges(); } } catch { res = false; } return(Json(item.GalleryMasterId, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveImages(GalleryDetails item) { bool res = true; try { using (AbcUEMDbEntities db = new AbcUEMDbEntities()) { if (!Directory.Exists(Server.MapPath("~/Images/Gallery/Details"))) { Directory.CreateDirectory(Server.MapPath("~/Images/Gallery/Details")); } HttpPostedFileBase file = Request.Files[0]; var i = db.GalleryDetails.Add(item); db.SaveChanges(); string extension = Path.GetExtension(file.FileName); var path = Path.Combine(Server.MapPath("~/Images/Gallery/Details/"), i.Id + ".jpg"); file.SaveAs(path); } } catch { res = false; } return(Json(item.GalleryMasterId, JsonRequestBehavior.AllowGet)); }
public ActionResult AddComment(int id, GalleryDetails model) { using (ApplicationDbContext db = new ApplicationDbContext()) { var gallery = db.Galleries.FirstOrDefault(m => m.Id == id); if (gallery == null) { return(RedirectToAction("Index", "Movies")); } var comment = db.Comments.Add(new Comment() { Text = model.Text, Owner = User.Identity.Name }); gallery.Comments.Add(comment); db.SaveChanges(); return(RedirectToAction("Details", "Gallery", new { id })); } }
public ActionResult DeleteImage(GalleryDetails item) { bool res = true; try { using (AbcUEMDbEntities db = new AbcUEMDbEntities()) { db.GalleryDetails.Remove(db.GalleryDetails.Find(item.Id)); var pathMaster = Server.MapPath("~/Images/Gallery/Details/" + item.Id + ".jpg"); if (System.IO.File.Exists(pathMaster)) { System.IO.File.Delete(pathMaster); } db.SaveChanges(); } } catch { res = false; } return(Json(item.GalleryMasterId, JsonRequestBehavior.AllowGet)); }
public JsonResult GetGallery([FromQuery] int galleryTypeId) { GalleryDetails galleryDetails = new GalleryDetails(); return(Json(galleryDetails.GetGallery(galleryTypeId))); }
public JsonResult GetGalleryType() { GalleryDetails galleryDetails = new GalleryDetails(); return(Json(galleryDetails.GetGalleryType())); }