Exemplo n.º 1
0
 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" });
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new ContentItem object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="contentType">Initial value of the ContentType property.</param>
 /// <param name="sortOrder">Initial value of the SortOrder property.</param>
 public static ContentItem CreateContentItem(global::System.Int32 id, global::System.Int32 contentType, global::System.Int32 sortOrder)
 {
     ContentItem contentItem = new ContentItem();
     contentItem.Id = id;
     contentItem.ContentType = contentType;
     contentItem.SortOrder = sortOrder;
     return contentItem;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ContentItem EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContentItem(ContentItem contentItem)
 {
     base.AddObject("ContentItem", contentItem);
 }
Exemplo n.º 4
0
        public ActionResult AddImagesBlock(FormCollection form)
        {
            using (var context = new SiteContainer())
            {
                var contentItem = new ContentItem
                {
                    ContentType = 2
                };

                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.AddToContentItem(contentItem);
                context.SaveChanges();

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