コード例 #1
0
 public void UpdateActivityDates([FromBody] ActivityDates dates)
 {
     if (dates.ActivityOnly)
     {
         DBFacilitator.ExecuteCommand(
             PostgreSQLConnectionString,
             UPDATE_ACTIVITY_DATES_ACTIVITY_ONLY,
             new List <Tuple <string, string, NpgsqlDbType> >()
         {
             { new Tuple <string, string, NpgsqlDbType>(":Username", dates.Username, NpgsqlDbType.Text) },
             { new Tuple <string, string, NpgsqlDbType>(":ApplicationName", dates.AppName, NpgsqlDbType.Text) },
             { new Tuple <string, string, NpgsqlDbType>(":LastActivityDate", dates.ActivityOnly ? "Y" : "N", NpgsqlDbType.Date) }
         }
             );
     }
     else
     {
         DBFacilitator.ExecuteCommand(
             PostgreSQLConnectionString,
             UPDATE_ACTIVITY_DATES,
             new List <Tuple <string, string, NpgsqlDbType> >()
         {
             { new Tuple <string, string, NpgsqlDbType>(":Username", dates.Username, NpgsqlDbType.Text) },
             { new Tuple <string, string, NpgsqlDbType>(":ApplicationName", dates.AppName, NpgsqlDbType.Text) },
             { new Tuple <string, string, NpgsqlDbType>(":LastActivityDate", DateTime.Now.ToString(), NpgsqlDbType.Date) },
             { new Tuple <string, string, NpgsqlDbType>(":LastUpdatedDate", DateTime.Now.ToString(), NpgsqlDbType.Date) }
         }
             );
     }
 }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
        public ItemInfo GetItem(string itemId)
        {
            string key = "item_" + itemId;

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

            if (CachingEnabled)
            {
                ServiceSharedCore.RedisCacheManager.Store(key, dbResult);
            }
            return(dbResult);
        }
コード例 #5
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));
        }
コード例 #6
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);
        }
コード例 #7
0
        public void SetAccountInfo([FromBody] SetAccountInfo accountInfo)
        {
            //TODO: use transactions here and in any other multi-call endpoints
            var deletedRecords = DBFacilitator.GetInteger(
                PostgreSQLConnectionString,
                DELETE_ACCOUNT,
                new List <Tuple <string, string, NpgsqlDbType> >()
            {
                { new Tuple <string, string, NpgsqlDbType>(":UniqueId", accountInfo.UniqueId.ToString(), NpgsqlDbType.Integer) }
            });

            DBFacilitator.ExecuteCommand(
                PostgreSQLConnectionString,
                INSERT_ACCOUNT,
                new List <Tuple <string, string, NpgsqlDbType> >()
            {
                { new Tuple <string, string, NpgsqlDbType>(":UniqueId", accountInfo.UniqueId.ToString(), NpgsqlDbType.Integer) },
                { new Tuple <string, string, NpgsqlDbType>(":Email", accountInfo.AddressInfo.Email, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":FirstName", accountInfo.AddressInfo.FirstName, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":LastName", accountInfo.AddressInfo.LastName, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":Address1", accountInfo.AddressInfo.Address1, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":Address2", accountInfo.AddressInfo.Address2, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":City", accountInfo.AddressInfo.City, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":State", accountInfo.AddressInfo.State, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":Zip", accountInfo.AddressInfo.Zip, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":Country", accountInfo.AddressInfo.Country, NpgsqlDbType.Text) },
                { new Tuple <string, string, NpgsqlDbType>(":Phone", accountInfo.AddressInfo.Phone, NpgsqlDbType.Text) }
            });
        }
コード例 #8
0
        public ItemInfo Get(string itemId)
        {
            string key = "inventoryitem_" + itemId;

            if (CachingEnabled)
            {
                var cached = ServiceSharedCore.RedisCacheManager.Get <ItemInfo>(key);
                if (cached != null)
                {
                    return(cached);
                }
                //the Item controller has a method that retrieves a superset of the info needed here, check if that's cached too
                key    = "item_" + itemId;
                cached = ServiceSharedCore.RedisCacheManager.Get <ItemInfo>(key);
                if (cached != null)
                {
                    return(cached);
                }
            }


            var dbResult = DBFacilitator.GetOne <ItemInfo>(
                PostgreSQLConnectionString,
                SQL_GET_INVENTORY_BY_ITEM,
                new List <Tuple <string, string, NpgsqlDbType> >()
            {
                { new Tuple <string, string, NpgsqlDbType>("itemId", itemId, NpgsqlDbType.Text) }
            });

            if (CachingEnabled)
            {
                ServiceSharedCore.RedisCacheManager.Store(key, dbResult);
            }
            return(dbResult);
        }
コード例 #9
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);
        }
コード例 #10
0
        public void PostOrder([FromBody] OrderInfo orderInfo)
        {
            int?highestOrderId = DBFacilitator.GetInteger(PostgreSQLConnectionString, SQL_GET_HIGHEST_ORDERID, new List <Tuple <string, string, NpgsqlDbType> >());

            highestOrderId = highestOrderId.HasValue ? highestOrderId + 1 : 0;

            var sb = new StringBuilder("");

            sb.Append("INSERT INTO \"MSPETSHOP4ORDERS\".Orders VALUES(");
            sb.Append("'" + highestOrderId + "', ");
            sb.Append("'" + orderInfo.UserId + "', ");
            sb.Append("'" + orderInfo.Date + "', ");
            sb.Append("'" + orderInfo.ShippingAddress.Address1 + "', ");
            sb.Append("'" + orderInfo.ShippingAddress.Address2 + "', ");
            sb.Append("'" + orderInfo.ShippingAddress.City + "', ");
            sb.Append("'" + orderInfo.ShippingAddress.State + "', ");
            sb.Append("'" + orderInfo.ShippingAddress.Zip + "', ");
            sb.Append("'" + orderInfo.ShippingAddress.Country + "', ");
            sb.Append("'" + orderInfo.BillingAddress.Address1 + "', ");
            sb.Append("'" + orderInfo.BillingAddress.Address2 + "', ");
            sb.Append("'" + orderInfo.BillingAddress.City + "', ");
            sb.Append("'" + orderInfo.BillingAddress.State + "', ");
            sb.Append("'" + orderInfo.BillingAddress.Zip + "', ");
            sb.Append("'" + orderInfo.BillingAddress.Country + "', ");
            sb.Append("'" + " UPS',");
            sb.Append("'" + orderInfo.OrderTotal + "', ");
            sb.Append("'" + orderInfo.BillingAddress.FirstName + "', ");
            sb.Append("'" + orderInfo.BillingAddress.LastName + "', ");
            sb.Append("'" + orderInfo.ShippingAddress.FirstName + "', ");
            sb.Append("'" + orderInfo.ShippingAddress.LastName + "', ");
            sb.Append("'" + orderInfo.AuthorizationNumber + "', ");
            sb.Append("'US-en');\n");


            sb.Append("INSERT INTO \"MSPETSHOP4ORDERS\".OrderStatus VALUES(");
            sb.Append("'" + highestOrderId + "', ");
            sb.Append("'" + "0', ");
            sb.Append("'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', ");
            sb.Append("'P'");
            sb.Append(");\n");

            foreach (LineItemInfo info in orderInfo.LineItems)
            {
                sb.Append("INSERT INTO \"MSPETSHOP4ORDERS\".LineItem VALUES(");
                sb.Append("'" + highestOrderId + "', ");
                sb.Append("'" + info.Line + "', ");
                sb.Append("'" + info.ItemId + "', ");
                sb.Append("'" + info.Quantity + "', ");
                sb.Append("'" + info.Price);
                sb.Append("');\n");

                sb.Append("UPDATE \"MSPETSHOP4\".Inventory SET Qty = Qty - " + info.Quantity + " WHERE ItemId = '" + info.ItemId + "';\n");
            }

            DBFacilitator.ExecuteCommand(PostgreSQLConnectionString, sb.ToString(), new List <Tuple <string, string, NpgsqlDbType> >());
        }
コード例 #11
0
 public ItemInfo GetItem(string itemId)
 {
     return(DBFacilitator.GetOne <ItemInfo>(
                ConfigSettings.PostgreSQLConnectionString,
                SQL_SELECT_ITEMS_BY_ID,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>("itemId", itemId, NpgsqlDbType.Text) }
     }));
 }
コード例 #12
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) }
     }));
 }
コード例 #13
0
 public ItemInfo Get(string itemId)
 {
     return(DBFacilitator.GetOne <ItemInfo>(
                PostgreSQLConnectionString,
                SQL_GET_INVENTORY_BY_ITEM,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>("itemId", itemId, NpgsqlDbType.Text) }
     }));
 }
コード例 #14
0
 public ProductInfo GetProduct(string productId)
 {
     return(DBFacilitator.GetOne <ProductInfo>(
                ConfigSettings.PostgreSQLConnectionString,
                SQL_SELECT_PRODUCT,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>(":productId", productId, NpgsqlDbType.Text) }
     }));
 }
コード例 #15
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) }
     }));
 }
コード例 #16
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());
 }
コード例 #17
0
 public Cart GetUniqueID([FromBody] GetUniqueId uniqueIdInfo)
 {
     return(DBFacilitator.GetOne <Cart>(
                PostgreSQLConnectionString,
                GET_UNIQUEID_FOR_USER,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>(":Username", uniqueIdInfo.UserName, NpgsqlDbType.Text) },
         { new Tuple <string, string, NpgsqlDbType>(":ApplicationName", uniqueIdInfo.AppName, NpgsqlDbType.Text) }
     }
                ));
 }
コード例 #18
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) }
     }
                ));
 }
コード例 #19
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) }
     }
                ));
 }
コード例 #20
0
 public int Create([FromBody] CreateProfile createProfileInfo)
 {
     return(DBFacilitator.GetInteger(
                PostgreSQLConnectionString,
                CREATE_USER,
                new List <Tuple <string, string, NpgsqlDbType> >()
     {
         { new Tuple <string, string, NpgsqlDbType>(":Username", createProfileInfo.Username, NpgsqlDbType.Text) },
         { new Tuple <string, string, NpgsqlDbType>(":ApplicationName", createProfileInfo.AppName, NpgsqlDbType.Text) },
         { new Tuple <string, string, NpgsqlDbType>(":LastActivityDate", DateTime.Now.ToString(), NpgsqlDbType.Date) },
         { new Tuple <string, string, NpgsqlDbType>(":LastUpdatedDate", DateTime.Now.ToString(), NpgsqlDbType.Date) },
         { new Tuple <string, string, NpgsqlDbType>(":IsAnonymous", createProfileInfo.IsAuthenticated ? "N" : "Y", NpgsqlDbType.Char) }
     }
                ).Value);
 }
コード例 #21
0
 public void Post([FromBody] LineItemInfo[] info)
 {
     foreach (var lineitem in info)
     {
         DBFacilitator.ExecuteCommand(
             PostgreSQLConnectionString,
             SQL_UPDATE_INVENTORY,
             new List <Tuple <string, string, NpgsqlDbType> >()
         {
             { new Tuple <string, string, NpgsqlDbType>("itemId", lineitem.ItemId, NpgsqlDbType.Text) },
             { new Tuple <string, string, NpgsqlDbType>("quantity", lineitem.Quantity.ToString(), NpgsqlDbType.Integer) }
         }
             );
     }
 }
コード例 #22
0
        public ProductInfo GetProduct(string productId)
        {
            string key = "product_" + productId;
            var cached = ServiceSharedCore.RedisCacheManager.Get<ProductInfo>(key);
            if (cached != null) return cached;

            var dbResult = DBFacilitator.GetOne<ProductInfo>(
            ConfigSettings.PostgreSQLConnectionString,
                SQL_SELECT_PRODUCT,
                new List<Tuple<string, string, NpgsqlDbType>>() {
                    { new Tuple<string, string, NpgsqlDbType>(":productId", productId, NpgsqlDbType.Text) } });

            ServiceSharedCore.RedisCacheManager.Store(key, dbResult);
            return dbResult;
        }
コード例 #23
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);
        }
コード例 #24
0
        public bool DeleteProfile([FromBody] AccountInfo accountInfo)
        {
            var cart = GetUniqueID(new GetUniqueId(accountInfo.FirebaseGUID, false, true, accountInfo.AppName));

            if (cart != null)
            {
                int uniqueId       = cart.UniqueId;
                var deletedRecords = DBFacilitator.GetInteger(
                    PostgreSQLConnectionString,
                    DELETE_PROFILE,
                    new List <Tuple <string, string, NpgsqlDbType> >()
                {
                    { new Tuple <string, string, NpgsqlDbType>(":UniqueId", uniqueId.ToString(), NpgsqlDbType.Integer) }
                });
                return(deletedRecords == 0);
            }
            return(true);
        }
コード例 #25
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> >()));
        }
コード例 #26
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);
        }
コード例 #27
0
        public void SetCartItems([FromBody] SetCartItems cartItemInfo)
        {
            string uniqueId = cartItemInfo.UniqueID.ToString();
            string isCart   = cartItemInfo.IsShoppingCart ? "Y" : "N";

            DBFacilitator.ExecuteCommand(
                PostgreSQLConnectionString,
                DELETE_CART,
                new List <Tuple <string, string, NpgsqlDbType> >()
            {
                { new Tuple <string, string, NpgsqlDbType>(":UniqueId", uniqueId, NpgsqlDbType.Integer) },
                { new Tuple <string, string, NpgsqlDbType>(":IsShoppingCart", isCart, NpgsqlDbType.Char) }
            }
                );


            foreach (var item in cartItemInfo.CartItems)
            {
                DBFacilitator.ExecuteCommand(
                    PostgreSQLConnectionString,
                    INSERT_CART_ITEMS,
                    new List <Tuple <string, string, NpgsqlDbType> >()
                {
                    { new Tuple <string, string, NpgsqlDbType>(":UniqueId", uniqueId, NpgsqlDbType.Integer) },
                    { new Tuple <string, string, NpgsqlDbType>(":IsShoppingCart", isCart, NpgsqlDbType.Char) },
                    { new Tuple <string, string, NpgsqlDbType>(":ItemId", item.ItemId, NpgsqlDbType.Text) },
                    { new Tuple <string, string, NpgsqlDbType>(":Name", item.Name, NpgsqlDbType.Text) },
                    { new Tuple <string, string, NpgsqlDbType>(":Type", item.Type, NpgsqlDbType.Text) },
                    { new Tuple <string, string, NpgsqlDbType>(":CategoryId", item.CategoryId, NpgsqlDbType.Text) },
                    { new Tuple <string, string, NpgsqlDbType>(":ProductId", item.ProductId, NpgsqlDbType.Text) },
                    { new Tuple <string, string, NpgsqlDbType>(":Quantity", item.Quantity.ToString(), NpgsqlDbType.Numeric) },
                    { new Tuple <string, string, NpgsqlDbType>(":Price", item.Price.ToString(), NpgsqlDbType.Numeric) }
                }
                    );
            }
        }
コード例 #28
0
 public List <CategoryInfo> Get()
 {
     return(DBFacilitator.GetList <CategoryInfo>(
                PostgreSQLConnectionString,
                SQL_GET_PRODUCTS));
 }