public async Task <IActionResult> UpdateBook(Books updatedBook) { Books oldBook = await bd.GetBook(updatedBook.Id); oldBook.Title = updatedBook.Title; oldBook.Author = updatedBook.Author; oldBook.PublishDate = updatedBook.PublishDate; oldBook.Pages = updatedBook.Pages; oldBook.Genre = updatedBook.Genre; oldBook.Price = updatedBook.Price; oldBook.Image = updatedBook.Image; oldBook.Description = updatedBook.Description; bd.UpdateBook(oldBook); return(RedirectToAction("Index")); }
public IActionResult Payment(Payment newPayment) { //if this is real, then I would have it go to a credit card processor string userid = User.FindFirstValue(ClaimTypes.NameIdentifier); var list = _context.Cart.Where(x => x.UserId == userid).ToList(); foreach (var c in list) { Books book = bd.GetBook(c.BookId.Value).Result; book.Quantity = book.Quantity - c.Quantity; bd.UpdateBook(book); _context.Cart.Remove(c); _context.SaveChanges(); } return(RedirectToAction("Confirmation")); }