Example #1
0
        public static EF6.ProductPrice Get(Guid productId, Guid priceTypeId)
        {
            EF6.ProductPrice result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.ProductPrice.Where(x => x.ProductId == productId && x.PriceTypeId == priceTypeId).AsNoTracking().FirstOrDefault();
            }

            return(result);
        }
Example #2
0
        private void ImportProductPrice(Guid productId, string priceType, string currencyCode, string price)
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                string sql    = "ProductId = '" + productId.ToString() + "'";
                var    oPrice = ctx.ProductPrice.Where(x => x.ProductId == productId).FirstOrDefault();
                if (oPrice == null)
                {
                    oPrice = new EF6.ProductPrice();
                    oPrice.ProductPriceId = Guid.NewGuid();
                    oPrice.ProductId      = productId;
                    oPrice.PriceTypeId    = GetPriceType(priceType);
                    oPrice.CurrencyCode   = currencyCode;
                    oPrice.Price          = Convert.ToDecimal(price);

                    ctx.ProductPrice.Add(oPrice);
                    ctx.SaveChanges();
                }
            }
        }
Example #3
0
        private void SaveProductPrice(Guid productId, string priceType, string currencyCode, string price)
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var priceTypeId = ProductPriceTypeEx.GetIdByPriceType(priceType);
                //string sql = "ProductId = '" + productId.ToString() + "' AND PriceTypeId = '" + priceTypeId.ToString() + "'";

                var oPrice = ctx.ProductPrice.Where(x => x.ProductId == productId && x.ProductPriceId == priceTypeId).FirstOrDefault();
                if (oPrice == null)
                {
                    oPrice = new EF6.ProductPrice();
                    oPrice.ProductPriceId = Guid.NewGuid();
                    oPrice.ProductId      = productId;

                    ctx.ProductPrice.Add(oPrice);
                }
                oPrice.PriceTypeId  = ProductPriceTypeEx.GetIdByPriceType(priceType);
                oPrice.CurrencyCode = currencyCode;
                oPrice.Price        = Convert.ToDecimal((price == string.Empty) ? "0" : price);

                ctx.SaveChanges();
            }
        }