public ActionResult Add(FormCollection form) { sbartoszak_bookwormsEntities ent = new sbartoszak_bookwormsEntities(); Review review = new Review(); if (TryUpdateModel(review)) { review.CreateDate = DateTime.Now; ent.Reviews.AddObject(review); ent.SaveChanges(); } return RedirectToAction("Details", "Book", new { id = review.IdBook }); }
/// <summary> /// Create a new Review object. /// </summary> /// <param name="idReview">Initial value of the IdReview property.</param> /// <param name="idBook">Initial value of the IdBook property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="content">Initial value of the Content property.</param> /// <param name="author">Initial value of the Author property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> public static Review CreateReview(global::System.Int32 idReview, global::System.Int32 idBook, global::System.String title, global::System.String content, global::System.String author, global::System.DateTime createDate) { Review review = new Review(); review.IdReview = idReview; review.IdBook = idBook; review.Title = title; review.Content = content; review.Author = author; review.CreateDate = createDate; return review; }
/// <summary> /// Deprecated Method for adding a new object to the Reviews EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToReviews(Review review) { base.AddObject("Reviews", review); }