public IActionResult Post([FromBody] Book book) { if (book == null) { return(BadRequest()); } var createdBooks = _bookRepository.AddBooks(book); return(CreatedAtRoute("GetBooks", new { id = createdBooks.Id }, createdBooks)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await _booksRepo.AddBooks(Book); Message = "Dodano pomyślnie"; return(RedirectToPage("Index")); }
public void ExecuteCommandOrExit(string command) { switch (command.ToUpper()) { case "1": _bookRepository.AddBooks(); break; case "2": _bookRepository.DeleteBooks(_clientRepository); break; case "3": ShowListOfBooks(SearchBy.ByName); break; case "4": ShowListOfBooks(SearchBy.ByTime); break; case "5": _bookRepository.BorrowBook(_clientRepository); break; case "6": ShowClientsList(); break; case "7": ShowAllBooks(); break; case "Q": exit = true; break; default: Console.WriteLine("Wrong Command!"); break; } Console.WriteLine("Powrot"); Console.ReadLine(); }
protected LibraryDTO GetBooksFromLibraryExpress(IUrlHttpClient urlHttpClient, IBookRepository bookRepository, BookFilter bookFilter) { try { var libraryRequest = GenerateLibraryBookRequest(bookFilter); //Go fetch from external service ExpressLibraryApi var libraryResponse = urlHttpClient.HttpGet(libraryRequest).Result; var libraryDto = ProcessExternalLibraryResponse(libraryResponse); if (libraryDto != null && libraryDto.Books != null && libraryDto.Books.Count > 0) { try { var newLibraryDto = new LibraryDTO(); var ourbooks = bookRepository.AddBooks(libraryDto.Books); newLibraryDto.Books = ourbooks; newLibraryDto.TotalBooks = ourbooks.Count; return(newLibraryDto); } catch (Exception ex) { //TODO: Log this the exception information along with the method details to the database for Error tracing //Allowing the exception be rethrown so that LOG4NET can log there is a problem on the api end point return(null); } } return(libraryDto); } catch (Exception ex) { //TODO: Log this the exception information along with the method details to the database for Error tracing //Allowing the exception be rethrown so that LOG4NET can log there is a problem on the api end point return(null); } }
/// <summary> /// Adds the books detail. /// </summary> /// <param name="bookStoreModel">The book store model.</param> /// <returns></returns> public int AddBooks(BookStoreModel bookStoreModel) { return(bookRepository.AddBooks(bookStoreModel)); }