public bool DeleteSanPham(string maSanPham) { var oldSanPham = _context.SanPhams .Include(sp => sp.DanhMuc) .FirstOrDefault(sp => sp.Id.Equals(maSanPham)); if (oldSanPham == null) { throw new KeyNotFoundException(maSanPham); } _context.Remove(oldSanPham); try { _context.SaveChanges(); } catch (Exception ex) { throw new ArgumentException(ex.InnerException == null ? ex.Message : ex.InnerException.Message); } return(true); }