Ejemplo n.º 1
0
        public ActionResult HorisontalMenuLine(string contentId, int level, bool itemHasChildren, string parentParentContentId, string currentContentId)
        {
            using (var context = new ContentStorage())
            {
                var parentContentId = context.Content.Where(c => c.ContentId == contentId).Select(c => c.Parent.ContentId).FirstOrDefault();
                var menuItemsList = context.Content.Where(c => c.ContentId == contentId).SelectMany(c => c.Children).Where(c => c.Horisontal).ToList();

                if (menuItemsList.Count == 0 && level == 0)
                {
                    ViewData["lastLevel"] = true;
                }
                else
                {
                    ViewData["lastLevel"] = false;
                }

                ViewData["level"] = level + 1;
                ViewData["contentId"] = contentId;
                ViewData["parentContentId"] = parentContentId;
                ViewData["parentParentContentId"] = parentParentContentId;
                ViewData["currentContentId"] = currentContentId;
                ViewData["itemHasChildrenParent"] = menuItemsList.Count > 0;
                ViewData["itemHasChildren"] = itemHasChildren;

                return View(menuItemsList);
            }
        }
Ejemplo n.º 2
0
 public ActionResult EditImageAttributes(int id, string contentId)
 {
     using(var context = new ContentStorage())
     {
         var galleryItem = context.Gallery.Include("Content").Where(c => c.Id == id).Select(c => c).First();
         return View(galleryItem);
     }
 }
Ejemplo n.º 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 });
     }
     
 }
Ejemplo n.º 4
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 });
 }
Ejemplo n.º 5
0
        //
        // GET: /Content/

        public ActionResult Index(string id)
        {
            string contentId = id;
            using (var context = new ContentStorage())
            {
                ViewData["contentId"] = contentId;
                ViewData["mcontentId"] = contentId;
                var content = context.Content.Include("Parent").Include("Galleries").Include("Children").Where(c => c.ContentId == contentId).FirstOrDefault();
                if (content != null)
                {
                    if (content.Parent != null)
                    {
                        ViewData["mparentContentId"]=ViewData["parentContentId"] = content.Parent.ContentId;
                    }

                    if (content.Horisontal && content.HorisontalLevel > 0)
                    {
                        if (content.HorisontalLevel == 1)
                        {
                            var mcontent = context.Content.Include("Parent").Include("Galleries").Include("Children").Where(c => c.Horisontal && c.HorisontalLevel == 0&&c.ContentId==content.Parent.ContentId).FirstOrDefault();
                            if (mcontent != null)
                            {
                                Session["mcontentId"] = ViewData["mcontentId"] = mcontent.ContentId;
                                if (mcontent.Parent != null)
                                {
                                    Session["mparentContentId"] = ViewData["mparentContentId"] = mcontent.Parent.ContentId;
                                }
                            }
                        }
                        else
                        {
                            ViewData["mcontentId"] = Session["mcontentId"];
                            ViewData["mparentContentId"] = Session["mparentContentId"];
                        }
                    }
                }


                

                return View("Content", content);
            }
        }
Ejemplo n.º 6
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 });
 }
Ejemplo n.º 7
0
 public ActionResult ManageGalleryPictures(int id)
 {
     ViewData["id"] = id;
     using (var context = new ContentStorage())
     {
         var pictures = context.Gallery.Where(c=>c.Content.Id==id).Select(c => c).ToList();
         return View(pictures);
     }
 }
Ejemplo n.º 8
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" });
     }
     
 }
Ejemplo n.º 9
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 });
            }
        }
Ejemplo n.º 10
0
 public ActionResult GalleryList(int? id, int level)
 {
     using (var context = new ContentStorage())
     {
         List<Content> galleryList = context.Content.Where(c => c.IsGalleryItem).Select(c => c).ToList();
         if (id == null)
             galleryList = galleryList.Select(c => c).Where(c => c.Parent == null).ToList();
         else
             galleryList = galleryList.Select(c => c).Where(c => c.Parent != null && c.Parent.Id == id.Value).ToList();
         ViewData["level"] = level;
         if (id != null)
             ViewData["id"] = id.Value;
         return View(galleryList);
     }
 }
Ejemplo n.º 11
0
        public ActionResult EditGalleryItem(int id, int? parentId)
        {
            ViewData["parentId"] = parentId;

            using (var context = new ContentStorage())
            {
                var contentItem = context.Content.Where(c => c.Id == id).Select(c => c).FirstOrDefault();
                return View(contentItem);
            }
        }
Ejemplo n.º 12
0
 public ActionResult EditContentItem(int id, int? parentId, bool? horisontal, bool? collapsible, bool? isGalleryItem)
 {
     ViewData["parentId"] = parentId;
     ViewData["horisontal"] = horisontal;
     ViewData["collapsible"] = collapsible;
     ViewData["isGalleryItem"] = isGalleryItem ?? false;
     using (var context = new ContentStorage())
     {
         var contentItem = context.Content.Where(c => c.Id == id).Select(c => c).FirstOrDefault();
         return View(contentItem);
     }
 }