ensure form name is unique in ActionDialog
This commit is contained in:
		| @ -11,12 +11,5 @@ namespace [Owner].Module.[Module].Repository | ||||
|         Models.[Module] Add[Module](Models.[Module] [Module]); | ||||
|         Models.[Module] Update[Module](Models.[Module] [Module]); | ||||
|         void Delete[Module](int [Module]Id); | ||||
|  | ||||
|         Task<IEnumerable<Models.[Module]>> Get[Module]sAsync(int ModuleId); | ||||
|         Task<Models.[Module]> Get[Module]Async(int [Module]Id); | ||||
|         Task<Models.[Module]> Get[Module]Async(int [Module]Id, bool tracking); | ||||
|         Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module]); | ||||
|         Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module]); | ||||
|         Task Delete[Module]Async(int [Module]Id); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore; | ||||
| using System.Linq; | ||||
| using System.Collections.Generic; | ||||
| using Oqtane.Modules; | ||||
| using System.Threading.Tasks; | ||||
|  | ||||
| namespace [Owner].Module.[Module].Repository | ||||
| { | ||||
| @ -62,54 +61,5 @@ namespace [Owner].Module.[Module].Repository | ||||
|             db.[Module].Remove([Module]); | ||||
|             db.SaveChanges(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public async Task<IEnumerable<Models.[Module]>> Get[Module]sAsync(int ModuleId) | ||||
|         { | ||||
|             using var db = _factory.CreateDbContext(); | ||||
|             return await db.[Module].Where(item => item.ModuleId == ModuleId).ToListAsync(); | ||||
|         } | ||||
|  | ||||
|         public async Task<Models.[Module]> Get[Module]Async(int [Module]Id) | ||||
|         { | ||||
|             return await Get[Module]Async([Module]Id, true); | ||||
|         } | ||||
|  | ||||
|         public async Task<Models.[Module]> Get[Module]Async(int [Module]Id, bool tracking) | ||||
|         { | ||||
|             using var db = _factory.CreateDbContext(); | ||||
|             if (tracking) | ||||
|             { | ||||
|                 return await db.[Module].FindAsync([Module]Id); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 return await db.[Module].AsNoTracking().FirstOrDefaultAsync(item => item.[Module]Id == [Module]Id); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public async Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module]) | ||||
|         { | ||||
|             using var db = _factory.CreateDbContext(); | ||||
|             db.[Module].Add([Module]); | ||||
|             await db.SaveChangesAsync(); | ||||
|             return [Module]; | ||||
|         } | ||||
|  | ||||
|         public async Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module]) | ||||
|         { | ||||
|             using var db = _factory.CreateDbContext(); | ||||
|             db.Entry([Module]).State = EntityState.Modified; | ||||
|             await db.SaveChangesAsync(); | ||||
|             return [Module]; | ||||
|         } | ||||
|  | ||||
|         public async Task Delete[Module]Async(int [Module]Id) | ||||
|         { | ||||
|             using var db = _factory.CreateDbContext(); | ||||
|             Models.[Module] [Module] = db.[Module].Find([Module]Id); | ||||
|             db.[Module].Remove([Module]); | ||||
|             await db.SaveChangesAsync(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -29,11 +29,11 @@ namespace [Owner].Module.[Module].Services | ||||
|             _alias = tenantManager.GetAlias(); | ||||
|         } | ||||
|  | ||||
|         public async Task<List<Models.[Module]>> Get[Module]sAsync(int ModuleId) | ||||
|         public Task<List<Models.[Module]>> Get[Module]sAsync(int ModuleId) | ||||
|         { | ||||
|             if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View)) | ||||
|             { | ||||
|                 return (await _[Module]Repository.Get[Module]sAsync(ModuleId)).ToList(); | ||||
|                 return Task.FromResult(_[Module]Repository.Get[Module]s(ModuleId).ToList()); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
| @ -42,11 +42,11 @@ namespace [Owner].Module.[Module].Services | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public async Task<Models.[Module]> Get[Module]Async(int [Module]Id, int ModuleId) | ||||
|         public Task<Models.[Module]> Get[Module]Async(int [Module]Id, int ModuleId) | ||||
|         { | ||||
|             if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View)) | ||||
|             { | ||||
|                 return await _[Module]Repository.Get[Module]Async([Module]Id); | ||||
|                 return Task.FromResult(_[Module]Repository.Get[Module]([Module]Id)); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
| @ -55,11 +55,11 @@ namespace [Owner].Module.[Module].Services | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public async Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module]) | ||||
|         public Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module]) | ||||
|         { | ||||
|             if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, [Module].ModuleId, PermissionNames.Edit)) | ||||
|             { | ||||
|                 [Module] = await _[Module]Repository.Add[Module]Async([Module]); | ||||
|                 [Module] = _[Module]Repository.Add[Module]([Module]); | ||||
|                 _logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]); | ||||
|             } | ||||
|             else | ||||
| @ -67,14 +67,14 @@ namespace [Owner].Module.[Module].Services | ||||
|                 _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Add Attempt {[Module]}", [Module]); | ||||
|                 [Module] = null; | ||||
|             } | ||||
|             return [Module]; | ||||
|             return Task.FromResult([Module]); | ||||
|         } | ||||
|  | ||||
|         public async Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module]) | ||||
|         public Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module]) | ||||
|         { | ||||
|             if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, [Module].ModuleId, PermissionNames.Edit)) | ||||
|             { | ||||
|                 [Module] = await _[Module]Repository.Update[Module]Async([Module]); | ||||
|                 [Module] = _[Module]Repository.Update[Module]([Module]); | ||||
|                 _logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]); | ||||
|             } | ||||
|             else | ||||
| @ -82,20 +82,21 @@ namespace [Owner].Module.[Module].Services | ||||
|                 _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Update Attempt {[Module]}", [Module]); | ||||
|                 [Module] = null; | ||||
|             } | ||||
|             return [Module]; | ||||
|             return Task.FromResult([Module]); | ||||
|         } | ||||
|  | ||||
|         public async Task Delete[Module]Async(int [Module]Id, int ModuleId) | ||||
|         public Task Delete[Module]Async(int [Module]Id, int ModuleId) | ||||
|         { | ||||
|             if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit)) | ||||
|             { | ||||
|                 await _[Module]Repository.Delete[Module]Async([Module]Id); | ||||
|                 _[Module]Repository.Delete[Module]([Module]Id); | ||||
|                 _logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", [Module]Id); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Delete Attempt {[Module]Id} {ModuleId}", [Module]Id, ModuleId); | ||||
|             } | ||||
|             return Task.CompletedTask; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 sbwalker
					sbwalker