Esempio n. 1
0
        public void Remove(int id, int businessId)
        {
            try
            {
                Employee employee = _context.Employee
                                    .Include(x => x.Address)
                                    .Include(x => x.Contacts)
                                    .FirstOrDefault(x => x.Id == id && x.RegisterEmployee.BusinessId == businessId);
                if (employee == null)
                {
                    throw new Exception("Id Not Found");
                }

                _context.RemoveRange(employee.Address);
                _context.RemoveRange(employee);
                _context.RemoveRange(employee.Contacts);
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Esempio n. 2
0
        public void Remove(int id, int bussinessId)
        {
            try
            {
                Supplier supplier = FindById(id, bussinessId);
                _context.Remove(supplier.Address);
                _context.Remove(supplier);
                _context.RemoveRange(supplier.Contacts);

                _context.SaveChanges();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Esempio n. 3
0
        public async Task RemoveAsync(int id, int businessId)
        {
            try
            {
                Client client = await FindByIdAsync(id, businessId);

                _context.Remove(client.Address);
                _context.Remove(client);
                _context.RemoveRange(client.Contacts);

                _context.SaveChanges();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }