コード例 #1
0
        public async Task <IActionResult> Put(string id, [FromBody] BookItemEditViewModel model)
        {
            await bookItemService.EditBookItemAsync(id, new BookItemEditModel
            {
                Barcode   = model.Barcode,
                Condition = model.Condition
            });

            return(Ok());
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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));
        }