I want to improve the architecture of my ASP.NET MVC application. In my controller i use service layer with ViewModel. Example Service Layer:
 public interface ICashRegisterManager
{
    void CreateCashRegister(CashRegisterTransactionModel model, int? programId);
}
Example Controller:
 public class CashRegisterTransactionController : PersonContextController<CashRegisterTransactionModel, CashRegisterTransactionFilter>
{
    public CashRegisterTransactionController(IPersonContextProvider personContextProvider, ICashRegisterManager cashRegisterManager)
        : base(personContextProvider)
    {
        ExceptionUtil.NotNull(cashRegisterManager, "cashRegisterManager");
        this.cashRegisterManager = cashRegisterManager;
    }
    public override ActionResult Create(DataSourceRequest request, CashRegisterTransactionModel contract)
    {
        cashRegisterManager.CreateCashRegister(contract, contract.ProgramId);
        return base.Create(request, contract);
    }
But in Service layer i should to create instance of IRepository and every time map TContract into TEntity.
My idea is in Service layer to use intermediate class , how make this.
Example:
  public class CashRegisterManager : ICashRegisterManager
  {
      public void CreateCashRegister(CashRegisterTransactionModel model, int? programId)
     {
         var persister = Persistence.GetPersister<CashRegisterTransactionModel>();
         persister.Add(model);
      }
   }
  public interface IPersister<TContrct>
  {
    void Add(TContrct model);
  } 
I don't know how to implement the Add method, which to use IRepository. I guess that should comply with the naming conventions of TContract and TEnitity(CashRegisterTransactionModel/CashRegisterTransaction) and how can I return a instance of IPersister. I apologize for my English. Thank you for your time!!!
 
    