コード例 #1
0
        public IList <CustomProfileInfo> GetProfileInfo([FromBody] ProfileInfo profileInfo)
        {
            string qualifiers = "";
            var    parameters = new List <Tuple <string, string, NpgsqlDbType> >();

            if (!string.IsNullOrEmpty(profileInfo.UsernameToMatch))
            {
                qualifiers += " AND Username LIKE :Username";
                parameters.Add(new Tuple <string, string, NpgsqlDbType>(":Username", profileInfo.UsernameToMatch, NpgsqlDbType.Text));
            }
            if (profileInfo.UserInactiveSinceDate != null)
            {
                qualifiers += " AND LastActivityDate >= :LastActivityDate";
                parameters.Add(new Tuple <string, string, NpgsqlDbType>("LastActivityDate", profileInfo.UserInactiveSinceDate.ToString(), NpgsqlDbType.Date));
            }
            if (profileInfo.AuthenticationOption != 2)
            {
                qualifiers += " AND IsAnonymous = " + (profileInfo.AuthenticationOption == 0 ? "TRUE" : "FALSE");
            }
            var totalRecords = DBFacilitator.GetInteger(
                PostgreSQLConnectionString,
                SELECT_PROFILE_COUNT + qualifiers,
                parameters);

            if (totalRecords <= 0)
            {
                return(new List <CustomProfileInfo>());
            }

            return(DBFacilitator.GetList <CustomProfileInfo>(
                       PostgreSQLConnectionString,
                       SELECT_PROFILES + qualifiers,
                       parameters));
        }
コード例 #2
0
        public IList <ItemInfo> GetItemByProduct(string productId)
        {
            string key = "itembyproduct_" + productId;

            if (CachingEnabled)
            {
                var cached = ServiceSharedCore.RedisCacheManager.Get <List <ItemInfo> >(key);
                if (cached != null)
                {
                    return(cached);
                }
            }
            var dbResult = DBFacilitator.GetList <ItemInfo>(
                PostgreSQLConnectionString,
                SQL_SELECT_ITEMS_BY_PRODUCT,
                new List <Tuple <string, string, NpgsqlDbType> >()
            {
                { new Tuple <string, string, NpgsqlDbType>("productId", productId, NpgsqlDbType.Text) }
            });

            if (CachingEnabled)
            {
                ServiceSharedCore.RedisCacheManager.Store(key, dbResult);
            }
            return(dbResult);
        }
コード例 #3
0
        public IList <ProductInfo> GetProductsBySearch(string terms)
        {
            string key    = "productsearch_" + terms;
            var    cached = ServiceSharedCore.RedisCacheManager.Get <List <ProductInfo> >(key);

            if (cached != null)
            {
                return(cached);
            }

            var keywords = terms.Split(',');
            var sb       = new StringBuilder(SQL_SELECT_PRODUCTS_BY_SEARCH1);

            for (int i = 0; i < keywords.Length; i++)
            {
                sb.Append(String.Format(SQL_SELECT_PRODUCTS_BY_SEARCH2, keywords[i]));
                if (i < keywords.Length - 1)
                {
                    sb.Append(SQL_SELECT_PRODUCTS_BY_SEARCH3);
                }
            }
            sb.Append(SQL_SELECT_PRODUCTS_BY_SEARCH4);

            var dbResult = DBFacilitator.GetList <ProductInfo>(
                ConfigSettings.PostgreSQLConnectionString,
                sb.ToString(),
                new List <Tuple <string, string, NpgsqlDbType> >());

            ServiceSharedCore.RedisCacheManager.Store(key, dbResult);
            return(dbResult);
        }
コード例 #4
0
        public CategoryInfo Get(string categoryId)
        {
            string key = "category_" + categoryId;

            if (CachingEnabled)
            {
                var cached = ServiceSharedCore.RedisCacheManager.Get <CategoryInfo>(key);
                if (cached != null)
                {
                    return(cached);
                }
            }
            var dbResult = DBFacilitator.GetList <CategoryInfo>(
                PostgreSQLConnectionString,
                SQL_GET_PRODUCTS_BY_CATEGORY,
                new List <Tuple <string, string, NpgsqlDbType> >()
            {
                { new Tuple <string, string, NpgsqlDbType>("categoryId", categoryId, NpgsqlDbType.Text) }
            })
                           .First();

            if (CachingEnabled)
            {
                ServiceSharedCore.RedisCacheManager.Store(key, dbResult);
            }
            return(dbResult);
        }
コード例 #5
0
        public IList <ProductInfo> GetProductsByCategory(string category)
        {
            string key = "product_" + category;

            if (CachingEnabled)
            {
                var cached = ServiceSharedCore.RedisCacheManager.Get <List <ProductInfo> >(key);
                if (cached != null)
                {
                    return(cached);
                }
            }

            var dbResult = DBFacilitator.GetList <ProductInfo>(
                ConfigSettings.PostgreSQLConnectionString,
                SQL_SELECT_PRODUCTS_BY_CATEGORY,
                new List <Tuple <string, string, NpgsqlDbType> >()
            {
                { new Tuple <string, string, NpgsqlDbType>(":categoryId", category, NpgsqlDbType.Text) }
            });

            if (CachingEnabled)
            {
                ServiceSharedCore.RedisCacheManager.Store(key, dbResult);
            }
            return(dbResult);
        }
コード例 #6
0
 public IList <ItemInfo> GetItemByProduct(string productId)
 {
     return(DBFacilitator.GetList <ItemInfo>(
                ConfigSettings.PostgreSQLConnectionString,
                SQL_SELECT_ITEMS_BY_PRODUCT,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>("productId", productId, NpgsqlDbType.Text) }
     }));
 }
コード例 #7
0
 public IList <ProductInfo> GetProductsByCategory(string category)
 {
     return(DBFacilitator.GetList <ProductInfo>(
                ConfigSettings.PostgreSQLConnectionString,
                SQL_SELECT_PRODUCTS_BY_CATEGORY,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>(":categoryId", category, NpgsqlDbType.Text) }
     }));
 }
コード例 #8
0
 public CategoryInfo Get(string categoryId)
 {
     return(DBFacilitator.GetList <CategoryInfo>(
                PostgreSQLConnectionString,
                SQL_GET_PRODUCTS_BY_CATEGORY,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>("categoryId", categoryId, NpgsqlDbType.Text) }
     })
            .First());
 }
コード例 #9
0
 public IList <CartItemInfo> GetCartItems([FromBody] GetCartItems cartitems)
 {
     return(DBFacilitator.GetList <CartItemInfo>(
                PostgreSQLConnectionString,
                GET_CART_ITEMS,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>(":Username", cartitems.Username, NpgsqlDbType.Text) },
         { new Tuple <string, string, NpgsqlDbType>(":ApplicationName", cartitems.AppName, NpgsqlDbType.Text) },
         { new Tuple <string, string, NpgsqlDbType>(":IsShoppingCart", cartitems.IsShoppingCart ? "Y" : "N", NpgsqlDbType.Char) }
     }
                ));
 }
コード例 #10
0
 public IList <string> GetInactiveProfiles([FromBody] InactiveProfiles inactiveInfo)
 {
     return(DBFacilitator.GetList <string>(
                PostgreSQLConnectionString,
                UPDATE_ACTIVITY_DATES_ACTIVITY_ONLY,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>(":LastActivityDate", inactiveInfo.UserInactiveSinceDate.ToString(), NpgsqlDbType.Date) },
         { new Tuple <string, string, NpgsqlDbType>(":ApplicationName", inactiveInfo.AppName, NpgsqlDbType.Text) },
         { new Tuple <string, string, NpgsqlDbType>(":IsAnonymous", DateTime.Now.ToString(), NpgsqlDbType.Date) }
     }
                ));
 }
コード例 #11
0
        public AddressInfo GetAccountInfo([FromBody] AccountInfo info)
        {
            var accounts = DBFacilitator.GetList <AddressInfo>(
                PostgreSQLConnectionString,
                GET_ACCOUNT_INFO,
                new List <Tuple <string, string, NpgsqlDbType> >()
            {
                { new Tuple <string, string, NpgsqlDbType>(":Username", info.FirebaseGUID, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":ApplicationName", info.AppName, NpgsqlDbType.Text) }
            });

            if (accounts.Count >= 1)
            {
                return(accounts.First());
            }
            return(null);
        }
コード例 #12
0
        public IList <ProductInfo> GetProductsBySearch(string terms)
        {
            var keywords = terms.Split(',');
            var sb       = new StringBuilder(SQL_SELECT_PRODUCTS_BY_SEARCH1);

            for (int i = 0; i < keywords.Length; i++)
            {
                sb.Append(String.Format(SQL_SELECT_PRODUCTS_BY_SEARCH2, keywords[i]));
                if (i < keywords.Length - 1)
                {
                    sb.Append(SQL_SELECT_PRODUCTS_BY_SEARCH3);
                }
            }
            sb.Append(SQL_SELECT_PRODUCTS_BY_SEARCH4);

            return(DBFacilitator.GetList <ProductInfo>(
                       ConfigSettings.PostgreSQLConnectionString,
                       sb.ToString(),
                       new List <Tuple <string, string, NpgsqlDbType> >()));
        }
コード例 #13
0
        public List <CategoryInfo> Get()
        {
            string key = "category_all";

            if (CachingEnabled)
            {
                var cached = ServiceSharedCore.RedisCacheManager.Get <List <CategoryInfo> >(key);
                if (cached != null)
                {
                    return(cached);
                }
            }
            var dbResult = DBFacilitator.GetList <CategoryInfo>(
                PostgreSQLConnectionString,
                SQL_GET_PRODUCTS);

            if (CachingEnabled)
            {
                ServiceSharedCore.RedisCacheManager.Store(key, dbResult);
            }
            return(dbResult);
        }
コード例 #14
0
 public List <CategoryInfo> Get()
 {
     return(DBFacilitator.GetList <CategoryInfo>(
                PostgreSQLConnectionString,
                SQL_GET_PRODUCTS));
 }