2022-09-30 09:40:42 -07:00

103 lines
2.5 KiB
C#

using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Transactions;
using System;
using Church.Net.DAL.EF;
using System.Linq;
using Church.Net.Utility;
using System.Threading.Tasks;
using WebAPI.Logics.Interface;
using Church.Net.DAL.EFCoreDBF;
namespace WebAPI.Logics.Core
{
public class LogicBase<T> : ICrudLogic<T> where T : class, Church.Net.Entity.Interface.IEntity, new()
{
protected readonly LogicService logicService;
protected readonly ICrudDAL<T> crudDAL;
public LogicBase(
LogicService logicService,
ICrudDAL<T> crudDAL
)
{
this.logicService = logicService;
this.crudDAL = crudDAL;
}
public virtual bool CheckExist(T obj)
{
return this.crudDAL.CheckExist(obj);
}
public virtual int Create(T entity)
{
return this.crudDAL.Create(entity);
}
public virtual Task<int> CreateAsync(T entity)
{
return this.crudDAL.CreateAsync(entity);
}
public void CreateDone(T entity)
{
}
public int CreateOrUpdate(T entity, out string id)
{
var result= this.crudDAL.CreateOrUpdate(entity);
id = entity.Id;
return result;
}
//public string CreateReturnId(T entity)
//{
// return this.crudDAL.CreateReturnId(entity);
//}
public int Delete(T obj)
{
return this.crudDAL.Delete(obj);
}
public int Delete(Func<T, bool> filter = null)
{
return this.crudDAL.Delete(filter);
}
public T First(Func<T, bool> filter = null)
{
return this.crudDAL.First(filter);
}
public IEnumerable<T> GetAll(Func<T, bool> filter = null)
{
return this.crudDAL.GetAll(filter);
}
//public IEnumerable<T> GetAllById(IEnumerable<string> Ids)
//{
// return this.crudDAL.GetAllById(Ids);
//}
public T GetById(string Id)
{
return this.crudDAL.GetById(Id);
}
public int Update(T entity)
{
return this.crudDAL.Update(entity);
}
public void UpdateDone(T entity)
{
}
public int UpdateRange(IEnumerable<T> entities)
{
return this.crudDAL.UpdateRange(entities);
}
}
}