JobTypeLogic and JobType classes in MVC business logic I am working on an MVC solution.  My DAL layer I could solve with Repository classes, everything is working great.

But in my BLL layer I have repetitive code:

My CRUD is the same, my fields and consructor are different.
I can also have some extra methods.

Is there a way to solve this properly?

Class 1

public class JobTypeLogic
{
    #region Fields
    public JobType JobType { get; set; }
    private UnitOfWork unitOfWork = new UnitOfWork();
    public Repository&lt;JobType&gt; JobTypeEngine { get; set; }
    #endregion

    #region Constructor
    public JobTypeLogic()
    {
        JobType = new JobType();
        JobTypeEngine = unitOfWork.Repository&lt;JobType&gt;();
    }
    #endregion

    #region CRUD

    public void Add()
    {
        JobTypeEngine.Add(JobType);
    }

    public JobType Get(long id)
    {
        return JobType = JobTypeEngine.Get(id);
    }

    public void Edit()
    {
        JobTypeEngine.Edit(JobType);
    }

    public void Delete()
    {
        JobTypeEngine.Delete(JobType); 
    }

    public List&lt;JobType&gt; List()
    {
        return JobTypeEngine.List.ToList();
    }

    #endregion

}    


Class 2

public class JobLogic
{
    #region Fields
    public Job Job { get; set; }        
    public IEnumerable&lt;SelectListItem&gt; JobTypeList { get; set; }
    private UnitOfWork unitOfWork = new UnitOfWork();
    public Repository&lt;Job&gt; JobEngine;
    private Repository&lt;JobType&gt; JobTypeEngine;
    #endregion

    #region Constructor
    public JobLogic()
    {
        Job = new Job();
        JobEngine = unitOfWork.Repository&lt;Job&gt;();
        JobTypeEngine = unitOfWork.Repository&lt;JobType&gt;();
        JobTypeList = GetJobTypeList();
    }
    #endregion

    #region CRUD

    public void Add()
    {
        JobEngine.Add(Job);
    }

    public Job Get(long id)
    {
        return Job = JobEngine.Get(id);
    }

    public void Edit()
    {
        JobEngine.Edit(Job);
    }

    public void Delete()
    {
        JobEngine.Delete(Job);
    }

    public List&lt;Job&gt; List()
    {
        return JobEngine.List.ToList();
    }

    #endregion

    #region Methode

    private IEnumerable&lt;SelectListItem&gt; GetJobTypeList()
    {
        JobTypeEngine = unitOfWork.Repository&lt;JobType&gt;();   
        var jobs = JobTypeEngine.List
                    .Select(x =&gt;
                            new SelectListItem
                            {
                                Value = x.ID.ToString(),
                                Text = x.Name
                            });

        return new SelectList(jobs, "Value", "Text");
    }

    #endregion


}
This feels bad to me:

private UnitOfWork unitOfWork = new UnitOfWork();

public JobTypeLogic()
{
    JobTypeEngine = unitOfWork.Repository&lt;JobType&gt;();
}


This begs for IoC/DI, otherwise I cannot see how you'd test your code.



JobTypeEngine.List.ToList();: I don't know what's worse, that you've got a property named List, or that it apparently isn't a List at all.



public IEnumerable&lt;SelectListItem&gt; JobTypeList { get; set; }: Does a SelectListItem belong in the BLL? Why isn't that a JobType instead, and why aren't you calling it JobTypes (especially since it is an IEnumerable and not a List)?



GetJobTypeList() doesn't seem to be used. It also again assigns JobTypeEngine even though this already happened in the JobLogic constructor.