title: How to add a class to record activity?
body: <p>I have a class library doing some CRUD operations for different areas of the system. One common requirement i have is to record the activity. My project is structured so i have an Interface and a class uses that interface.</p>
  
  <pre><code>public interface Users
  {
   void AddUser(User u);
  }
  
  public interface Products
  {
   void AddProducts(Product p);
  }
  
  Likewise my class code is similar to 
  
  public class Users : DataContext, IUsers
  {
   void AddUser(User u)
   {
     Context.User.InsertOnSubmit(u);
     Context.SubmitChanges();
     // AddActivity("User was added");
   }
  }
  
  public class Products : DataContext, IProducts
  {
   void AddProducts(Product p)
   {
     Context.Products.InsertOnSubmit(p);
     Context.SubmitChanges();
   // AddActivity("Product was added");
   }
  }
  </code></pre>
  
  <p>This works fine but i need to add all the activity that occurs i.e. when a user adds a product or user.</p>
  
  <p>Considering this would be re-used across other similar classes as above, i would like to minimise repeating/copying the code. I did consider using an <code>abstract</code> class but received an object no instantiated error so not sure if my approach is wrong or missed something. I dont want to my classes to inherit a <code>UserActivity</code> Interface as that would mean i need to copy the code into that particular class for it to work. This one class would be doing the same type of tasks (just add a record).</p>
  
  <p>How could i add another class to my projects which does one task of recording the activity but if i need to make a change to the Activity insertion method i can do this in one place instead of going through all the classes?</p>