Exemple #1
0
        public ActionResult UpdateContent(int id, int? parentId, string contentId, string title, string description, string keywords, string text, int sortOrder)
        {
            using (var context = new ContentStorage())
            {
                Content parent = null;
                if (parentId != null)
                {
                    parent = context.Content.Select(c => c).Where(c => c.Id == parentId).First();
                }

                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.SortOrder = sortOrder;

                if (content.Id == 0)
                    context.AddToContent(content);
                context.SaveChanges();
                return RedirectToAction("Index", "Content", new { id = contentId });
            }
        }
Exemple #2
0
        //
        // GET: /News/

        public ActionResult Index()
        {
            using (var context = new ContentStorage())
            {
                var newsList = context.Article.Select(c => c).ToList();
                return View(newsList);
            }
        }
Exemple #3
0
 public ActionResult EditContentItem(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);
     }
 }
Exemple #4
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" });
            }

        }
Exemple #5
0
        //
        // GET: /Content/

        public ActionResult Index(string id)
        {
            string contentId = id;
            using (var context = new ContentStorage())
            {
                
                var content = context.Content.Include("Parent").Where(c => c.ContentId == contentId).Select(c => c).FirstOrDefault();
                if (content != null)
                {
                    ViewData["ContentId"] = content.ContentId;
                    if (content.Parent != null)
                    {
                        ViewData["ParentContentId"] = content.Parent.ContentId;
                        ViewData["ParentId"] = content.Parent.Id;
                    }
                }
                return View("Content", content);
            }
        }
Exemple #6
0
 public ActionResult AddEditArticle(string id)
 {
     string title = "Создание новости";
     ViewData["isNew"] = string.IsNullOrEmpty(id);
     ViewData["id"] = id;
     if (!string.IsNullOrEmpty(id))
     {
         using (ContentStorage context = new ContentStorage())
         {
             Article article = context.Article.Where(a => a.Name == id).First();
             title = string.Format("Редактирование новости \"{0}\"", article.Title);
             ViewData["title"] = article.Title;
             ViewData["date"] = article.Date.ToString("dd.MM.yyyy");
             ViewData["text"] = article.Text;
             ViewData["description"] = article.Description;
             ViewData["keywords"] = article.Keywords;
         }
     }
     else
     {
         ViewData["date"] = DateTime.Now.ToString("dd.MM.yyyy");
     }
     ViewData["cTitle"] = title;
     return View();
 }
Exemple #7
0
        public ActionResult DeleteArticle(string id)
        {
            using (ContentStorage context = new ContentStorage())
            {
                List<Article> articles = context.Article.Where(a => a.Name == id).ToList();

                foreach (var item in articles)
                {
                    context.DeleteObject(item);
                }
                context.SaveChanges();
            }
            return RedirectToAction("Index", "News");
        }
Exemple #8
0
        public ActionResult AddEditArticle(string id,
            string title,
            string date,
            string keywords,
            string description,
            string text,
            bool isNew)
        {
            using (ContentStorage context = new ContentStorage())
            {
                Article article;
                if (isNew)
                {
                    article = new Article {Name = id};
                    context.AddToArticle(article);
                }
                else
                {
                    article = context.Article.Where(a => a.Name == id).First();
                }

                article.Title = title;
                article.Date = DateTime.Parse(date);
                article.Text = HttpUtility.HtmlDecode(text);
                article.Description = description;
                article.Keywords = keywords;
                context.SaveChanges();
            }
            return RedirectToAction("Index", "News");
        }