public ActionResult Create(Content content) { ViewBag.exMsg = ""; try { if (!ModelState.IsValid) return View(); // we need to gen the primary key content.ContentId = Guid.NewGuid(); // Add and Save var _db = new DataEntities(); _db.Contents.AddObject(content); _db.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { ViewBag.exMsg = ex.Message; return View(); } }
/// <summary> /// Create a new Content object. /// </summary> /// <param name="contentId">Initial value of the ContentId property.</param> /// <param name="isDefault">Initial value of the IsDefault property.</param> public static Content CreateContent(global::System.Guid contentId, global::System.Boolean isDefault) { Content content = new Content(); content.ContentId = contentId; content.IsDefault = isDefault; return content; }
/// <summary> /// Deprecated Method for adding a new object to the Contents EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToContents(Content content) { base.AddObject("Contents", content); }