예제 #1
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 });
     }
 }
예제 #2
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 });
     }
 }
예제 #3
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});
            }
        }
예제 #4
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 });
            }

        }
예제 #5
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 });
            }
        }
예제 #6
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 });
            }
        }
예제 #7
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 });
            }
        }