Ejemplo n.º 1
0
        internal List <WebsiteDataModel> DynamoDbSearchWebsites(IdentitiesFilterCriteria filterCriteria)
        {
            if ((null == filterCriteria.Email || "" == filterCriteria.Email) && (null == filterCriteria.WebsiteName || "" == filterCriteria.WebsiteName))
            {
                return(null);
            }
            Dictionary <string, Condition> filter = new Dictionary <string, Condition>();

            //if ( null != filterCriteria.WebsiteName && "" != filterCriteria.WebsiteName )
            //    {
            //    filter.Add("Name", new Condition
            //        {
            //        ComparisonOperator = "CONTAINS",
            //        AttributeValueList = new List<AttributeValue>()
            //                   {
            //                   new AttributeValue {S=filterCriteria.FirstName.ToLower()}
            //                   }
            //        });
            //    }
            if (null != filterCriteria.Email && "" != filterCriteria.Email)
            {
                filter.Add("Email", new Condition
                {
                    ComparisonOperator = "CONTAINS",
                    AttributeValueList = new List <AttributeValue>()
                    {
                        new AttributeValue {
                            S = filterCriteria.Email.ToLower()
                        }
                    }
                });
            }
            ScanRequest request = new ScanRequest
            {
                TableName       = _tableName,
                AttributesToGet = new List <string> {
                    "Email", "WebsiteDataModel"
                },
                ScanFilter = filter
            };
            ScanResponse             response     = AmazonDynamoDBClientConnection.Client.Scan(request);
            List <IdentityDataModel> identityList = CovertresponseIntoJSON(response);

            if (0 < identityList.FirstOrDefault().WebsiteDataModel.Count)
            {
                List <WebsiteDataModel> websitelist = new List <WebsiteDataModel>();
                foreach (WebsiteDataModel website in identityList.FirstOrDefault().WebsiteDataModel)
                {
                    if (website.WebsiteName.ToLower().Contains(filterCriteria.WebsiteName.ToLower()) || website.WebsiteLabel.ToLower().Contains(filterCriteria.WebsiteName.ToLower()))
                    {
                        websitelist.Add(website);
                    }
                }
                return(websitelist);
            }
            return(null);
        }
Ejemplo n.º 2
0
        internal Response DynamoDbSearchAffiliates(IdentitiesFilterCriteria filterCriteria)
        {
            if ((null == filterCriteria.FirstName || "" == filterCriteria.FirstName) && (null == filterCriteria.Date || "" == filterCriteria.Date))
            {
                return(new Response(false, "First enter Search String"));
            }
            Dictionary <string, Condition> filter = new Dictionary <string, Condition>();

            if (null != filterCriteria.FirstName && "" != filterCriteria.FirstName)
            {
                filter.Add("Name", new Condition
                {
                    ComparisonOperator = "CONTAINS",
                    AttributeValueList = new List <AttributeValue>()
                    {
                        new AttributeValue {
                            S = filterCriteria.FirstName.ToLower()
                        }
                    }
                });
            }
            if (null != filterCriteria.Date && "" != filterCriteria.Date)
            {
                filter.Add("CurrentDate", new Condition
                {
                    ComparisonOperator = "CONTAINS",
                    AttributeValueList = new List <AttributeValue>()
                    {
                        new AttributeValue {
                            S = filterCriteria.Date.ToLower()
                        }
                    }
                });
            }
            ScanRequest request = new ScanRequest
            {
                TableName       = _tableName,
                AttributesToGet = new List <string> {
                    "CurrentDate", "Name", "Identities"
                },
                ScanFilter = filter
            };
            ScanResponse response = AmazonDynamoDBClientConnection.Client.Scan(request);
            List <AffiliateDataModel> identityList = CovertresponseIntoJSON(response);

            return(new Response(true, "Search data found", identityList));
        }