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

@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using Dapper;
@ -13,12 +12,8 @@ namespace Fab2ApprovalSystem.DMO;
public class PartsRequestDMO {
private readonly AppSettings _AppSettings;
private readonly IDbConnection db = new SqlConnection(GlobalVars.DB_CONNECTION_STRING);
public PartsRequestDMO(AppSettings appSettings) =>
_AppSettings = appSettings;
public IEnumerable<PartsRequestList> GetPartsRequestList() {
List<PartsRequestList> r = db.Query<PartsRequestList>("PartsRequestGetList", commandType: CommandType.StoredProcedure).ToList();
return r;
@ -114,28 +109,4 @@ public class PartsRequestDMO {
db.Execute("PartsRequestDelete", parameters, commandType: CommandType.StoredProcedure);
}
public void AttachSave(int prNumber, int userId, string fullFileName, Stream stream) {
// Some browsers send file names with full path.
// We are only interested in the file name.
var fileName = Path.GetFileName(fullFileName);
string prFolderPath = _AppSettings.AttachmentFolder + "PartsRequest\\" + prNumber.ToString();
DirectoryInfo di = new(prFolderPath);
if (!di.Exists)
di.Create();
var physicalPath = Path.Combine(prFolderPath, fileName);
using (FileStream fileStream = new(physicalPath, FileMode.Create, FileAccess.Write)) {
stream.CopyTo(fileStream);
}
PartsRequestAttachment attach = new() {
PRNumber = prNumber,
FileName = fileName,
UserID = userId,
};
InsertAttachment(attach);
}
}