public static void Insert(ProductProfit productProfit) { using (var db = OnlineStoreDbContext.Entity) { db.ProductProfits.Add(productProfit); db.SaveChanges(); } }
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(); } }
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(); } }