Пример #1
0
 public ActionResult UpdateImageAttributes(int id, string contentId,string location,string materialText,string materialUrl,int sortOrder)
 {
     using (var context = new ContentStorage())
     {
         var galleryItem = context.Gallery.Include("Content").Where(c => c.Id == id).Select(c => c).First();
         galleryItem.Location = location;
         galleryItem.MaterialText = materialText;
         galleryItem.MaterialUrl = materialUrl;
         galleryItem.SortOrder = sortOrder;
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Content", new { id = contentId });
 }
Пример #2
0
 public ActionResult AddImageToGallery(int itemId, string contentId, string materialText, string materialUrl, string location, int sortOrder)
 {
     string file = Request.Files["image"].FileName;
     if (!string.IsNullOrEmpty(file))
     {
         string newFileName = IOHelper.GetUniqueFileName("~/Content/GalleryImages", file);
         string filePath = Path.Combine(Server.MapPath("~/Content/GalleryImages"), newFileName);
         Request.Files["image"].SaveAs(filePath);
         using (var context = new ContentStorage())
         {
             var galleryItem = new Gallery();
             galleryItem.ContentReference.EntityKey = new EntityKey("ContentStorage.Content", "Id", itemId);
             galleryItem.ImageSource = newFileName;
             galleryItem.MaterialText = materialText;
             galleryItem.MaterialUrl = materialUrl;
             galleryItem.Location = location;
             galleryItem.SortOrder = sortOrder;
             context.AddToGallery(galleryItem);
             context.SaveChanges();
         }
     }
     return RedirectToAction("Index", "Content", new { id = contentId });
 }
Пример #3
0
 public ActionResult DeleteImage(int id)
 {
     using (var context = new ContentStorage())
     {
         var galleryItem = context.Gallery.Include("Content").Where(c => c.Id == id).Select(c => c).First();
         string contentId = galleryItem.Content.ContentId;
         context.DeleteObject(galleryItem);
         context.SaveChanges();
         return RedirectToAction("Index", "Content", new { id = contentId });
     }
     
 }
Пример #4
0
 public ActionResult DeleteContentItem(int id)
 {
     using (var context = new ContentStorage())
     {
         Content content = context.Content.Include("Children").Where(c => c.Id == id).FirstOrDefault();
         if (content.Children.Count == 0)
         {
             context.DeleteObject(content);
             context.SaveChanges();
         }
         return RedirectToAction("Index", "Content", new { id = "About" });
     }
     
 }
Пример #5
0
        public ActionResult UpdateContent(int id, bool isGalleryItem, int? parentId, string contentId, string title, string description, string keywords, string text, bool collapsible, bool? horisontal,int sortOrder)
        {
            using (var context = new ContentStorage())
            {

                Content parent = null;
                int parentHorisontalLevel = 0;
                if (parentId != null)
                {
                    parent = context.Content.Select(c => c).Where(c => c.Id == parentId).First();
                    parentHorisontalLevel = context.Content.Where(c => c.Id == parentId).Select(c => c.HorisontalLevel).First();
                    if (parent.Horisontal)
                        parentHorisontalLevel++;
                }
                Content content = id != int.MinValue ? context.Content.Select(c => c).Where(c => c.Id == id).First() : new Content();
                content.Parent = parent;
                content.ContentId = contentId;
                content.Title = title;
                content.Description = description;
                content.Keywords = keywords;
                content.Text = HttpUtility.HtmlDecode(text);
                content.IsGalleryItem = isGalleryItem;
                content.Collapsible=collapsible;
                content.SortOrder = sortOrder;
                
                content.HorisontalLevel = parentHorisontalLevel;
                if (horisontal.HasValue)
                    content.Horisontal = horisontal.Value;
                if (content.Id == 0)
                    context.AddToContent(content);
                context.SaveChanges();


                if (collapsible && parent != null)
                    contentId = parent.ContentId;

                return RedirectToAction("Index", "Content", new { id = contentId });
            }
        }