public void AddItems(List<Item> items)
 {
     using (PriceCompareContext db = new PriceCompareContext())
     {
         db.Items.AddRange(items);
         db.SaveChanges();
     }
 }
 public void AddItem(Item item)
 {
     using (PriceCompareContext db = new PriceCompareContext())
     {
         db.Items.Add(item);
         db.SaveChanges();
     }
 }
 public void DeleteAll()
 {
     using (PriceCompareContext db = new PriceCompareContext())
     {
         db.Items.RemoveRange(db.Items);
         db.Users.RemoveRange(db.Users);
         db.Stores.RemoveRange(db.Stores);
         db.SaveChanges();
     }
 }
 public void AddStore(Store store)
 {
     using (PriceCompareContext db = new PriceCompareContext())
     {
         if (db.Stores.Where(dbStore => dbStore.Name.Equals(store.Name) && dbStore.ChainStoreName.Equals(store.ChainStoreName)).ToList().Count == 0)
         {
             db.Stores.Add(store);
             db.SaveChanges();
         }
     }
 }
 public void AddUser(User user)
 {
     using (PriceCompareContext db = new PriceCompareContext())
     {
        if (String.IsNullOrEmpty(user.Name) || String.IsNullOrEmpty(user.Password))
         {
             throw new ArgumentException("Please enter name and password!");
         }
         if (db.Users.Where(dbUser => dbUser.Name == user.Name).ToList().Count != 0)
         {
             throw new ArgumentException($"There is user with the name {user.Name}!");
         }
         db.Users.Add(user);
         db.SaveChanges();
     }
 }