コード例 #1
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
 public ActionResult EditTextBlock(int id, FormCollection form)
 {
     using (var context = new SiteContainer())
     {
         var contentItem = context.ContentItem.First(c => c.Id == id);
         TryUpdateModel(contentItem, new[] { "SortOrder" });
         contentItem.Text = HttpUtility.HtmlDecode(form["Text"]);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area = "", id = "look" });
     }
 }
コード例 #2
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
 public ActionResult Edit(int id, FormCollection form)
 {
     using (var context = new SiteContainer())
     {
         var content = context.Content.First(c => c.Id == id);
         TryUpdateModel(content, new[] { "Title", "SortOrder", "SeoDescription", "SeoKeywords" });
         content.Text = HttpUtility.HtmlDecode(form["Text"]);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area = "", id = content.Name });
     }
 }
コード例 #3
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
 public ActionResult AddTextBlock(FormCollection form)
 {
     using (var context = new SiteContainer())
     {
         var contentItem = new ContentItem
                               {
                                   ContentType = 1,
                                   Text = HttpUtility.HtmlDecode(form["Text"])
                               };
         TryUpdateModel(contentItem, new[] { "SortOrder" });
         context.AddToContentItem(contentItem);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area = "", id = "look" });
     }
 }
コード例 #4
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
 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" });
     }
 }
コード例 #5
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
        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" });
        }
コード例 #6
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
        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" });
            }
        }
コード例 #7
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult EditImagesBlock(int id, FormCollection form)
        {
            using (var context = new SiteContainer())
            {
                var contentItem = context.ContentItem.First(c => c.Id == id);
                TryUpdateModel(contentItem, new[] { "SortOrder" });
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];

                    if (file == null) continue;
                    if (string.IsNullOrEmpty(file.FileName)) continue;

                    var ci = new ContentItemImage();
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                    string filePath = Server.MapPath("~/Content/Images");

                    filePath = Path.Combine(filePath, fileName);
                    GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500);

                    ci.ImageSource = fileName;
                    contentItem.ContentItemImages.Add(ci);
                }

                context.SaveChanges();

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