コード例 #1
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult Edit(int id, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Include("Parent").Where(c => c.Id == id).First();
                string parentName = "";
                if (content.Parent != null)
                    parentName = content.Parent.Name;
                string name = content.Name;
                TryUpdateModel(content, new[]
                                   {
                                       "Name", 
                                       "Title", 
                                       "PageTitle", 
                                       "Description", 
                                       "SortOrder", 
                                       "SeoDescription",
                                       "SeoKeywords"
                                   });
                content.Text = HttpUtility.HtmlDecode(form["Text"]);
                context.SaveChanges();

                return RedirectToAction("Index", "Home", new { area = "", id = parentName!=""?parentName: name });
            }
        }
コード例 #2
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult Add(int id, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var content = new Content();
                var parent = context.Content.Where(c => c.Id == id).First();
                content.Parent = parent;

                string parentName = parent.Name;

                TryUpdateModel(content,
                               new[]
                                   {
                                       "Name", "Title", "PageTitle", "ContentType", "ContentLevel", "Description",
                                       "SortOrder", "SeoDescription", "SeoKeywords"
                                   });


                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);
                    content.ImageSource = fileName;
                }

                context.AddToContent(content);
                context.SaveChanges();

                return RedirectToAction("Index", "Home", new {area = "", id = parentName});
            }
        }
コード例 #3
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
 public ActionResult Edit(int id)
 {
     using (var context = new ContentStorage())
     {
         var content = context.Content.Where(c => c.Id == id).First();
         return View(content);
     }
 }
コード例 #4
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult Add(int id)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Where(c => c.Id == id).First();

                return View(new Content { ContentType = content.ContentType, ContentLevel = 1 });
            }
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: fathurxzz/aleqx
 public ActionResult Index(string id)
 {
     using (var context = new ContentStorage())
     {
         var content = context.Content.Where(c => string.IsNullOrEmpty(id) ? c.ContentType == 0 && c.ContentLevel == 0 : c.Name == id).First();
         ViewData["contentType"] = content.ContentType;
         ViewData["seoDescription"] = content.SeoDescription;
         ViewData["seoKeywords"] = content.SeoKeywords;
         return View(content);
     }
 }
コード例 #6
0
ファイル: HomeController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult Content(string id, int contentType)
        {
            using (var context = new ContentStorage())
            {
                if (!string.IsNullOrEmpty(id))
                {
                    var content = context.Content.Include("Parent").Include("Children").Where(c => c.Name == id).First();
                    ViewData["contentType"] = content.ContentType;
                    ViewData["seoDescription"] = content.SeoDescription;
                    ViewData["seoKeywords"] = content.SeoKeywords;
                    return View("Details", content);
                }

                var mainContent = context.Content.Include("Children").Where(c => c.ContentType == contentType && c.ContentLevel == 0).First();
                ViewData["contentType"] = mainContent.ContentType;
                ViewData["seoDescription"] = mainContent.SeoDescription;
                ViewData["seoKeywords"] = mainContent.SeoKeywords;
                return View("Index", mainContent);
            }
        }
コード例 #7
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult Delete(int id)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Include("Children").Where(c => c.Id == id).First();

                while (content.Children.Any())
                {
                    var child = content.Children.First();
                    if (!string.IsNullOrEmpty(child.ImageSource))
                    {
                        IOHelper.DeleteFile("~/Content/Photos", child.ImageSource);
                        IOHelper.DeleteFile("~/ImageCache/thumbnail1", child.ImageSource);
                        IOHelper.DeleteFile("~/ImageCache/thumbnail2", child.ImageSource);
                        context.DeleteObject(child);
                    }
                }


                if (!string.IsNullOrEmpty(content.ImageSource))
                {
                    IOHelper.DeleteFile("~/Content/Photos", content.ImageSource);
                    IOHelper.DeleteFile("~/ImageCache/thumbnail1", content.ImageSource);
                    IOHelper.DeleteFile("~/ImageCache/thumbnail2", content.ImageSource);
                }
                context.DeleteObject(content);
                context.SaveChanges();
            }
            return RedirectToAction("Index", "Home", new { area = "", id = "" });
        }
コード例 #8
0
ファイル: ContentController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult EditDetailsItem(int id, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                
                var content = context.Content.Include("Parent").Where(c => c.Id == id).First();
                string parentName = content.Parent.Name;
                TryUpdateModel(content, new[] { "SortOrder" });
                content.Description = HttpUtility.HtmlDecode(form["Description"]);

                if (Request.Files["logo"] != null && !string.IsNullOrEmpty(Request.Files["logo"].FileName))
                {
                    if(!string.IsNullOrEmpty(content.ImageSource))
                    {
                        IOHelper.DeleteFile("~/Content/Photos", content.ImageSource);
                        IOHelper.DeleteFile("~/ImageCache/thumbnail1", content.ImageSource);
                        IOHelper.DeleteFile("~/ImageCache/thumbnail2", content.ImageSource);
                    }

                    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);
                    content.ImageSource = fileName;
                }
                context.SaveChanges();

                return RedirectToAction("Content", "Home", new { area = "", id = parentName });
            }
        }