Ejemplo n.º 1
0
 public ActionResult Add(FormCollection form)
 {
     sbartoszak_bookwormsEntities ent = new sbartoszak_bookwormsEntities();
     ViewBag.BookGenres = ent.Genres.OrderBy(g => g.Name).ToSelectListItem(1, g => g.IdGenre, g => g.Name, g => g.Name, g => g.IdGenre.ToString());
     Book book = new Book();
     if (TryUpdateModel(book))
     {
         book.AddDate = DateTime.Now;
         ent.Books.AddObject(book);
         ent.SaveChanges();
     }
     return RedirectToAction("Index");
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new Book object.
 /// </summary>
 /// <param name="idBook">Initial value of the IdBook property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="author">Initial value of the Author property.</param>
 /// <param name="idGenre">Initial value of the IdGenre property.</param>
 /// <param name="addDate">Initial value of the AddDate property.</param>
 public static Book CreateBook(global::System.Int32 idBook, global::System.String title, global::System.String author, global::System.Int32 idGenre, global::System.DateTime addDate)
 {
     Book book = new Book();
     book.IdBook = idBook;
     book.Title = title;
     book.Author = author;
     book.IdGenre = idGenre;
     book.AddDate = addDate;
     return book;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Books EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBooks(Book book)
 {
     base.AddObject("Books", book);
 }