public async void CreateMovie(MovieViewModel movieModel) { var movie = MapMovie(movieModel); await _context.AddAsync(movie); await _context.SaveChangesAsync(); }
public async Task <IActionResult> Create([Bind("GenreId,Name,Description,RowVersion")] Genre genre) { if (ModelState.IsValid) { await _context.AddAsync(genre); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(genre)); }
public async Task <bool> AddAsync(TEntity entity) { try { if (entity == null) { throw new Exception("Could not add empty object to database"); } await _movieContext.AddAsync(entity); int result = await _movieContext.SaveChangesAsync(); return((result > 0)?true:false); } catch (System.Exception) { throw new Exception("Could not save objects to database"); } }
public Task <EntityEntry <T> > AddAsync <T>(T entity) where T : class { return(_movieContext.AddAsync(entity)); }