Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("RentalID,UserID,BookID,RentalEndDate,ToPay")] Rental rental)
        {
            if (id != rental.RentalID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rental);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RentalExists(rental.RentalID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookID"] = new SelectList(_context.Books, "BookID", "Author", rental.BookID);

            return(View(rental));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("BookID,Title,Author,Category")] Book book)
        {
            if (id != book.BookID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.BookID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }