public async Task <bool> DeleteAsync(CustomerEntity customer)
        {
            _context.Remove(customer);
            await _context.SaveChangesAsync();

            return(true);
        }
Example #2
0
        public int Remove(Customer customer)
        {
            var customerFromDb = Get(customer.FirstName, customer.LastName);

            if (customerFromDb == null)
            {
                return(0);
            }
            _dbContext.Remove(customerFromDb);
            return(_dbContext.SaveChanges());
        }
        public String Delete(Customer customer)
        {
            try
            {
                using (var _context = new CustomerDbContext())
                {
                    Customer newRecord = _context.Customers.Where(c => c.Id == customer.Id).FirstOrDefault();

                    _context.Remove(newRecord);
                    _context.SaveChanges();

                    return("Customer with id : " + customer.Id + " Successesfully Removed");
                }
            }
            catch (Exception ex)
            {
                new Exception(ex.StackTrace);
                return("Deletion Failed");

                throw;
            }
        }