public ActionResult CreateSection(ContentSection contentSection)
 {
     try
     {
         db.ContentSections.Attach(contentSection);
         db.ObjectStateManager.ChangeObjectState(contentSection, EntityState.Added);
         db.SaveChanges();
         ViewData.Model = db.ContentSections.OrderBy(s => s.Header).ToList();
         return View("ContentMaintenance");
     }
     catch
     {
         ViewBag.Error = "<span class='field-validation-error'> An error occured while processing this submission. Please try again.</span>";
         ViewBag.ContentTypeId = new SelectList(db.ContentTypes, "Id", "Description");
         return View("");
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new ContentSection object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="header">Initial value of the Header property.</param>
 /// <param name="uRL">Initial value of the URL property.</param>
 /// <param name="creationDate">Initial value of the CreationDate property.</param>
 /// <param name="contentTypeId">Initial value of the ContentTypeId property.</param>
 public static ContentSection CreateContentSection(global::System.Int32 id, global::System.String header, global::System.String uRL, global::System.String creationDate, global::System.Int32 contentTypeId)
 {
     ContentSection contentSection = new ContentSection();
     contentSection.Id = id;
     contentSection.Header = header;
     contentSection.URL = uRL;
     contentSection.CreationDate = creationDate;
     contentSection.ContentTypeId = contentTypeId;
     return contentSection;
 }
        public ActionResult Edit(ContentSection contentSection)
        {
            if (ModelState.IsValid)
            {
                db.ContentSections.Attach(contentSection);
                db.ObjectStateManager.ChangeObjectState(contentSection, EntityState.Modified);
                db.SaveChanges();

            }
            return RedirectToAction("Index");
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ContentSections EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContentSections(ContentSection contentSection)
 {
     base.AddObject("ContentSections", contentSection);
 }