Manish Tewary

Manish Tewary

  • 1.7k
  • 78
  • 584

How can I use a generic repository and unitofwork?

Apr 16 2019 1:15 PM
I have a service layer which is using unitofwork and Imapper, example given below:
  1. //Service layer   
  2. public interface IEmployeeService  
  3. {        
  4.    Task  AddEmployee(EmployeeListResponseModel model);       
  5. }  
  6. public class EmployeeService :  IEmployeeService       
  7. {  
  8.  public async Task AddEmployees(EmployeeListResponseModel mode)           
  9.    {                                 
  10.       public EmployeeService (IUnitOfWork unitOfWork, IMapper mapper)           
  11.        {              
  12.          _unitOfWork = unitOfWork;               
  13.          _mapper = mapper;           
  14.        }            
  15.    private readonly IUnitOfWork _unitOfWork;           
  16.       private readonly IMapper _mapper;      
  17. }  
Question: How can i call this service method "AddEmployees" in one of my class library project? For creating a object of class "EmployeeService" i need to create unitofwork and imapper but i do not know the best practice. Kindly help

Answers (1)