public async Task <bool> RegisterUser(User user) { _iMDbContext.Users.Add(user); await _iMDbContext.SaveChangesAsync(); return(true); }
public async Task <IActionResult> PutTitlebasics(string id, Titlebasics titlebasics) { if (id != titlebasics.Tconst) { return(BadRequest()); } _context.Entry(titlebasics).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TitlebasicsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <bool> RegisterRate(MovieRate rate) { _iMDbContext.MovieRates.Add(rate); await _iMDbContext.SaveChangesAsync(); return(true); }
public async Task InsertAssets(IEnumerable <AssetEntity> assetEntities) { foreach (var asset in assetEntities) { var currentAsset = imDbContext.Assets.AsQueryable().SingleOrDefault(a => a.AssetId == asset.AssetId); if (currentAsset == null) { logger.LogError($"AssetId can not be found {asset.AssetId}"); } else if (currentAsset.TimeStamp > asset.TimeStamp) { logger.LogWarning($"Asset has smaller timestamp so skipping. AssetID : {asset.AssetId}"); } else { imDbContext.Assets.Remove(currentAsset); imDbContext.Assets.Add(asset); } } await imDbContext.SaveChangesAsync(); }
public async Task <bool> RegisterMovie(Movie movie) { movie.MoviesActors = new List <MoviesActors>(); foreach (var actorID in movie.ActorsIDs) { var actor = _iMDbContext.Actors.First(x => x.ActorID == actorID); if (actor != null) { var link = new MoviesActors() { Actor = actor, Movie = movie }; movie.MoviesActors.Add(link); } } _iMDbContext.Movies.Add(movie); await _iMDbContext.SaveChangesAsync(); return(true); }
public async Task InsertBatch(BatchEntity entity) { dbContext.Batches.Add(entity); await dbContext.SaveChangesAsync(); }
public Task <int> SaveChanges() { return(_db.SaveChangesAsync()); }