Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync(Book handler)

        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            _context.Cart.Add(Cart);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Book).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookExists(Book.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 3
0
        public async Task OnGetDeleteAsync(int Id)
        {
            Cart cart = await _context.Cart.FindAsync(Id);

            if (cart != null)
            {
                _context.Cart.Remove(cart);
                await _context.SaveChangesAsync();
            }

            RedirectToPage();
            // code omitted for brevity
        }
Esempio n. 4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Cart = await _context.Cart.FindAsync(id);

            if (Cart != null)
            {
                _context.Cart.Remove(Cart);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            OrderBook = await _context.OrderBook.FindAsync(id);

            if (OrderBook != null)
            {
                _context.OrderBook.Remove(OrderBook);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }