Ejemplo n.º 1
0
 public async Task Add(FacebookAuthModel newUser)
 {
     using (DynamoDbContext dbContext = new DynamoDbContext())
     {
         await dbContext.SaveAsync(newUser);
     }
 }
 public async Task Update(LoginTokenModel loginToken)
 {
     using (DynamoDbContext dbContext = new DynamoDbContext())
     {
         await dbContext.SaveAsync <LoginTokenModel>(loginToken);
     }
 }
Ejemplo n.º 3
0
        /// <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 <LoginTokenModel> AddLoginToken(LoginTokenModel loginToken)
        {
            using (DynamoDbContext dbContext = new DynamoDbContext())
            {
                await dbContext.SaveAsync(loginToken);

                var savedLoginToken = await dbContext.LoadAsync <LoginTokenModel>(loginToken.Token);

                return(savedLoginToken);
            }
        }
Ejemplo n.º 5
0
 public async Task Update(FacebookAuthModel facebookAuth)
 {
     try
     {
         using (DynamoDbContext dbContext = new DynamoDbContext())
         {
             await dbContext.SaveAsync(facebookAuth);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 6
0
 public async Task Update(AuthModel updatedUser)
 {
     try
     {
         using (DynamoDbContext dbContext = new DynamoDbContext())
         {
             await dbContext.SaveAsync(updatedUser);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 7
0
 public async Task Add(AuthModel newUser)
 {
     try
     {
         using (DynamoDbContext dbContext = new DynamoDbContext())
         {
             await dbContext.SaveAsync(newUser).ConfigureAwait(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 8
0
 /// <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);
         }
     }
 }
Ejemplo n.º 9
0
 public async Task EfficientDynamoDbBenchmark()
 {
     await _efficientDbContext.SaveAsync(EntitiesFactory.CreateMixedEntity(0)).ConfigureAwait(false);
 }
Ejemplo n.º 10
0
 private async Task SetupTestData(Application entity)
 {
     await DynamoDbContext.SaveAsync(entity.ToDatabase()).ConfigureAwait(false);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Saves the supplied entity to the configured DynamoDb instance.
        /// Also amtains a reference to the save entity and will remove it from the database automatically when disposed.
        /// </summary>
        /// <typeparam name="T">The entity type</typeparam>
        /// <param name="entity">The entity instance</param>
        /// <returns>Task</returns>
        public async Task SaveEntityAsync <T>(T entity) where T : class
        {
            await DynamoDbContext.SaveAsync <T>(entity).ConfigureAwait(false);

            _cleanup.Add(async() => await DynamoDbContext.DeleteAsync(entity).ConfigureAwait(false));
        }
Ejemplo n.º 12
0
 private void InsertDatatoDynamoDB(DatabaseEntity entity)
 {
     DynamoDbContext.SaveAsync <DatabaseEntity>(entity).GetAwaiter().GetResult();
     CleanupActions.Add(async() => await DynamoDbContext.DeleteAsync(entity).ConfigureAwait(false));
 }