title: Lots Repositories In Project
body: <p>I'm using ninject controller factory to bind some repositories to controllers via interfaces...</p>
  
  <pre><code>public class NinjectControllerFactory : DefaultControllerFactory 
  {
      private IKernel ninjectKernel;
  
      public NinjectControllerFactory() 
      {
          ninjectKernel = new StandardKernel();
          AddBindings();
      }
  
      protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) {
          return controllerType == null ? null : (IController)ninjectKernel.Get(controllerType);
      }
  
      private void AddBindings() 
      {
          ninjectKernel.Bind&lt;ISystemDefinition&lt;CentreModel&gt;&gt;().To&lt;CentreRepository&gt;();
          ninjectKernel.Bind&lt;ISystemDefinition&lt;ResidentStatusModel&gt;&gt;().To&lt;ResidentStatusRepository&gt;();
      // here will be the list of lots of repositories with different models
      }
  
  }
  </code></pre>
  
  <p>Imagine that i need to write about hundred forms with different data, so i need to have at least different models...(maybe with same "IReposotory"), but i still need to add model into "AddBindings()" method... Is it ok? (I'm not sure)...
  What is the best practice to store repositories with different models into controllers?</p>
  
  <p>Model is for example: </p>
  
  <pre><code>public class CentreModel : BaseModel {
      [Required(ErrorMessage = "*")]
      [Display(Name = "Name:")]
      public string Name { get; set; }
  
      [Display(Name = "Order:")]
      [Required(ErrorMessage = "*")]
      public int SortOrder { get; set; }
  
      [Display(Name = "Is active:")]
      public bool IsActive { get; set; }
  
      [Required(ErrorMessage = "*")]
      [Display(Name = "Associated centre:")]
      public int AssociatedCentreId { get; set; }
      public IEnumerable&lt;CentreListModel&gt; OldCentres { get; set; }
  }
  </code></pre>
  
  <p>Interface example:</p>
  
  <pre><code>public interface ISystemDefinition&lt;T&gt; where T : class,new()
  {
      IEnumerable&lt;T&gt; GetList(bool? isActive = null);
      IEnumerable&lt;T&gt; GetList(bool? isActive = null, int? OwnerID = null);
      T Fetch(int? ID);
      void Save(T item);
      void Remove(T item);
      void Order(List&lt;T&gt; items);
  }
  </code></pre>
  
  <p>And Repository example:</p>
  
  <pre><code>public class CentreRepository : BaseRepository, ISystemDefinition&lt;CentreModel&gt; {
      public IEnumerable&lt;CentreModel&gt; GetList(bool? isActive) {
          return (from c in entities.Centres
                  where c.IsActive == isActive || isActive == null
                  orderby c.SortOrder
                  select new CentreModel {
                      ID = c.ID,
                      Name = c.Name,
                      IsActive = c.IsActive,
                      SortOrder = c.SortOrder,
                      AssociatedCentreId = c.AssociatedCentreID
                  });
      }
  
      public CentreModel Fetch(int? ID) {
          return (from c in entities.Centres
                  where c.ID == ID
                  orderby c.SortOrder
                  select new CentreModel {
                      ID = c.ID,
                      Name = c.Name,
                      IsActive = c.IsActive,
                      SortOrder = c.SortOrder,
                      AssociatedCentreId = c.AssociatedCentreID
                  }).FirstOrDefault();
      }
  
      public void Save(CentreModel model) {
          Centre centre = model.IsNew ? new Centre() : entities.Centres.Where(c =&gt; c.ID == model.ID).SingleOrDefault();
  
          centre.Name = model.Name;
          centre.SortOrder = model.SortOrder;
          centre.IsActive = model.IsActive;
          centre.AssociatedCentreID = model.AssociatedCentreId;
  
          if (model.IsNew) entities.Centres.Add(centre);
  
          Save();
      }
  
      public void Remove(CentreModel model) {
          Centre centre = model.IsNew ? new Centre() : entities.Centres.Where(c =&gt; c.ID == model.ID).SingleOrDefault();
          entities.Centres.Remove(centre);
  
          Save();
      }
  
      public void Order(List&lt;CentreModel&gt; items) {
          throw new NotImplementedException();
      }
      public IEnumerable&lt;CentreModel&gt; GetList(bool? isActive = null, int? OwnerID = null) {
          throw new NotImplementedException();
      }
  }
  </code></pre>