//[6][5] 삭제
        public async Task <bool> DeleteAsync(int id)
        {
            try
            {
                var model = await _context.Products.SingleOrDefaultAsync(c => c.ProductId == id);

                _context.Remove(model);
                return(await _context.SaveChangesAsync() > 0 ? true : false);
            }
            catch (Exception e)
            {
                _logger.LogError($"ERROR({nameof(DeleteAsync)}): " + e.Message);
            }

            return(false);
        }
예제 #2
0
        // 삭제
        public async Task <bool> DeleteAsync(int id)
        {
            var customer = await _context.Customers
                           .SingleOrDefaultAsync(c => c.CustomerId == id);

            _context.Remove(customer);
            try
            {
                return(await _context.SaveChangesAsync() > 0 ? true : false);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error in {nameof(DeleteAsync)}: " + ex.Message);
            }
            return(false);
        }
예제 #3
0
        // 삭제
        public async Task <bool> DeleteAsync(int id)
        {
            try
            {
                var model = await _context.Customers
                            //.Include(c => c.Orders)
                            .SingleOrDefaultAsync(c => c.CustomerId == id);

                _context.Remove(model);
                return(await _context.SaveChangesAsync() > 0 ? true : false);
            }
            catch (Exception e)
            {
                _logger.LogError($"에러 발생({nameof(DeleteAsync)}): " + e.Message);
            }
            return(false);
        }