예제 #1
0
        public ActionResult DeleteImage(int id)
        {
            using (var context = new SiteContainer())
            {
                var image = context.ContentItemImage.First(c => c.Id == id);
                var contentItemId = image.ContentItemId;

                ImageHelper.DeleteImage(image.ImageSource);
                context.DeleteObject(image);
                context.SaveChanges();
                
                
                var contentItem = context.ContentItem.Include("ContentItemImages").First(c => c.Id == contentItemId);
                if (!contentItem.ContentItemImages.Any())
                {
                    context.DeleteObject(contentItem);
                    context.SaveChanges();
                }


            }
            return RedirectToAction("Index", "Home", new { area = "", id = "look" });
        }
예제 #2
0
 public ActionResult DeleteTextBlock(int id)
 {
     using (var context = new SiteContainer())
     {
         var contentItem = context.ContentItem.First(c => c.Id == id);
         context.DeleteObject(contentItem);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area = "", id = "look" });
     }
 }
예제 #3
0
        public ActionResult DeleteImagesBlock(int id)
        {
            using (var context = new SiteContainer())
            {
                var contentItem = context.ContentItem.Include("ContentItemImages").First(c => c.Id == id);

                while (contentItem.ContentItemImages.Any())
                {
                    var ci = contentItem.ContentItemImages.First();
                    ImageHelper.DeleteImage(ci.ImageSource);
                    context.DeleteObject(ci);
                }

                context.DeleteObject(contentItem);

                context.SaveChanges();



                return RedirectToAction("Index", "Home", new { area = "", id = "look" });
            }
        }