// GET: Book/Create public async Task <ActionResult> CreateOrEdit(int id = 0) { Book book = new Book(); if (id != 0) { book = await BookstoreClient.GetBookAsync(id) ?? book; } return(View(book)); }
// GET: Book/Delete/5 public async Task <ActionResult> Delete(int id) { try { bool response = await BookstoreClient.DeleteBookAsync(id); if (response) { return(RedirectToAction(nameof(Index))); } else { return(View()); } } catch { return(View()); } }
public async Task <ActionResult> Create([Bind()] Book book) { try { Book response; if (book.Id == 0) { response = await BookstoreClient.CreateAsync(book); } else { response = await BookstoreClient.UpdateBookAsync(book); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ActionResult> RegisterSell(StockMovement stockMovement) { await BookstoreClient.RegisterSellAsync(stockMovement); return(RedirectToAction(nameof(Index))); }
public async Task <ActionResult> ChangePrice(ItemPrice itemPrice) { await BookstoreClient.ChangePriceAsync(itemPrice); return(RedirectToAction(nameof(Index))); }
// GET: Book public async Task <ActionResult> Index() { var books = await BookstoreClient.GetBooksAsync(); return(View(books)); }
public BookController(IConfiguration config) { BooksEndpoint = config.GetValue <string>("Endpoints:Books"); BookstoreClient = BookstoreClient.Build(BooksEndpoint); }