Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SupplierId,BookId,Price,Deldelay")] SupplierSupplyBook supplierSupplyBook)
        {
            if (id != supplierSupplyBook.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplierSupplyBook);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupplierSupplyBookExists(supplierSupplyBook.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]     = new SelectList(_context.Books, "Id", "Author", supplierSupplyBook.BookId);
            ViewData["SupplierId"] = new SelectList(_context.Suppliers, "Id", "Id", supplierSupplyBook.SupplierId);
            return(View(supplierSupplyBook));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,SupplierId,BookId,Price,Deldelay")] SupplierSupplyBook supplierSupplyBook)
        {
            if (ModelState.IsValid)
            {
                _context.Add(supplierSupplyBook);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]     = new SelectList(_context.Books, "Id", "Author", supplierSupplyBook.BookId);
            ViewData["SupplierId"] = new SelectList(_context.Suppliers, "Id", "Id", supplierSupplyBook.SupplierId);
            return(View(supplierSupplyBook));
        }