示例#1
0
 public void AddItem(Item item)
 {
     using (var ctx = new ShopsDB())
     {
         ctx.Items.Add(item);
         ctx.SaveChanges();
     }
 }
示例#2
0
 public void AddPurchase(PurchaseItem purchaseItem)
 {
     using (var ctx = new ShopsDB())
     {
         ctx.PurchaseItems.Add(purchaseItem);
         ctx.SaveChanges();
         DeletePurchaseFromUserFile(purchaseItem);
     }
 }
示例#3
0
        //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);
            }
        }