Пример #1
0
        public async void CreateMovie(MovieViewModel movieModel)
        {
            var movie = MapMovie(movieModel);

            await _context.AddAsync(movie);

            await _context.SaveChangesAsync();
        }
Пример #2
0
        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));
        }
Пример #3
0
        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");
            }
        }
Пример #4
0
 public Task <EntityEntry <T> > AddAsync <T>(T entity)
     where T : class
 {
     return(_movieContext.AddAsync(entity));
 }