Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("PublisherID,Name,StreetAddress,City,State,Zip")] Publisher publisher)
        {
            if (id != publisher.PublisherID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(publisher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PublisherExists(publisher.PublisherID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(publisher));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("BookID,ISBN,Title,NumberOfPages,PublicationYear,CategoryID,PublisherID,AuthorID")] 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)));
            }
            ViewData["AuthorID"]    = new SelectList(_context.Author, "AuthorID", "AuthorID", book.AuthorID);
            ViewData["CategoryID"]  = new SelectList(_context.Category, "CategoryID", "CategoryID", book.CategoryID);
            ViewData["PublisherID"] = new SelectList(_context.Publisher, "PublisherID", "PublisherID", book.PublisherID);
            return(View(book));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("AuthorID,FirstName,LastName,DateOfBirth")] Author author)
        {
            if (id != author.AuthorID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(author);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AuthorExists(author.AuthorID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(author));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoryID,CategoryName")] Category category)
        {
            if (id != category.CategoryID)
            {
                return(NotFound());
            }

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