public BookModel Add(BookModel instance)
 {
     if (instance.Id == 0)
       {
     instance.Id =  Books.Any() ? Books.Keys.Max() + 1 : 1;
       }
       Books[instance.Id] = instance;
       return instance;
 }
 public ActionResult EditBook(BookModel book)
 {
     BookModel persistedBook;
       if (book.Id == 0)
       {
     persistedBook = BookRepository.Add(book);
       }
       else
       {
     persistedBook = BookRepository.Update(book);
       }
       return new JsonResult
     {
       JsonRequestBehavior = JsonRequestBehavior.AllowGet,
       Data = new {id = persistedBook.Id, error = string.Empty}
     };
 }
Esempio n. 3
0
 public static Book ConvertToDB(BookModel bookMod)
 {
     throw new NotImplementedException();
 }
 public BookModel Update(BookModel instance)
 {
     Books[instance.Id] = instance;
       return instance;
 }