public DataInfo Get(DataInfo item) { AmazonDynamoDBClient client = DynamoUtilities.InitializeClient(); using (client) { ScanRequest request = CreateScanRequest(item.DataId); if (request.ScanFilter.Count == 0) { throw new InvalidOperationException(ErrorMessages.NoSearchCriteria); } ScanResponse response = client.Scan(request); if (response.Items == null) { string errorMessage = string.Format(ErrorMessages.MisingResponseItem, "Get Data Info"); throw new MissingFieldException(errorMessage); } Dictionary <string, AttributeValue> userData = response.Items[0]; var returnValue = DynamoUtilities.GetItemFromAttributeStore <DataInfo>(userData); return(returnValue); } }
public IEnumerable <Organization> GetAll() { List <Organization> returnValue = new List <Organization>(); AmazonDynamoDBClient client = DynamoUtilities.InitializeClient(); using (client) { ScanRequest request = CreateScanRequest(); ScanResponse response = client.Scan(request); if (response.Items == null || response.Items.Any() == false) { string errorMessage = string.Format(ErrorMessages.MisingResponseItem, "Get Organization"); throw new MissingFieldException(errorMessage); } foreach (Dictionary <string, AttributeValue> item in response.Items) { Organization organization = DynamoUtilities.GetItemFromAttributeStore <Organization>(item); returnValue.Add(organization); } return(returnValue); } }
public Organization Get(Guid id) { AmazonDynamoDBClient client = DynamoUtilities.InitializeClient(); using (client) { GetItemRequest request = CreateGetItemRequest(id); GetItemResponse response = client.GetItem(request); if (response.Item == null) { string errorMessage = string.Format(ErrorMessages.MisingResponseItem, "Get Organization"); throw new MissingFieldException(errorMessage); } Organization returnValue = DynamoUtilities.GetItemFromAttributeStore <Organization>(response.Item); return(returnValue); } }
/// <summary> /// This method will use whatever information is supplied to scan the table /// supported fields are: /// CustomerId /// UserName /// Password(Hash) /// EmailAddress /// </summary> /// <param name="searchCriteria"></param> /// <returns></returns> public IEnumerable <UserInfo> Search(UserInfo searchCriteria) { AmazonDynamoDBClient client = DynamoUtilities.InitializeClient(); using (client) { ScanRequest request = CreateScanRequest(searchCriteria); if (request.ScanFilter.Count == 0) { throw new InvalidOperationException(ErrorMessages.NoSearchCriteria); } List <UserInfo> returnValue = new List <UserInfo>(); try { ScanResponse response = client.Scan(request); if (response.Items == null) { string errorMessage = string.Format(ErrorMessages.MisingResponseItem, "Search User"); throw new MissingFieldException(errorMessage); } foreach (Dictionary <string, AttributeValue> item in response.Items) { UserInfo user = DynamoUtilities.GetItemFromAttributeStore <UserInfo>(item); returnValue.Add(user); } } catch (AmazonDynamoDBException ex) { //expected exception, 404 } return(returnValue); } throw new NotImplementedException(); }