public BookShelfDocument Post(BookShelfDocument document) { if (document == null) { throw new ValidationException("request was empty"); } var bookShelf = new BookShelf { Name = document.Name }; repository.Save(bookShelf); return(Mapper.Map <BookShelfDocument>(bookShelf)); }
public BookShelfDocument Update(int id, BookShelfDocument document) { var bookShelf = repository.Get(id); if (bookShelf == null) { throw new ResourceNotFoundException("Book not Found"); } if (document == null) { throw new ValidationException("request was empty"); } bookShelf.Name = document.Name; repository.Update(bookShelf); return(Mapper.Map <BookShelfDocument>(bookShelf)); }
public IHttpContentResult <BookShelfDocument> Put(int bookshelfId, BookShelfDocument document) { return(Request.CreateContentResponse(resource.Update(bookshelfId, document))); }
public IHttpContentResult <BookShelfDocument> Post(BookShelfDocument document) { var result = resource.Post(document); return(Request.CreateNewContentResponse(new Uri($"v1/bookshelves/{result.BookShelfId}"), result)); }