Ejemplo n.º 1
0
 public void CreateBook(BookModels book)
 {
     try
     {
         int maxId = booksList.Count == 0 ? 0 : booksList.Select(item => item.Id).Max();
         book.Id = maxId + 1;
         booksList.Add(book);
     }
     catch (Exception)
     { }
 }
Ejemplo n.º 2
0
 public void UpdateBook(BookModels book)
 {
     try
     {
         //foreach (BookModels bm in booksList)
         //{
         //    if (bm.Id == bookModel.Id)
         //    {
         //        booksList.Remove(bm);
         //        booksList.Add(bookModel);
         //        break;
         //    }
         //}
         BookModels bm = booksList.Find(item => item.Id == book.Id);
         bm.Name       = book.Name;
         bm.Publishing = book.Publishing;
         bm.Author     = book.Author;
         bm.Edition    = book.Edition;
     }
     catch (Exception)
     {
     }
 }