Ejemplo n.º 1
0
        public void RemoveStore(int id)
        {
            if (_dbContext.Store.Any(s => s.Id == id))
            {
                foreach (Inventory inventory in _dbContext.Inventory.Where(i => i.StoreId == id))
                {
                    _dbContext.Remove(inventory);
                }

                _dbContext.Remove(_dbContext.Store.First(s => s.Id == id));
            }
            else
            {
                Console.WriteLine($"No Store with ID: {id} exists.");
            }
        }
Ejemplo n.º 2
0
        public void RemoveOrder(int id)
        {
            if (_dbContext.Orders.Any(s => s.Id == id))
            {
                foreach (OrderItems oI in _dbContext.OrderItems.Where(i => i.OrderId == id))
                {
                    _dbContext.Remove(oI);
                }

                _dbContext.Remove(_dbContext.Orders.First(s => s.Id == id));
                _dbContext.SaveChanges();
            }
            else
            {
                Console.WriteLine($"No Store with ID: {id} exists.");
            }
        }
Ejemplo n.º 3
0
 public void RemoveCustomer(int id)
 {
     if (_dbContext.Customer.Any(c => c.Id == id))
     {
         _dbContext.Remove(_dbContext.Customer.First(c => c.Id == id));
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
 }