Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email")] Reader reader)
        {
            if (id != reader.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reader);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReaderExists(reader.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reader));
        }
        public async Task <IActionResult> Create([Bind("Id,BookTitle,Price,ImageUrl,BookImage")] Book book)
        {
            if (ModelState.IsValid)
            {
                SaveBookPicture(book);
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var bookSalesRecord = await _context.BookSalesRecord.FindAsync(id);

            _context.BookSalesRecord.Remove(bookSalesRecord);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }