/*******************************BaseService****************************************/
using Company.IBLL;
using Company.IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace Company.BLL
{
public abstract class BaseService<T> : IBaseService<T> where T : class, new()
{
public BaseService()
{
SetDAL();
}
public abstract void SetDAL();
public IBaseDAL<T> Dal { get; set; }
public bool Add(T t)
{
Dal.Add(t);
return Dal.SaveChanges();
}
public bool Delete(T t)
{
Dal.Delete(t);
return Dal.SaveChanges();
}
public IQueryable<T> GetModels(Expression<Func<T, bool>> whereLambda)
{
return Dal.GetModels(whereLambda);
}
public IQueryable<T> GetModelsByPage<type>(int pageIndex, int pageSize, bool isAsc, Expression<Func<T, type>> orderLambda, Expression<Func<T, bool>> whereLambda)
{
return Dal.GetModelsByPage<type>(pageIndex, pageSize, isAsc, orderLambda, whereLambda);
}
public bool Update(T t)
{
Dal.Update(t);
return Dal.SaveChanges();
}
}
}
/**********************************StaffService******************************************/
using Company.DAL;
using Company.IBLL;
using Company.IDAL;
using Company.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Company.BLL
{
public class StaffService : BaseService<Staff>,IStaffService
{
private IStaffDAL staffDAL = new StaffDAL();
public override void SetDAL()
{
Dal = staffDAL;
}
}
}