Editing many “categorizations” tables in one window

Feb 27, 2013 at 1:40 AM
Edited Feb 27, 2013 at 2:19 AM
Good day everyone!
I'm trying to edit (base CRUD operations) multiple "category-like" tables in one window of my mvvm-based app. So ModelView of editing window use one ServiceAgent object which provide implementation of required operations to models.

I implemented ModelView as somewhat huge class filled with anti-DRY code repetition, the reason is that Categorization tables' structure varies subtily and it in 70% have one field "name" thus my code for CRUD is extremly boring ) and looks like:
private string organizationName;
  public string OrganizationName
  {
     get ...
     set ...
  }

  private organization selectedOrganization;
  public organization SelectedOrganization
  {
     get .....
     set ....
  }

  private List<organization> allOrganizations;
  public List<organization> AllOrganizations
  {
     get ....
     set ...
  }


  private RelayCommand _addOrganizationCommand;
  public ICommand AddOrganizationCommand
  {
     get
     {
        if (_addOrganizationCommand == null)
           _addOrganizationCommand = new RelayCommand(AddOrganization);
        return _addOrganizationCommand;
     }
  }
  private void AddOrganization(object prm)
  {
     serviceAgent.CreateOrganization(OrganizationName);
     AllLevels = serviceAgent.ListAllEventLevels();
  }

  private RelayCommand _deleteOrganizationCommand;
  public ICommand DeleteOrganizationCommand
  {
     get
     {
        if (_deleteOrganizationCommand == null)
           _deleteOrganizationCommand = new RelayCommand(DeleteOrganization);
        return _deleteOrganizationCommand;
     }
  }
  private void DeleteOrganization(object prm)
  {
     serviceAgent.DeletePartner(SelectedOrganization.Id);
     AllOrganizations = serviceAgent.ListAllOrganization();
  }
and so on for each model to be edited in the window. Each time I want to add some functionality to standart operations for all models it cause me a headache. What is common approach in mvvm to the problem ?