public UpdateItemHighLevelHttpContent(DynamoDbContext context, DdbClassInfo classInfo, BuilderNode?node) : base("DynamoDB_20120810.UpdateItem") { _context = context; _node = node; _classInfo = classInfo; }
public async Task Update(LoginTokenModel loginToken) { using (DynamoDbContext dbContext = new DynamoDbContext()) { await dbContext.SaveAsync <LoginTokenModel>(loginToken); } }
public async Task Add(FacebookAuthModel newUser) { using (DynamoDbContext dbContext = new DynamoDbContext()) { await dbContext.SaveAsync(newUser); } }
public EfficientEntityQueryBenchmark() { _context = new DynamoDbContext(new DynamoDbContextConfig(RegionEndpoint.USEast1, new AwsCredentials("test", "test")) { HttpClientFactory = new DefaultHttpClientFactory(new HttpClient(new MockHttpClientHandler(CreateResponse))) }); }
public AuthModel GetAuthByEmail(string email) { using (DynamoDbContext dbContext = new DynamoDbContext()) { var user = dbContext.Load <AuthModel>(email); return(user); } }
public bool IsEmailFree(string email) { using (DynamoDbContext dbContext = new DynamoDbContext()) { var auth = dbContext.Load <AuthModel>(email); return(auth == null); } }
public void SetUp() { var credentialsOptions = new CredentialsOptions(); var credentialsProvider = new CredentialsProvider(credentialsOptions); var options = new DynamoDbOptions <DynamoDbContextTests>(); _context = new DynamoDbContext <DynamoDbContextTests>(credentialsProvider, options); }
/// <summary> /// Calls the base class because there may be some generic behavior in it /// Get the Generic object /// </summary> /// <typeparam name="T">generic type</typeparam> /// <returns>The generic object</returns> public override async Task <IQueryable <T> > GetAsync <T>() { await base.GetAsync <T>(); var result = await DynamoDbContext.ScanAsync <T>(new List <ScanCondition>()).GetRemainingAsync(); return(result.AsQueryable()); }
public LoginTokenModel GetLoginToken(string token) { using (DynamoDbContext dbContext = new DynamoDbContext()) { var loginToken = dbContext.Load <LoginTokenModel>(token); return(loginToken); } }
public bool IsFacebookIdFree(string facebookId) { using (DynamoDbContext dbContext = new DynamoDbContext()) { var auth = dbContext.Load <FacebookAuthModel>(facebookId); return(auth == null); } }
public FacebookAuthModel GetAuthByFacebookId(string facebookId) { using (DynamoDbContext dbContext = new DynamoDbContext()) { var user = dbContext.Load <FacebookAuthModel>(facebookId); return(user); } }
/// <summary> /// Add or update the document /// Calls the base class because there may be some generic behavior in it /// </summary> /// <typeparam name="T">generic type</typeparam> /// <param name="model">generic model</param> /// <returns>The entity to upserted</returns> public override async Task <T> AddOrUpdateAsync <T>(T model) { await base.AddOrUpdateAsync <T>(model); await DynamoDbContext.SaveAsync(model); return(await Task.FromResult <T>(model)); }
public async Task Delete(string facebookId) { using (DynamoDbContext dbContext = new DynamoDbContext()) { await dbContext.DeleteAsync <FacebookAuthModel>(facebookId).ConfigureAwait(false); //TODO: log } }
public async Task Delete(string userEmail) { using (DynamoDbContext dbContext = new DynamoDbContext()) { await dbContext.DeleteAsync <AuthModel>(userEmail); //TODO: log } }
public async Task <LoginTokenModel> AddLoginToken(LoginTokenModel loginToken) { using (DynamoDbContext dbContext = new DynamoDbContext()) { await dbContext.SaveAsync(loginToken); var savedLoginToken = await dbContext.LoadAsync <LoginTokenModel>(loginToken.Token); return(savedLoginToken); } }
public async Task <ICollection <TDTO> > Get(ResourceRequest <TServiceQuery> request) { var policy = _dynamoDbResourceQuerablePolicy.Convert(request?.Query); var result = await DynamoDbContext.ScanAsync <TDTO>( policy.ScanConditions, policy.OperationConfig ).GetRemainingAsync(); return(result); }
/// <summary> /// Add or update the document /// Calls the base class because there may be some generic behavior in it /// </summary> /// <typeparam name="T">generic type</typeparam> /// <param name="listModels">list generic models</param> /// <returns>The upserted Entity</returns> public override async Task <IEnumerable <T> > AddOrUpdateAsync <T>(List <T> listModels) { await base.AddOrUpdateAsync(listModels); var itemBatch = DynamoDbContext.CreateBatchWrite <T>(); listModels.ToList().ForEach(x => itemBatch.AddPutItem(x)); await itemBatch.ExecuteAsync(); return(listModels); }
public async Task Update(FacebookAuthModel facebookAuth) { try { using (DynamoDbContext dbContext = new DynamoDbContext()) { await dbContext.SaveAsync(facebookAuth); } } catch (Exception e) { throw e; } }
public async Task Update(AuthModel updatedUser) { try { using (DynamoDbContext dbContext = new DynamoDbContext()) { await dbContext.SaveAsync(updatedUser); } } catch (Exception e) { throw e; } }
public async Task Add(AuthModel newUser) { try { using (DynamoDbContext dbContext = new DynamoDbContext()) { await dbContext.SaveAsync(newUser).ConfigureAwait(false); } } catch (Exception e) { throw e; } }
/// <summary> /// Deletes the user associated with the specified id. /// </summary> /// <param name="id"></param> public async Task Delete(string id) { using (DynamoDbContext context = new DynamoDbContext()) { try { await context.DeleteAsync <UserModel>(id); } catch (Exception e) { //ADD LOGER throw new Exception(e.Message); } } }
/// <summary> /// Adds user or update user if the user already exict in the db. /// </summary> /// <param name="user"></param> public async Task AddOrUpdate(UserModel user) { using (DynamoDbContext context = new DynamoDbContext()) { try { await context.SaveAsync(user); } catch (Exception e) { //ADD LOGER throw new Exception(e.Message); } } }
/// <summary> /// Gets a user record from the db. /// </summary> /// <param name="id"></param> /// <returns>User</returns> public async Task <UserModel> Get(string id) { using (DynamoDbContext context = new DynamoDbContext()) { try { return(await context.LoadAsync <UserModel>(id)); } catch (Exception e) { //ADD LOGER throw new Exception(e.Message); } } }
/// <summary> /// Calls the base class because there may be some generic behavior in it /// Counts the quantity of documents /// </summary> /// <typeparam name="T">generic type</typeparam> /// <param name="predicate">lambda expression</param> /// <returns>Quantity of Document</returns> public override async Task <int> CountAsync <T>(Expression <Func <T, bool> > predicate) { await base.CountAsync <T>(predicate); List <ScanCondition> conditions = new List <ScanCondition>(); IEnumerable <ExpressionAnalyzed> expressions = (IEnumerable <ExpressionAnalyzed>)_evaluatePredicate.Evaluate <T>(predicate); expressions.ToList().ForEach(x => { conditions.Add(new ScanCondition(x.PropertyName, this.ConvertEnum(x.OperatorBetweenPropAndValue.ExpressionType), x.PropertyValue)); }); var result = await DynamoDbContext.ScanAsync <T>(conditions).GetRemainingAsync(); return(result.Count); }
/// <summary> /// Gets the full name of the user associated with id specified. /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <string> GetFullName(string id) { using (DynamoDbContext context = new DynamoDbContext()) { try { var userSearched = await context.LoadAsync <UserModel>(id); return(userSearched.FirstName + " " + userSearched.LastName); } catch (Exception e) { //ADD LOGER throw new Exception(e.Message); } } }
public async Task DynamoDbService_Should_List_Records_In_A_DynamoDb_Table() { var tableName = Guid.NewGuid().ToString(); const int recordCount = 5; var dynamoDbOperationConfig = new DynamoDBOperationConfig() { OverrideTableName = tableName }; await CreateTestTable(tableName); Table targetTable = DynamoDbContext.GetTargetTable <MovieEntity>(dynamoDbOperationConfig); IList <MovieEntity> movieEntities = new Fixture().CreateMany <MovieEntity>(recordCount).ToList(); List <Document> documents = movieEntities .Select(entity => { string serialize = JsonSerializer.Serialize(entity); Document item = Document.FromJson(serialize); return(item); }) .ToList(); foreach (Document document in documents) { await targetTable.PutItemAsync(document); } dynamoDbOperationConfig.IndexName = TestConstants.MoiveTableMovieIdGsi; List <MovieEntity> returnedMovieEntities = await DynamoDbContext.ScanAsync <MovieEntity>(new List <ScanCondition>(), dynamoDbOperationConfig).GetRemainingAsync(); Assert.NotNull(movieEntities); Assert.NotEmpty(movieEntities); Assert.Equal(recordCount, movieEntities.Count); Assert.All(returnedMovieEntities, movieEntity => { MovieEntity entity = movieEntities.First(e => e.MovieId == movieEntity.MovieId); Assert.True(movieEntity.DeepEquals(entity)); }); }
public SaveEntityComparisonBenchmark() { var ddbConfig = new AmazonDynamoDBConfig { RegionEndpoint = Amazon.RegionEndpoint.USEast1, HttpClientFactory = new MockHttpClientFactory(CreateResponse) }; var dbClient = new AmazonDynamoDBClient( new BasicAWSCredentials(Environment.GetEnvironmentVariable("DEV_AWS_PUBLIC_KEY"), Environment.GetEnvironmentVariable("DEV_AWS_PRIVATE_KEY")), ddbConfig); var contextConfig = new DynamoDBContextConfig { TableNamePrefix = "production_", Conversion = DynamoDBEntryConversion.V2 }; _awsDbContext = new DynamoDBContext(dbClient, contextConfig); _efficientDbContext = new DynamoDbContext(new DynamoDbContextConfig(RegionEndpoint.USEast1, new AwsCredentials("test", "test")) { HttpClientFactory = new DefaultHttpClientFactory(new HttpClient(new MockHttpClientHandler(CreateResponse))) }); }
public async Task DynamoDbService_Should_Add_A_Record_To_A_DynamoDb_Table() { var tableName = Guid.NewGuid().ToString(); var dynamoDbOperationConfig = new DynamoDBOperationConfig() { OverrideTableName = tableName }; await CreateTestTable(tableName); Table targetTable = DynamoDbContext.GetTargetTable <MovieEntity>(dynamoDbOperationConfig); var movieEntity = new Fixture().Create <MovieEntity>(); string modelJson = JsonSerializer.Serialize(movieEntity); Document item = Document.FromJson(modelJson); await targetTable.PutItemAsync(item); dynamoDbOperationConfig.IndexName = TestConstants.MoiveTableMovieIdGsi; List <MovieEntity> movieEntities = await DynamoDbContext.QueryAsync <MovieEntity>(movieEntity.MovieId, dynamoDbOperationConfig).GetRemainingAsync(); Assert.True(movieEntity.DeepEquals(movieEntities.First())); }
internal UpdateDocumentRequestBuilder(DynamoDbContext context, BuilderNode?node) { _context = context; _node = node; }
public UpdateDocumentRequestBuilder(DynamoDbContext context) { _context = context; }