public void AddItem(Item item) { using (var ctx = new ShopsDB()) { ctx.Items.Add(item); ctx.SaveChanges(); } }
public void AddPurchase(PurchaseItem purchaseItem) { using (var ctx = new ShopsDB()) { ctx.PurchaseItems.Add(purchaseItem); ctx.SaveChanges(); DeletePurchaseFromUserFile(purchaseItem); } }
//public void updatePurchases(Purchase newPurchase, Purchase oldPurchase) //{ // using (var ctx = new ShopsDB()) // { // ctx.Purchases.Remove(oldPurchase); // ctx.Purchases.Add(newPurchase); // ctx.SaveChanges(); // } //} #endregion #region add to db public void AddUser(User user) { using (var ctx = new ShopsDB()) { ctx.Users.Add(user); ctx.SaveChanges(); } string CSPath = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).FullName).FullName).FullName; string FolderPath = Path.Combine(CSPath, @"DAL\UsersLists\" + user.Id + ".txt"); if (!File.Exists(FolderPath)) { File.Create(FolderPath); } }