public ActionResult Forums(ForumViewModel newForum) { if (!ModelState.IsValid) return View(); try { MvcForumsEntities entities; using (entities = new MvcForumsEntities()) { Forum forum = new Forum() { description = newForum.Description, name = newForum.Name }; entities.AddToForum(forum); entities.SaveChanges(); } } catch (Exception e) { } return View(); }
/// <summary> /// Create a new Forum object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="name">Initial value of the name property.</param> /// <param name="description">Initial value of the description property.</param> public static Forum CreateForum(global::System.Int32 id, global::System.String name, global::System.String description) { Forum forum = new Forum(); forum.id = id; forum.name = name; forum.description = description; return forum; }
/// <summary> /// Deprecated Method for adding a new object to the Forum EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToForum(Forum forum) { base.AddObject("Forum", forum); }