public async Task <IActionResult> Edit(int id, [Bind("BookId,Author,Title,Year,ISBN")] 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)); }
public async Task <IActionResult> Edit(string id, [Bind("ISBN,Title,Language,Pages,AuthorId")] Book book) { if (id != book.ISBN) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(book); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(book.ISBN)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AuthorId"] = new SelectList(_context.Author, "Id", "Name", book.AuthorId); return(View(book)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Total,Details,DateCreated,DateModified,CustomerId")] Order order) { if (id != order.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(order); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(order.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "Id", order.CustomerId); return(View(order)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Author author) { if (id != author.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(author); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthorExists(author.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(author)); }
public async Task <IActionResult> Edit(int id, [Bind("UserId,Nick,Password,Email,City,Street,HouseNumber,PostalCode,CreateDate")] User user) { if (id != user.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,name,brand,model")] Printer printer) { if (id != printer.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(printer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrinterExists(printer.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(printer)); }
public async Task <IActionResult> EditPost(int?id, BookViewModel vm) { if (id != vm.BooksID) { return(NotFound()); } if (ModelState.IsValid) { try { string uniqueFileName = UploadedFile(vm); Book book = new Book { BooksID = vm.BooksID, Title = vm.Title, OriginalTitle = vm.OriginalTitle, Genre = vm.Genre, Synopsis = vm.Synopsis, NumberofPages = vm.NumberofPages, Picture = uniqueFileName, Price = vm.Price, ReleaseDate = vm.ReleaseDate, Publisher = vm.Publisher, Movie = vm.Movie, Author = vm.Author, Authorid = vm.Authorid }; _context.Update(book); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(vm.BooksID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vm)); }
public async Task <IActionResult> EditPost(int?id, MovieViewModel vm) { if (id != vm.MovieID) { return(NotFound()); } if (ModelState.IsValid) { try { string uniqueFileName = UploadedFile(vm); Movie movie = new Movie { MovieID = vm.MovieID, Title = vm.Title, Synopsis = vm.Synopsis, BookId = vm.BookId, Picture = uniqueFileName, ReleaseDate = vm.ReleaseDate, Trailer = vm.Trailer, Rating = vm.Rating, Book = vm.Book }; _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(vm.MovieID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vm)); }
public async Task <IActionResult> EditPost(int?id, AuthorViewModel vm) { if (id != vm.AuthorID) { return(NotFound()); } if (ModelState.IsValid) { try { string uniqueFileName = UploadedFile(vm); Author author = new Author { AuthorID = vm.AuthorID, FirstName = vm.FirstName, LastName = vm.LastName, DateofBirth = vm.DateofBirth, DateofDeath = vm.DateofBirth, Biography = vm.Biography, Picture = uniqueFileName, Rewards = vm.Rewards, Book = vm.Book }; _context.Update(author); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthorExists(vm.AuthorID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vm)); }
public async Task <IActionResult> Edit(int id, [Bind("BookID,Category,BookTitle,BookAuthor,BookPrice,BookDescription,Bestseller,Publisher,ReleaseDate,Pages")] Book book) { if (id != book.BookID) { Response.StatusCode = 404; return(View("errorWrongId")); } /*bool NotUniqueTitle = db.Books.Any(x => x.BookTitle == book.BookTitle && x.BookID != id); * * if (NotUniqueTitle) * { * ModelState.AddModelError("Title", "Książka o tym tytule już istnieje"); * }*/ if (ModelState.IsValid) { try { db.Update(book); await db.SaveChangesAsync(); TempData["Message"] = "Informację dotyczące książki " + book.BookTitle + " zostały zmienione"; var title = book.BookTitle; var author = book.BookAuthor; HttpContext.Session.SetString("Session_1", "Niedawno zmodyfiowano informacje o książce: " + title + ", której autorem jest " + author); } catch (DbUpdateConcurrencyException) { if (!BookExists(book.BookID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(book)); }
public IActionResult UpdateQuantity(int cartId, int quantity) { // string cartJson = HttpContext.Session.GetString("CartList"); Cart item = _context.Cart.Find(cartId); if (quantity == 0) { _context.Cart.Remove(item); _context.SaveChanges(); } if (item != null && quantity >= 1) { item.Quantity = quantity; _context.Entry(item).State = EntityState.Modified; _context.Update(item); _context.SaveChanges(); } return(RedirectToAction("Cart", item)); }
public void Update(Publisher publisher) { _db.Update(publisher); }
public void Update(Genere genere) { _db.Update(genere); }
public void Update(Author author) { _db.Update(author); }
public void Update(Book book) { _db.Update(book); }