public async Task <IActionResult> Create([Bind("Id,Name")] MsGenre msGenre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(msGenre);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(msGenre));
        }
        public async Task <IActionResult> Create([Bind("Id,GenreId,Title,Author,PublishYear,ISBN")] Book book)
        {
            if (ModelState.IsValid)
            {
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GenreId"] = new SelectList(_context.MsGenres, "Id", "Name", book.GenreId);
            return(View(book));
        }
Esempio n. 3
0
 public Task <int> SaveChangesAsync()
 {
     return(Context.SaveChangesAsync());
 }
Esempio n. 4
0
        public async Task InsertAsync(TEntity entity)
        {
            await Context.Set <TEntity>().AddAsync(entity);

            await Context.SaveChangesAsync();
        }