Moved System.IO references from DMO classes to Static Helpers

Removed nugetSource from pipeline
Removed more comments
Created Static Classes for most DMO / Controller Classes
Push ConfigurationManager.AppSettings to controller
Align Tests with other Projects
This commit is contained in:
2024-12-11 09:29:01 -07:00
parent b1c6903c1c
commit b99b721458
86 changed files with 2961 additions and 4432 deletions

View File

@ -71,8 +71,6 @@ public class AdminDMO {
if (!lookup.TryGetValue(parent.RoleID, out role)) {
lookup.Add(parent.RoleID, role = parent);
}
//if (role.RoleID == null)
// role.SubRoles = new List<SubRole>();
role.SubRoles.Add(child);
return role;
},
@ -80,7 +78,7 @@ public class AdminDMO {
return data;
}
///
public List<UserSubRoles> GetUserSubRoles(int userId) {
DynamicParameters parameters = new();
parameters.Add("@UserId", userId);
@ -130,14 +128,17 @@ public class AdminDMO {
}
}
#if !NET8
public List<TrainingReportUser> GetTrainingReportUsers() {
List<TrainingReportUser> CurrentReportUsers = (from a in FabApprovalDB.TrainingReportUsers select a).ToList();
return CurrentReportUsers;
}
#else
public List<TrainingReportUser> GetTrainingReportUsers() => throw new NotImplementedException();
public List<TrainingReportUser> GetTrainingReportUsers() =>
throw new NotImplementedException();
#endif
#if !NET8
public List<TECNNotificationsUser> GetTECNNotificationUsers() {
List<TECNNotificationsUser> currentTECNNotificationUsers = (from a in FabApprovalDB.TECNNotificationsUsers select a).ToList();
@ -164,8 +165,6 @@ public class AdminDMO {
public void TrainingReportDeleteUser(int userId) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@UserID", userId);
db.Execute("DeleteUserFromTrainingReport", parameters, commandType: CommandType.StoredProcedure);
@ -174,25 +173,14 @@ public class AdminDMO {
public void TECNExpirationDeleteUser(int userId) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@UserID", userId);
db.Execute("DeleteUserFromTECNReport", parameters, commandType: CommandType.StoredProcedure);
return;
}
#if !NET8
public List<TrainingGroup> GetTrainingGroups() {
//StringBuilder sql = new StringBuilder();
//sql.Append(
// "SELECT 'TrainingGroupID', TrainingGroupName " +
// "FROM TrainingGroups " +
// "ORDER BY TrainingGroupID ");
//db.Open();
//var lookup = new Dictionary<int, TrainingGroup>();
////List<TrainingGroup> data = this.db.Query<TrainingGroup>(sql.ToString()
//return this.db.Query<TrainingGroup>(sql.ToString()).ToList();
var TrainingGroups = from a in FabApprovalDB.TrainingGroups select a;
List<TrainingGroup> GroupsToReturn = TrainingGroups.ToList();
@ -201,16 +189,14 @@ public class AdminDMO {
public void AddNewTrainingGroup(string groupName) {
TrainingGroup existing = null;
//Check to see that the group name doesn't exist.
// Check to see that the group name doesn't exist.
try {
existing = (from a in FabApprovalDB.TrainingGroups where a.TrainingGroupName == groupName select a).FirstOrDefault();
} catch {
// string test = "";
}
if (existing == null) {
//string sql = new StringBuilder();
string sql = "INSERT INTO TrainingGroups (TrainingGroupName) " + "VALUES ('" + groupName + "') ";
this.db.Open();
@ -234,6 +220,7 @@ public class AdminDMO {
} catch {
}
}
#if !NET8
public List<TrainingGroupMember> GetTrainingGroupMembers(int GroupID) {
return (from a in FabApprovalDB.TrainingGroupMembers where a.TrainingGroupID == GroupID select a).ToList();
@ -259,34 +246,10 @@ public class AdminDMO {
throw new Exception("The user already exists in this training group.");
}
//if (existing == null)
//{
// //string sql = new StringBuilder();
// string sql = "INSERT INTO TrainingGroupMembers (TrainingGroupID, UserID, FullName) " + "VALUES ('" + groupId + "','" + userId + "','" + userFullName + "') ";
// try
// {
// this.db.Open();
// this.db.Execute(sql);
// }
// catch(Exception e)
// {
// return;
// }
// return;
//}
//else
//{
// return;
}
#endif
public void DeleteFromGroup(int userId, int groupId) {
DynamicParameters parameters = new();
parameters = new DynamicParameters();
parameters.Add("@GroupID", groupId);
parameters.Add("@UserID", userId);
@ -298,35 +261,35 @@ public class AdminDMO {
public void DeleteUser(UserAccountDMO userDMO, TrainingDMO trainingDMO, LoginModel loginModel) {
if (loginModel != null) {
userDMO.DeleteUser(loginModel);
//Remove open trainings
//Get a list of all user assigned trainings.
// Remove open trainings
// Get a list of all user assigned trainings.
List<TrainingAssignment> trainingAssignments = trainingDMO.GetTrainingAssignmentsByUserID(loginModel.UserID);
//Go Through that list.
// Go Through that list.
foreach (var trainingAssignment in trainingAssignments) {
//Delete Any document acknowledgements.
// Delete Any document acknowledgements.
trainingDMO.DeleteTrainingDocAck(trainingAssignment.ID);
//Delete the training assignment itself
// Delete the training assignment itself
trainingDMO.DeleteTrainingAssignment(trainingAssignment.ID);
//Check the parent Training task to set to to complete if applicable.
// Check the parent Training task to set to to complete if applicable.
if (trainingDMO.CheckTrainingStatus(trainingAssignment.ID)) {
int TrainingID = trainingAssignment.TrainingID;
//Set Training status to complete
// Set Training status to complete
trainingDMO.UpdateTrainingStatus(TrainingID);
}
}
//Remove user from any Training Groups
// Remove user from any Training Groups
DeleteUserFromAllTrainingGroups(loginModel.UserID);
//Remove User from training report notifications
// Remove User from training report notifications
TrainingReportDeleteUser(loginModel.UserID);
//Remove user from TECN Expiration Notifications
// Remove user from TECN Expiration Notifications
TECNExpirationDeleteUser(loginModel.UserID);
//Get user subroles
// Get user subroles
List<UserSubRoles> userSubRoles = GetUserSubRoles(loginModel.UserID);
//Delete user from any subroles
// Delete user from any subroles
foreach (var userSubRole in userSubRoles) {
DeleteUserRoles(userSubRole.SubRoleID, loginModel.UserID.ToString());
}