Church.Net.API/Chruch.Net.BLL.Core/BussinessLogicBase.cs
2022-09-08 08:04:32 -07:00

78 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using PagedList;
namespace Church.Net.BLL.Core
{
public class BussinessLogicBase<T> : IBussinessLogic<T> where T : class
{
DAL.Core.IRepository<T> DAL { get; set; }
public BussinessLogicBase(string connString)
{
DAL = new RepositoryBase<T>(connString);
}
public void Add(T obj)
{
DAL.Add(obj);
}
public void Edit(T obj)
{
DAL.Edit(obj);
}
public void Delete(T obj)
{
DAL.Delete(obj);
}
public void Delete(string id)
{
throw new NotImplementedException();
}
public T GetSingle(Expression<Func<T, bool>> whereCondition)
{
return DAL.GetSingle(whereCondition);
}
public PagedList<T> GetPagedList(int page, int itemPerPage)
{
var list = DAL.GetQueryable().Skip(page - 1).Take(itemPerPage);
PagedList<T> result = new PagedList<T>(list,page, itemPerPage);
return result;
}
public PagedList<T> GetPagedList(int page, int itemPerPage,Expression<Func<T, bool>> whereCondition)
{
throw new NotImplementedException();
}
public PagedList<T> GetPagedList<TKey>(int page, int itemPerPage, Expression<Func<T, bool>> whereCondition, Expression<Func<T, TKey>> orderCondition)
{
var list = DAL.GetQueryable(whereCondition).OrderBy(orderCondition).Skip(page - 1).Take(itemPerPage);
throw new NotImplementedException();
}
public IList<T> GetAll()
{
throw new NotImplementedException();
}
public IList<T> GetAll(Expression<Func<T, bool>> whereCondition)
{
var list = DAL.GetQueryable(whereCondition);
return list.ToList();
}
}
}