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