public async Task <IActionResult> Put(string id, [FromBody] BookItemEditViewModel model) { await bookItemService.EditBookItemAsync(id, new BookItemEditModel { Barcode = model.Barcode, Condition = model.Condition }); return(Ok()); }
public async Task <IActionResult> Post([FromBody] BookItemEditViewModel model) { var bookItem = new BookItem { BookId = model.BookId, Barcode = model.Barcode, Condition = model.Condition }; await bookItemService.CreateBookItemAsync(bookItem); return(Ok(bookItem.Id)); }
public async Task <IActionResult> Put(string id, [FromBody] BookItemEditViewModel model) { var current = await context.BookItems.SingleOrDefaultAsync(b => b.Id == id); if (current == null) { return(BadRequest()); } context.Entry <BookItem>(current).CurrentValues.SetValues(model); await context.SaveChangesAsync(); return(Ok()); }
public async Task <IActionResult> Post([FromBody] BookItemEditViewModel model) { var bookItem = new BookItem { Id = Guid.NewGuid().ToString(), BookId = model.BookId, Barcode = model.Barcode, Condition = model.Condition, State = "Free" }; context.BookItems.Add(bookItem); await context.SaveChangesAsync(); eventBus.Publish(new BookDataChangedIntegrationEvent { BookId = model.BookId }); return(Ok(bookItem.Id)); }