My boss, recently gave me some C# .NET code he wants me to incorporate in an n-tiered MVC application I am building. He wants me to fill in the missing code. Here is a middle-tier class file (shown below)
public class UnitOfWork : IUnitOfWork
{
private readonly JRES_Context _context;
public UnitOfWork(JRES_Context context)
{
_context = context;
table1_UOW = new table1Repository(_context);
table2_UOW = new table2Repository(_context);
}
public Iinterface1 table1_UOW { get; private set; }
public Iinterface2 table2_UOW { get; private set; }
public int Complete()
{
return _context.SaveChanges();
}
public void Dispose()
{
_context.Dispose();
}
}
One things puzzles me: why are 2 previously-defined interfaces declared? Isn't the purpose of the interface to IMPLEMENT it (and thereby enforce behavior inside the object that implements it)? I wondered if there was another good purpose (the interfaces define some 'Get' methods used on the UI layer) - or maybe there is a better way to code this.
table1_UOWandtable2_UOW, those aren't interface declarations, they are properties of typeIinterface1andIinterface2, respectively.