|
|
|
@ -20,13 +20,13 @@ namespace IoT.Shared.Areas.Admin.Controlls
|
|
|
|
|
where TEditModel : EditModel
|
|
|
|
|
where TSearchModel : PagedListModel<TDisplayModel>
|
|
|
|
|
{
|
|
|
|
|
private readonly IServiceProvider _applicationServices;
|
|
|
|
|
private readonly bool _isIoTCenter;
|
|
|
|
|
protected readonly IServiceProvider applicationServices;
|
|
|
|
|
protected readonly bool isIoTCenter;
|
|
|
|
|
|
|
|
|
|
public SharedController(IRepository<TEntity> repo, IServiceProvider applicationServices) : base(repo)
|
|
|
|
|
{
|
|
|
|
|
this._applicationServices = applicationServices;
|
|
|
|
|
this._isIoTCenter = Assembly.GetEntryAssembly().GetName().Name.Contains("IoTCenter");
|
|
|
|
|
this.applicationServices = applicationServices;
|
|
|
|
|
this.isIoTCenter = Assembly.GetEntryAssembly().GetName().Name.Contains("IoTCenter");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IActionResult Add(TEditModel model)
|
|
|
|
@ -41,8 +41,8 @@ namespace IoT.Shared.Areas.Admin.Controlls
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var method = $"Edit{typeof(TEntity).Name}";
|
|
|
|
|
using var scope = this._applicationServices.CreateScope();
|
|
|
|
|
if (this._isIoTCenter)
|
|
|
|
|
using var scope = this.applicationServices.CreateScope();
|
|
|
|
|
if (this.isIoTCenter)
|
|
|
|
|
{
|
|
|
|
|
var group = this.GetNodeNumber(model);
|
|
|
|
|
this.ToEntity(model, null);
|
|
|
|
@ -75,8 +75,8 @@ namespace IoT.Shared.Areas.Admin.Controlls
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var method = $"Delete{typeof(TEntity).Name}";
|
|
|
|
|
using var scope = this._applicationServices.CreateScope();
|
|
|
|
|
if (this._isIoTCenter)
|
|
|
|
|
using var scope = this.applicationServices.CreateScope();
|
|
|
|
|
if (this.isIoTCenter)
|
|
|
|
|
{
|
|
|
|
|
var query = this._repo.ReadOnlyTable();
|
|
|
|
|
query = this.Include(query);
|
|
|
|
|