コード例 #1
0
        public async Task <IActionResult> Create([Bind("ShopId,BookId,StockLevel")] ShopBook shopBook)
        {
            if (ModelState.IsValid)
            {
                await _shopService.AddBookToShop(shopBook);

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["ShopId"] = new SelectList(await _shopService.GetAllShops(), "Id", "Name", shopBook.ShopId);
            ViewData["BookId"] = new SelectList(await _dataService.GetAllBooks(), "Id", "Title", shopBook.BookId);
            return(View(shopBook));
        }