Ejemplo n.º 1
0
        public ActionResult Delete(int id)
        {
            using (var context = new ContentStorage())
            {

                var gallery = context.Gallery.Include("GalleryItems").Include("Content").Where(g => g.Id == id).First();
                var content = gallery.Content;

                while (gallery.GalleryItems.Any())
                {
                    var photo = gallery.GalleryItems.First();
                    if (!string.IsNullOrEmpty(photo.ImageSource))
                    {
                        IOHelper.DeleteFile("~/Content/Photos", photo.ImageSource);
                        IOHelper.DeleteFile("~/ImageCache/mainView", photo.ImageSource);
                        IOHelper.DeleteFile("~/ImageCache/thumbnail", photo.ImageSource);
                        IOHelper.DeleteFile("~/ImageCache/galleryThumbnail", photo.ImageSource);
                    }
                    context.DeleteObject(gallery.GalleryItems.First());
                }

                context.DeleteObject(gallery);

                context.SaveChanges();

                return RedirectToAction("Index", "Home", new { area = "", id = content.Name });
            }
        }
Ejemplo n.º 2
0
 public ActionResult Edit(int id)
 {
     using (var context = new ContentStorage())
     {
         var content = context.Content.Where(c => c.Id == id).First();
         return View(content);
     }
 }
Ejemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            using (var context = new ContentStorage())
            {

                var gallery = context.Gallery.Include("Content").Where(g => g.Id == id).First();
                ViewData["contentName"] = gallery.Content.Name;
                return View(gallery);
            }
        }
Ejemplo n.º 4
0
 public ActionResult Delete(int id)
 {
     using (var context = new ContentStorage())
     {
         var content = context.Content.Include("Parent").Where(c => c.Id == id).First();
         string parentName = content.Parent.Name;
         context.DeleteObject(content);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area = "", id = parentName });
     }
 }
Ejemplo n.º 5
0
 public ActionResult Add(int id)
 {
     ViewData["id"] = id;
     using (var context = new ContentStorage())
     {
         var content = context.Content.Include("Galleries").Where(c => c.Id == id).First();
         int sortOrder = content.Galleries.Count > 0 ? content.Galleries.Max(c => c.SortOrder) : -1;
         ViewData["SortOrder"] = (sortOrder + 1).ToString();
         return View(new Gallery {SortOrder = sortOrder + 1});
     }
 }
Ejemplo n.º 6
0
        public ActionResult Edit(int id, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var gallery = context.Gallery.Include("Content").Where(g => g.Id == id).First();
                var content = gallery.Content;



                return RedirectToAction("Index", "Home", new { area = "", id = content.Name });
            }
        }
Ejemplo n.º 7
0
 public ActionResult Edit(int id, FormCollection form)
 {
     using (var context = new ContentStorage())
     {
         Content content = context.Content.Where(c => c.Id == id).FirstOrDefault();
         TryUpdateModel(content, new string[] { "Name", "PageTitle", "PageTitleEng", "Title", "TitleEng", "SeoKeywords", "SeoKeywordsEng", "SeoDescription", "SeoDescriptionEng", "SortOrder" });
         content.Text = HttpUtility.HtmlDecode(form["Text"]);
         content.TextEng = HttpUtility.HtmlDecode(form["TextEng"]);
         content.Description = HttpUtility.HtmlDecode(form["Description"]);
         content.DescriptionEng = HttpUtility.HtmlDecode(form["DescriptionEng"]);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area = "", id = content.Name });
     }
 }
Ejemplo n.º 8
0
        public ActionResult Add(int id, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var parentContent = context.Content.Where(c => c.Id == id).First();

                var content = new Content {ContentLevel = 1};
                TryUpdateModel(content, new string[] { "Name", "PageTitle", "PageTitleEng", "Title", "TitleEng", "SeoKeywords", "SeoKeywordsEng", "SeoDescription", "SeoDescriptionEng", "SortOrder" });             
                content.Parent = parentContent;
                context.AddToContent(content);
                context.SaveChanges();

                return RedirectToAction("Index", "Home", new {area="", id = parentContent.Name});
            }
        }
Ejemplo n.º 9
0
        public ActionResult Add(int id, FormCollection form)
        {
            ViewData["id"] = id;

            using (var context = new ContentStorage())
            {
                var content = context.Content.Where(c => c.Id == id).First();

                var gallery = new Gallery
                {
                    Content = content,
                };

                TryUpdateModel(gallery, new string[] { "Description", "DescriptionEng", "SortOrder" });

                context.AddToGallery(gallery);
                context.SaveChanges();

                return RedirectToAction("Index", "Home", new { area = "", id = content.Name });
            }

        }
Ejemplo n.º 10
0
        public ActionResult SetPreviewPicture(int id)
        {
            using (var context = new ContentStorage())
            {
                var photo = context.GalleryItem.Include("Gallery").Where(p => p.Id == id).First();
                long galleryId = photo.Gallery.Id;
                var gallery = context.Gallery.Include("Content").Where(g => g.Id == galleryId).First();

                gallery.ImageSource = photo.ImageSource;
                context.SaveChanges();

                return RedirectToAction("Index", "Home", new { area = "", id = gallery.Content.Name, galleryId = galleryId });
            }
        }
Ejemplo n.º 11
0
        public ActionResult AddPhoto(int galleryId, string contentName, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var gallery = context.Gallery.Include("GalleryItems").Where(g => g.Id == galleryId).FirstOrDefault();
                
                if (Request.Files["logo"] != null && !string.IsNullOrEmpty(Request.Files["logo"].FileName))
                {
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Photos", Request.Files["logo"].FileName);
                    string filePath = Server.MapPath("~/Content/Photos");
                    filePath = Path.Combine(filePath, fileName);
                    Request.Files["logo"].SaveAs(filePath);

                    GraphicsHelper.SaveCachedImage("~/Content/Photos", fileName, "mainView");
                    GraphicsHelper.SaveCachedImage("~/Content/Photos", fileName, "galleryThumbnail");


                    gallery.GalleryItems.Add(new GalleryItem { ImageSource = fileName });

                    if (gallery.GalleryItems.Count == 1)
                        gallery.ImageSource = fileName;

                    context.SaveChanges();
                }

                return RedirectToAction("Index", "Home", new { area = "", id = contentName, galleryId=galleryId });
            }
        }
Ejemplo n.º 12
0
 public ActionResult AddPhoto(int id)
 {
     ViewData["galleryId"] = id;
     using (var context = new ContentStorage())
     {
         var gallery = context.Gallery.Include("Content").Where(g => g.Id == id).First();
         ViewData["contentName"] = gallery.Content.Name;
     }
     return View();
 }
Ejemplo n.º 13
0
        public ActionResult Index(string id, int? galleryPage, int? galleryId)
        {
            using (var context = new ContentStorage())
            {
                var menuItems = context.Content.Where(c => c.ContentLevel == 0 && c.Id != 1).OrderBy(c => c.SortOrder).ToList();
                ViewData["menuItems"] = menuItems;

                Content content;
                if (id == null)
                    content = context.Content.Where(c => c.Id == 1).FirstOrDefault();
                else
                {
                    content = context.Content.Include("Parent").Include("Children").Include("Galleries").Where(c => c.Name == id).FirstOrDefault();
                    if (content.Parent != null)
                        ViewData["parentContentName"] = content.Parent.Name;
                }
                if (content.Children.Count > 0)
                {
                    var subMenuItems = content.Children.OrderBy(c => c.SortOrder).ToList();
                    ViewData["subMenuItems"] = subMenuItems;
                }
                else if (content.Parent != null)
                {
                    var parentContentId = content.Parent.Id;
                    var parentContent = context.Content.Include("Children").Where(pc => pc.Id == parentContentId).First();
                    var subMenuItems = parentContent.Children.OrderBy(c => c.SortOrder).ToList();
                    ViewData["subMenuItems"] = subMenuItems;
                }



                if (content.Galleries.Count > 0)
                {
                    if (galleryPage.HasValue)
                    {
                        ViewData["galleryPage"] = galleryPage.Value;
                    }

                    ViewData["Galleries"] = content.Galleries;

                }
                else
                {
                    ViewData["Galleries"] = new List<Gallery>();
                }

                if(galleryId.HasValue)
                {
                    var gallery = context.Gallery.Include("GalleryItems").Where(g => g.Id == galleryId.Value).First();
                    ViewData["Gallery"] = gallery;
                    ViewData["galleryId"] = galleryId.Value;
                }else
                {
                    ViewData["Gallery"] = new Gallery();
                }


                ViewData["contentName"] = content.Name;
                ViewData["contentId"] = content.Id;
                ViewData["contentLevel"] = content.ContentLevel;



                return View(content);
            }
        }