public Book Put(int id, Book book) { book.Id = id; return BookService.SaveBook(book); }
public Book AddBook(Book aBook) { using (var tran = Repository.BeginTran()) { var entity = Repository.Create(_simpleMapper.Map<Book, Data.Entities.Book>(aBook)); aBook.Id = entity.Id; tran.Commit(); } return aBook; }
public Book Post(Book book) { return BookService.AddBook(book); }
public Book SaveBook(Book aBook) { using (var tran = Repository.BeginTran()) { var entity = Repository.Get().OfType<Data.Entities.Book>().Single(x => x.Id == aBook.Id); if (aBook.Author != null) { entity.AuthorId = aBook.Author.Id; entity.Author = Repository.Get().OfType<Data.Entities.Person>().Single(x => x.Id == aBook.Author.Id); } entity.Copyright = aBook.Copyright; entity.Description = aBook.Description; entity.Name = aBook.Name; entity.Published = DateTime.Parse(aBook.Published); entity = (Data.Entities.Book)Repository.Save(entity); tran.Commit(); } return aBook; }