// // GET: /Content/ public ActionResult Index(string id) { string contentId = id; using (var context = new ContentStorage()) { ViewData["contentId"] = contentId; var content = context.Content.Include("Parent").Include("Children").Include("Galleries").Where(c => c.ContentId == contentId).FirstOrDefault(); if (content != null) { ViewData["contentLevel"] = content.ContentLevel; if (content.Parent != null) { ViewData["parentContentId"] = content.Parent.ContentId; ViewData["parentId"] = content.Parent.Id; var pcontent = context.Content.Include("Parent").Where(c => c.ContentId == content.Parent.ContentId).FirstOrDefault(); if (pcontent.Parent != null) { ViewData["parentParentContentId"] = pcontent.Parent.ContentId; ViewData["parentId"] = pcontent.Parent.Id; } } else { ViewData["parentId"] = content.Id; } } return View("Content", content); } }
public ActionResult EditWidgetItem(int widgetType, int id) { using (var context = new ContentStorage()) { var widgetItem = context.Widgets.Select(w => w).Where(w => w.Id == id).FirstOrDefault(); return View(widgetItem); } }
// // GET: /News/ public ActionResult Index() { using (var context = new ContentStorage()) { var newsList = context.Article.Select(c => c).ToList(); return View(newsList); } }
// // GET: /Widget/ public ActionResult Index(int type) { using (var context = new ContentStorage()) { ViewData["type"] = type; var widgetList = context.Widgets.Select(w => w).Where(w => w.Type == type).ToList(); return View(widgetList); } }
// // GET: /Galleries/ public ActionResult Index(int id, string contentId) { using (var context = new ContentStorage()) { ViewData["contentId"] = contentId; ViewData["galleryId"] = id; var gallery = context.Gallery.Include("Content").Include("GalleryItems").Where(g => g.Id == id).Select(g => g).FirstOrDefault(); return View(gallery); } }
public ActionResult UpdateWidgetItem(int widgetType, int id, string title, string url) { using (var context = new ContentStorage()) { var widgetItem = context.Widgets.Select(w => w).Where(w => w.Id == id).FirstOrDefault(); widgetItem.Title = title; widgetItem.Url = url; context.SaveChanges(); } return Redirect("~/Widgets/" + widgetType); }
public ActionResult DeleteWidgetItem(int widgetType,int id) { using (var context = new ContentStorage()) { var widgetItem = context.Widgets.Select(w => w).Where(w => w.Id == id).FirstOrDefault(); if (widgetItem != null) { context.DeleteObject(widgetItem); context.SaveChanges(); } } return Redirect("~/Widgets/" + widgetType); }
public ActionResult AddWidgetItem(int widgetType, string title, string url) { ViewData["type"] = widgetType; string file = Request.Files["image"].FileName; if (!string.IsNullOrEmpty(file)) { string newFileName = IOHelper.GetUniqueFileName("~/Content/WidgetImages", file); string filePath = Path.Combine(Server.MapPath("~/Content/WidgetImages"), newFileName); Request.Files["image"].SaveAs(filePath); using (var context = new ContentStorage()) { var widgetItem = new Widgets { Type = widgetType, ImageSource = newFileName, Title = title, Url = url }; context.AddToWidgets(widgetItem); context.SaveChanges(); } } return RedirectToAction("Index", "Content"); }
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(); }
public ActionResult AddGallery(int parentId, string contentId,string galleryName) { using (var context = new ContentStorage()) { var galleryItem = new Gallery(); galleryItem.ContentReference.EntityKey = new EntityKey("ContentStorage.Content", "Id", parentId); galleryItem.Title = galleryName; galleryItem.ImageSource = ""; context.AddToGallery(galleryItem); context.SaveChanges(); } return RedirectToAction("Index", "Content", new { id = contentId }); }
public ActionResult AddGalleryItem(int parentId, string contentId, int galleryId) { string file = Request.Files["image"].FileName; if (!string.IsNullOrEmpty(file)) { string newFileName = IOHelper.GetUniqueFileName("~/Content/GalleryImages", file); string filePath = Path.Combine(Server.MapPath("~/Content/GalleryImages"), newFileName); string filePathTmp = Path.Combine(Server.MapPath("~/Content/GalleryImages/tmp"), newFileName); Request.Files["image"].SaveAs(filePathTmp); string imgWatermarkPath = Server.MapPath("~/Content/img/watermark.png"); Bitmap imgWatermark = new Bitmap(imgWatermarkPath); Image imgPhoto = Image.FromFile(filePathTmp); DrawWatermark(imgPhoto, imgWatermark, WatermarkPosition.BottomMiddle, Color.FromArgb(0, 255, 0), 0.7f); imgPhoto.Save(filePath, ImageFormat.Jpeg); imgPhoto.Dispose(); imgWatermark.Dispose(); System.IO.File.Delete(filePathTmp); using (var context = new ContentStorage()) { var galleryItem = new GalleryItems(); galleryItem.GalleryReference.EntityKey = new EntityKey("ContentStorage.Gallery", "Id", parentId); galleryItem.ImageSource = newFileName; context.AddToGalleryItems(galleryItem); context.SaveChanges(); } } //return RedirectToAction("Index", "Content", new { id = contentId }); return Redirect("~/Galleries/" + galleryId); /*return RedirectToAction("Index", "Galleries", new { id = contentId });*/ }
public ActionResult DeleteGallery(int id, string contentId) { using (var context = new ContentStorage()) { Gallery gallery = context.Gallery.Include("GalleryItems").Select(g => g).Where(g => g.Id == id).FirstOrDefault(); if (gallery.GalleryItems.Count == 0) { context.DeleteObject(gallery); context.SaveChanges(); } return RedirectToAction("Index", "Content", new { id = contentId }); } }
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(); 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"); }
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"); }
public ActionResult DeleteGalleryItem(int id, string contentId, int galleryId) { using (var context = new ContentStorage()) { GalleryItems galleryItem = context.GalleryItems.Select(g => g).Where(g => g.Id == id).FirstOrDefault(); context.DeleteObject(galleryItem); context.SaveChanges(); //return RedirectToAction("Index", "Content", new { id = contentId }); return Redirect("~/Galleries/" + galleryId); } }
public ActionResult DeleteContentItem(int id) { using (var context = new ContentStorage()) { Content content = context.Content.Include("Children").Where(c => c.Id == id).FirstOrDefault(); string contentId = content.ContentId; if (content.Children.Count == 0) { context.DeleteObject(content); context.SaveChanges(); } return RedirectToAction("Index", "Content", new { id = "About" }); } }
public ActionResult UpdateContent(int id, bool isGalleryItem, int? parentId, string contentId, string title, string description, string keywords, string text, bool? horisontal, int sortOrder, int contentLevel) { 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.ContentLevel = contentLevel; content.IsGalleryItem = isGalleryItem; content.SortOrder = sortOrder; if (content.Id == 0) context.AddToContent(content); context.SaveChanges(); return RedirectToAction("Index", "Content", new { id = contentId }); } }
public ActionResult EditContentItem(int id, int? parentId, bool? horisontal, bool isGalleryItem, int contentLevel) { ViewData["parentId"] = parentId; ViewData["horisontal"] = horisontal; ViewData["isGalleryItem"] = isGalleryItem; ViewData["contentLevel"] = contentLevel; using (var context = new ContentStorage()) { var contentItem = context.Content.Where(c => c.Id == id).Select(c => c).FirstOrDefault(); return View(contentItem); } }
public ActionResult SetDefaultImage(int id, string contentId, int galleryId) { using (var context = new ContentStorage()) { GalleryItems galleryItem = context.GalleryItems.Select(g => g).Where(g => g.Id == id).FirstOrDefault(); Gallery gallery = context.Gallery.Select(g => g).Where(g => g.Id == galleryId).FirstOrDefault(); gallery.ImageSource = galleryItem.ImageSource; context.SaveChanges(); } return RedirectToAction("Index", "Content", new { id = contentId }); }