Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        /// <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();
        }