public async void Create(CollectiveEF collectiveEF) { using (IDynamoDBContext context = _dbConnection.Context()) { await context.SaveAsync(collectiveEF); } }
public int GetUserCount(string userCountId) { using (var context = _dbConnection.Context()) { AppTotalUsers userCount = context.LoadAsync <AppTotalUsers>(userCountId).Result; return(userCount.UserRecordCount); } }
public async Task <int> CreateReward(Reward reward) { using (var context = _dbConnection.Context()) { try { var rewardExists = await context.LoadAsync <Reward>(reward.Id); if (rewardExists != null) { // Error - Reward already exists return(-10); } else { await context.SaveAsync(reward); return(1); } } catch (AmazonServiceException ase) { Debug.WriteLine("Could not complete operation"); Debug.WriteLine("Error Message: " + ase.Message); Debug.WriteLine("HTTP Status: " + ase.StatusCode); Debug.WriteLine("AWS Error Code: " + ase.ErrorCode); Debug.WriteLine("Error Type: " + ase.ErrorType); Debug.WriteLine("Request ID: " + ase.RequestId); return(-1); } catch (AmazonClientException ace) { Debug.WriteLine("Internal error occurred communicating with DynamoDB"); Debug.WriteLine("Error Message: " + ace.Message); return(-1); } catch (NullReferenceException e) { Debug.WriteLine("Context obj for DynamoDB set to null"); Debug.WriteLine("Error Message: " + e.Message); Debug.WriteLine("Inner Exception: " + e.InnerException); return(-1); } catch (Exception e) { Debug.WriteLine("Internal error occurred communicating with DynamoDB"); Debug.WriteLine("Error Message: " + e.Message); Debug.WriteLine("Inner Exception: " + e.InnerException); return(-1); } } }