public ActionResult Home(FormCollection form, Topic ts) { var title = form["Title"]; //var content = form["Content"]; ts = db.Topic.Add(new Topic()); ts.Title = title; ts.CreaterId = 1; ts.Content = "kkkkkkkkkk"; ts.CourseId = 1; ts.ReplyCount = 15; ts.CreateTime = DateTime.Now; ts.ReplyTime = DateTime.Now; db.SaveChanges(); //try //{ // result += db.SaveChanges(); //} //catch(Exception ex) //{ // throw; //} return Content("ok"); }
/// <summary> /// Deprecated Method for adding a new object to the Topics EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTopics(Topic topic) { base.AddObject("Topics", topic); }
/// <summary> /// Create a new Topic object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="nom">Initial value of the Nom property.</param> /// <param name="dateCreation">Initial value of the DateCreation property.</param> /// <param name="createurId">Initial value of the CreateurId property.</param> /// <param name="contenu">Initial value of the Contenu property.</param> /// <param name="categorieId">Initial value of the CategorieId property.</param> public static Topic CreateTopic(global::System.Int32 id, global::System.String nom, global::System.DateTime dateCreation, global::System.Int32 createurId, global::System.String contenu, global::System.Int32 categorieId) { Topic topic = new Topic(); topic.Id = id; topic.Nom = nom; topic.DateCreation = dateCreation; topic.CreateurId = createurId; topic.Contenu = contenu; topic.CategorieId = categorieId; return topic; }