Пример #1
0
        public static void Insert(ProductProfit productProfit)
        {
            using (var db = OnlineStoreDbContext.Entity)
            {
                db.ProductProfits.Add(productProfit);

                db.SaveChanges();
            }
        }
Пример #2
0
        public static void Update(ProductProfit productProfit)
        {
            using (var db = OnlineStoreDbContext.Entity)
            {
                var orgProductProfit = db.ProductProfits.Where(item => item.ID == productProfit.ID).Single();

                orgProductProfit.ProductID  = productProfit.ProductID;
                orgProductProfit.Percent    = productProfit.Percent;
                orgProductProfit.ProfitType = productProfit.ProfitType;
                orgProductProfit.LastUpdate = productProfit.LastUpdate;

                db.SaveChanges();
            }
        }
Пример #3
0
        public static void Insert(int productID, byte physicalSell, byte downloadSell)
        {
            using (var db = OnlineStoreDbContext.Entity)
            {
                var profit_PhysicalSell = new ProductProfit()
                {
                    ProductID  = productID,
                    Percent    = physicalSell,
                    ProfitType = ProfitType.PhysicalSell
                };

                var profit_DownloadSell = new ProductProfit()
                {
                    ProductID  = productID,
                    Percent    = downloadSell,
                    ProfitType = ProfitType.DownloadSell
                };

                db.ProductProfits.Add(profit_PhysicalSell);
                db.ProductProfits.Add(profit_DownloadSell);

                db.SaveChanges();
            }
        }