Пример #1
0
 public ActionResult Edit([Bind(Include = "GenreId,GenreName")] Genre genre)
 {
     if (ModelState.IsValid)
     {
         db.Entry(genre).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(genre));
 }
Пример #2
0
 public ActionResult Edit([Bind(Include = "AuthorId,FirstName,LastName")] Author author)
 {
     if (ModelState.IsValid)
     {
         db.Entry(author).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }
Пример #3
0
 public ActionResult Edit([Bind(Include = "BookId,Title,ReleaseDate,Description,GenreId")] Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "GenreName", book.GenreId);
     return(View(book));
 }
Пример #4
0
        public async Task <IActionResult> PutBook(long id, Book item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }