public HttpResponseMessage GetBooks(HttpRequestMessage request) { var webApiModel = new LibraryApiModel(); var transaction = new TransactionalInformation(); var libraryBusinessService = new LibraryBusinessService(libraryDataService); var books = libraryBusinessService.GetBooks(out transaction); webApiModel.CopyData(transaction); webApiModel.IsAuthenicated = true; webApiModel.Books = books; return(CreateResponse(webApiModel, transaction)); }
private HttpResponseMessage CreateResponse(LibraryApiModel webApiModel, TransactionalInformation transaction) { if (transaction.ReturnStatus == true) { var response = Request.CreateResponse <LibraryApiModel>(HttpStatusCode.OK, webApiModel); return(response); } var badResponse = Request.CreateResponse <LibraryApiModel>(HttpStatusCode.BadRequest, webApiModel); return(badResponse); }
public HttpResponseMessage CreateBook(HttpRequestMessage request, [FromBody] BookDTO bookDTO) { var webApiModel = new LibraryApiModel(); var jsModel = bookDTO.Convert(); var transaction = new TransactionalInformation(); var libraryBusinessService = new LibraryBusinessService(libraryDataService); libraryBusinessService.CreateBook(jsModel, out transaction); webApiModel.CopyData(transaction); webApiModel.IsAuthenicated = true; webApiModel.Book = jsModel; return(CreateResponse(webApiModel, transaction)); }