Update API
This commit is contained in:
@@ -13,8 +13,8 @@ namespace WebAPI.Logics.Core
|
||||
{
|
||||
public class LogicBase<T> : ICrudLogic<T> where T : class, Church.Net.Entity.Interface.IEntity, new()
|
||||
{
|
||||
private readonly LogicService logicService;
|
||||
private readonly ICrudDAL<T> crudDAL;
|
||||
protected readonly LogicService logicService;
|
||||
protected readonly ICrudDAL<T> crudDAL;
|
||||
|
||||
public LogicBase(
|
||||
LogicService logicService,
|
||||
@@ -46,15 +46,15 @@ namespace WebAPI.Logics.Core
|
||||
|
||||
public int CreateOrUpdate(T entity, out string id)
|
||||
{
|
||||
var result= this.crudDAL.CreateOrUpdate(entity, out string _id);
|
||||
id = _id;
|
||||
var result= this.crudDAL.CreateOrUpdate(entity);
|
||||
id = entity.Id;
|
||||
return result;
|
||||
}
|
||||
|
||||
public string CreateReturnId(T entity)
|
||||
{
|
||||
return this.crudDAL.CreateReturnId(entity);
|
||||
}
|
||||
//public string CreateReturnId(T entity)
|
||||
//{
|
||||
// return this.crudDAL.CreateReturnId(entity);
|
||||
//}
|
||||
|
||||
public int Delete(T obj)
|
||||
{
|
||||
@@ -75,10 +75,10 @@ namespace WebAPI.Logics.Core
|
||||
return this.crudDAL.GetAll(filter);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetAllById(IEnumerable<string> Ids)
|
||||
{
|
||||
return this.crudDAL.GetAllById(Ids);
|
||||
}
|
||||
//public IEnumerable<T> GetAllById(IEnumerable<string> Ids)
|
||||
//{
|
||||
// return this.crudDAL.GetAllById(Ids);
|
||||
//}
|
||||
|
||||
public T GetById(string Id)
|
||||
{
|
||||
|
||||
@@ -1,16 +1,33 @@
|
||||
using Church.Net.DAL.EF;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using WebAPI.Services;
|
||||
|
||||
namespace WebAPI.Logics.Core
|
||||
{
|
||||
public class LogicService
|
||||
{
|
||||
private readonly IServiceScopeFactory serviceScopeFactory;
|
||||
|
||||
public LogicService(
|
||||
ChurchNetContext dbContext
|
||||
//ChurchNetContext dbContext
|
||||
IServiceScopeFactory serviceScopeFactory
|
||||
)
|
||||
{
|
||||
DbContext = dbContext;
|
||||
this.serviceScopeFactory = serviceScopeFactory;
|
||||
//DbContext = dbContext;
|
||||
}
|
||||
|
||||
public ChurchNetContext DbContext { get; }
|
||||
//public ChurchNetContext DbContext { get; }
|
||||
public string CurrentUserId
|
||||
{
|
||||
get
|
||||
{
|
||||
using (var scope = serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var service = scope.ServiceProvider.GetService<IdentityService>();
|
||||
return service.UserId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user