Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public IHttpContentResult <BookShelfDocument> Put(int bookshelfId, BookShelfDocument document)
 {
     return(Request.CreateContentResponse(resource.Update(bookshelfId, document)));
 }
Ejemplo n.º 4
0
        public IHttpContentResult <BookShelfDocument> Post(BookShelfDocument document)
        {
            var result = resource.Post(document);

            return(Request.CreateNewContentResponse(new Uri($"v1/bookshelves/{result.BookShelfId}"), result));
        }