refactor: Entfernte DbContext und Hilfsklassen, die durch 'new' generiert wurden, und injiziert. Testprojekt aufgrund von Generierungsfehlern entfernt.
This commit is contained in:
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class AdWebAppToWebAppRoleRepository : BaseRepository<AdWebAppToWebAppRole>
|
||||
{
|
||||
public AdWebAppToWebAppRoleRepository() : base(new WebApiContext())
|
||||
public AdWebAppToWebAppRoleRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class CostCentreRepository : BaseRepository<CostCentre>
|
||||
{
|
||||
public CostCentreRepository() : base(new WebApiContext())
|
||||
public CostCentreRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class DepartmentRepository : BaseRepository<Department>
|
||||
{
|
||||
public DepartmentRepository() : base(new WebApiContext())
|
||||
public DepartmentRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class DepartmentToWebAppToEmployeeForWindreamRepository : BaseRepository<DepartmentToWebAppToEmployeeForWindream>
|
||||
{
|
||||
public DepartmentToWebAppToEmployeeForWindreamRepository() : base(new WebApiContext())
|
||||
public DepartmentToWebAppToEmployeeForWindreamRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class DocumentArtRepository : BaseRepository<DocumentArt>
|
||||
{
|
||||
public DocumentArtRepository() : base(new WebApiContext())
|
||||
public DocumentArtRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class DocumentArtToDepartmentRepository : BaseRepository<DocumentArtToDepartment>
|
||||
{
|
||||
public DocumentArtToDepartmentRepository() : base(new WebApiContext())
|
||||
public DocumentArtToDepartmentRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeAttributeRepository : BaseRepository<EmployeeAttribute>
|
||||
{
|
||||
public EmployeeAttributeRepository() : base(new WebApiContext())
|
||||
public EmployeeAttributeRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeRepository : BaseRepository<Employee>
|
||||
{
|
||||
public EmployeeRepository() : base(new WebApiContext())
|
||||
public EmployeeRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeStatusRepository : BaseRepository<EmployeeStatus>
|
||||
{
|
||||
public EmployeeStatusRepository() : base(new WebApiContext())
|
||||
public EmployeeStatusRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeToAttributeRepository : BaseRepository<EmployeeToAttribute>
|
||||
{
|
||||
public EmployeeToAttributeRepository() : base(new WebApiContext())
|
||||
public EmployeeToAttributeRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeToDepartmentRepository : BaseRepository<EmployeeToDepartment>
|
||||
{
|
||||
public EmployeeToDepartmentRepository() : base(new WebApiContext())
|
||||
public EmployeeToDepartmentRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeToWebAppRepository : BaseRepository<EmployeeToWebApp>
|
||||
{
|
||||
public EmployeeToWebAppRepository() : base(new WebApiContext())
|
||||
public EmployeeToWebAppRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class ProjectRepository : BaseRepository<Project>
|
||||
{
|
||||
public ProjectRepository() : base(new WebApiContext())
|
||||
public ProjectRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class RangRepository : BaseRepository<Rang>
|
||||
{
|
||||
public RangRepository() : base(new WebApiContext())
|
||||
public RangRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class SubsidiaryRepository : BaseRepository<Subsidiary>
|
||||
{
|
||||
public SubsidiaryRepository() : base(new WebApiContext())
|
||||
public SubsidiaryRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppAdditionalRoleRepository : BaseRepository<WebAppAdditionalRole>
|
||||
{
|
||||
public WebAppAdditionalRoleRepository() : base(new WebApiContext())
|
||||
public WebAppAdditionalRoleRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppRepository : BaseRepository<WebApp>
|
||||
{
|
||||
public WebAppRepository() : base(new WebApiContext())
|
||||
public WebAppRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppRoleRepository : BaseRepository<WebAppRole>
|
||||
{
|
||||
public WebAppRoleRepository() : base(new WebApiContext())
|
||||
public WebAppRoleRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppToDepartmentRepository : BaseRepository<WebAppToDepartment>
|
||||
{
|
||||
public WebAppToDepartmentRepository() : base(new WebApiContext())
|
||||
public WebAppToDepartmentRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppToWebAppAdditionalRoleRepository : BaseRepository<WebAppToWebAppAdditionalRole>
|
||||
{
|
||||
public WebAppToWebAppAdditionalRoleRepository() : base(new WebApiContext())
|
||||
public WebAppToWebAppAdditionalRoleRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppToWebAppRoleRepository : BaseRepository<WebAppToWebAppRole>
|
||||
{
|
||||
public WebAppToWebAppRoleRepository() : base(new WebApiContext())
|
||||
public WebAppToWebAppRoleRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamColumnsToDepartmentRepository : BaseRepository<WindreamColumnsToDepartment>
|
||||
{
|
||||
public WindreamColumnsToDepartmentRepository() : base(new WebApiContext())
|
||||
public WindreamColumnsToDepartmentRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamIndexRepository : BaseRepository<WindreamIndex>
|
||||
{
|
||||
public WindreamIndexRepository() : base(new WebApiContext())
|
||||
public WindreamIndexRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamIndexToWindreamSearchToDepartmentRepository : BaseRepository<WindreamIndexToWindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamIndexToWindreamSearchToDepartmentRepository() : base(new WebApiContext())
|
||||
public WindreamIndexToWindreamSearchToDepartmentRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamInputFolderRepository : BaseRepository<WindreamInputFolder>
|
||||
{
|
||||
public WindreamInputFolderRepository() : base(new WebApiContext())
|
||||
public WindreamInputFolderRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchItemRepository : BaseRepository<WindreamSearchItem>
|
||||
{
|
||||
public WindreamSearchItemRepository() : base(new WebApiContext())
|
||||
public WindreamSearchItemRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchItemToWindreamSearchToDepartmentRepository : BaseRepository<WindreamSearchItemToWindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamSearchItemToWindreamSearchToDepartmentRepository() : base(new WebApiContext())
|
||||
public WindreamSearchItemToWindreamSearchToDepartmentRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchRepository : BaseRepository<WindreamSearch>
|
||||
{
|
||||
public WindreamSearchRepository() : base(new WebApiContext())
|
||||
public WindreamSearchRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchToDepartmentRepository : BaseRepository<WindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamSearchToDepartmentRepository() : base(new WebApiContext())
|
||||
public WindreamSearchToDepartmentRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,6 @@ namespace DAL
|
||||
{
|
||||
public partial class WebApiContext : WebApiBaseContext
|
||||
{
|
||||
public WebApiContext() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public WebApiContext(DbContextOptions<DbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace DAL._Shared.SharedRepositories
|
||||
public class WebAppEmployeeInfoRepository : BaseRepository<WebAppEmployeeInfo>
|
||||
|
||||
{
|
||||
public WebAppEmployeeInfoRepository() : base(new WebApiContext())
|
||||
public WebAppEmployeeInfoRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace DAL._Shared.SharedRepositories
|
||||
{
|
||||
public class WebAppUserRepository : BaseRepository<WebAppUser>
|
||||
{
|
||||
public WebAppUserRepository() : base(new WebApiContext())
|
||||
public WebAppUserRepository(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace StaffDBServer.SharedExtensions
|
||||
[ApiController]
|
||||
public class InfoController : InfoBaseController
|
||||
{
|
||||
public InfoController() : base(new WebApiContext())
|
||||
public InfoController(WebApiContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,13 @@ namespace StaffDBServer.SharedControllers
|
||||
[JWTAuthorizeAttribute]
|
||||
public class WebAppUserController : BaseMiniController
|
||||
{
|
||||
public WebAppUserController() : base(new WebApiContext())
|
||||
private readonly WebAppUserRepository webAppUserRepository;
|
||||
WebAppUserHelper webAppUserHelper;
|
||||
|
||||
public WebAppUserController(WebApiContext context, WebAppUserRepository webAppUserRepository, WebAppUserHelper webAppUserHelper) : base(context)
|
||||
{
|
||||
this.webAppUserRepository = webAppUserRepository;
|
||||
this.webAppUserHelper = webAppUserHelper;
|
||||
}
|
||||
|
||||
[HttpPost("Culture")]
|
||||
@@ -23,8 +28,6 @@ namespace StaffDBServer.SharedControllers
|
||||
{
|
||||
try
|
||||
{
|
||||
//User Should by in the DB
|
||||
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
|
||||
WebAppUser userFromDB = await webAppUserRepository.GetByAsync(u => u.LoginName == userFromClient.LoginName, false);
|
||||
|
||||
if (userFromDB != default) //first login, get User from WebAppEmployeeInfo
|
||||
@@ -51,7 +54,7 @@ namespace StaffDBServer.SharedControllers
|
||||
try
|
||||
{
|
||||
var accessToken = Request.Headers[HeaderNames.Authorization];
|
||||
WebAppUserHelper webAppUserHelper = new WebAppUserHelper();
|
||||
|
||||
WebAppUser result = await webAppUserHelper.CheckLoginWithJWTAsync(accessToken, userFromClient.ClientVersion);
|
||||
return new OkObjectResult(result);
|
||||
}
|
||||
@@ -67,8 +70,7 @@ namespace StaffDBServer.SharedControllers
|
||||
public async Task<IActionResult> LoginWithNameAndPasswordAsync([FromBody] WebAppUser userFromClient, int webApiId)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebAppUserHelper webAppUserHelper = new WebAppUserHelper();
|
||||
{
|
||||
var result = await webAppUserHelper.CheckLoginWithNameAndPasswordAsync(userFromClient, webApiId);
|
||||
return new OkObjectResult(result);
|
||||
}
|
||||
@@ -85,7 +87,6 @@ namespace StaffDBServer.SharedControllers
|
||||
{
|
||||
try
|
||||
{
|
||||
WebAppUserHelper webAppUserHelper = new WebAppUserHelper();
|
||||
var result = await webAppUserHelper.CheckLoginWithNameAndPasswordAsync(userFromClient);
|
||||
return new OkObjectResult(result);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,18 @@ namespace StaffDBServer.SharedControllers
|
||||
|
||||
public int GlbWebApiIdStaffDB { get; private set; } = 2;
|
||||
|
||||
public async Task<WebAppUser> CheckLoginWithJWTAsync(StringValues accessToken, string clientVersion)
|
||||
WebAppUserRepository webAppUserRepository;
|
||||
|
||||
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository;
|
||||
|
||||
public WebAppUserHelper(WebAppUserRepository webAppUserRepository, WebAppEmployeeInfoRepository webAppEmployeeInfoRepository)
|
||||
{
|
||||
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
|
||||
this.webAppUserRepository = webAppUserRepository;
|
||||
this.webAppEmployeeInfoRepository = webAppEmployeeInfoRepository;
|
||||
}
|
||||
|
||||
public async Task<WebAppUser> CheckLoginWithJWTAsync(StringValues accessToken, string clientVersion)
|
||||
{
|
||||
if (!JwtManager.IsValidatJwtTokenSubject(accessToken))
|
||||
{
|
||||
throw new UnauthorizedAccessException($"Not valid JWT");
|
||||
@@ -27,8 +36,7 @@ namespace StaffDBServer.SharedControllers
|
||||
{
|
||||
throw new UnauthorizedAccessException($"Unable to decrypt JWT");
|
||||
}
|
||||
|
||||
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository = new WebAppEmployeeInfoRepository();
|
||||
|
||||
WebAppEmployeeInfo webAppEmployeeInfo = await webAppEmployeeInfoRepository.GetByAsync(x => x.LoginName == ldapUser.LoginName);
|
||||
if (webAppEmployeeInfo == default)
|
||||
{
|
||||
@@ -63,10 +71,9 @@ namespace StaffDBServer.SharedControllers
|
||||
public async Task<WebAppUser> CheckLoginWithNameAndPasswordAsync(WebAppUser userFromClient, int webAppId)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository = new WebAppEmployeeInfoRepository();
|
||||
{
|
||||
WebAppEmployeeInfo webAppEmployeeInfo = await webAppEmployeeInfoRepository.GetByAsync(x => x.LoginName == userFromClient.LoginName && x.WebAppId == webAppId);
|
||||
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
|
||||
|
||||
return await DoCheckLoginWithNameAndPasswordAsync(userFromClient, webAppUserRepository, webAppEmployeeInfoRepository);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -79,9 +86,8 @@ namespace StaffDBServer.SharedControllers
|
||||
{
|
||||
try
|
||||
{
|
||||
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository = new WebAppEmployeeInfoRepository();
|
||||
WebAppEmployeeInfo webAppEmployeeInfo = await webAppEmployeeInfoRepository.GetByAsync(x => x.LoginName == userFromClient.LoginName && x.WebAppId == GlbWebApiIdStaffDB);
|
||||
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
|
||||
|
||||
return await DoCheckLoginWithNameAndPasswordAsync(userFromClient, webAppUserRepository, webAppEmployeeInfoRepository);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user