コード例 #1
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("./IndexBooks"));
        }
コード例 #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            return(RedirectToPage("./IndexGenres"));
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            return(RedirectToPage("../FavBooks/Index"));
        }
コード例 #4
0
        public async Task <IActionResult> OnGetAsync(int?bookId)
        {
            if (bookId == null)
            {
                return(NotFound());
            }

            var userId = _userManager.GetUserId(HttpContext.User);

            var Book = _context.FavBook.FindAsync(bookId, userId); // pobieranie ksiazki, ktora chcesz usunac (z favBooks)

            _context.Remove(Book);
            await _context.SaveChangesAsync();

            return(RedirectToPage("Index"));
        }
コード例 #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./IndexBooks"));
        }
コード例 #6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

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