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) { } }
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) { } }