This commit is contained in:
Zeeshaun
2026-03-17 08:54:34 -05:00
parent 64856c640e
commit cdcba54aa4
330 changed files with 54110 additions and 0 deletions
@@ -0,0 +1,69 @@
using System.Collections.Generic;
using System.Linq;
using ReserveManagementSystemLib.Models;
namespace ReserveManagementSystemUI.Helpers
{
public class GridHelpers
{
public List<Import> OrderByAscending(List<Import> imports, string sortByField)
{
return sortByField switch
{
"FileName" => imports.OrderBy(loan => loan.FileName).ToList(),
"StartDate" => imports.OrderBy(loan => loan.StartDate).ToList(),
"EndDate" => imports.OrderBy(loan => loan.EndDate).ToList(),
"RecordCount" => imports.OrderBy(loan => loan.RecordCount).ToList(),
"RecordsSaved" => imports.OrderBy(loan => loan.RecordsSaved).ToList(),
"Success" => imports.OrderBy(loan => loan.Success).ToList(),
_ => imports
};
}
public List<Import> OrderByDescending(List<Import> imports, string sortByField)
{
return sortByField switch
{
"FileName" => imports.OrderByDescending(loan => loan.FileName).ToList(),
"StartDate" => imports.OrderByDescending(loan => loan.StartDate).ToList(),
"EndDate" => imports.OrderByDescending(loan => loan.EndDate).ToList(),
"RecordCount" => imports.OrderByDescending(loan => loan.RecordCount).ToList(),
"RecordsSaved" => imports.OrderByDescending(loan => loan.RecordsSaved).ToList(),
"Success" => imports.OrderByDescending(loan => loan.Success).ToList(),
_ => imports
};
}
public List<AuditHistory> OrderByAscending(List<AuditHistory> historyData, string sortByField)
{
return sortByField switch
{
"MemberNumber" => historyData.OrderBy(history => history.MemberNumber).ToList(),
"LoanNumber" => historyData.OrderBy(history => history.LoanNumber).ToList(),
"ActivityType" => historyData.OrderBy(history => history.ActivityType).ToList(),
"OldValue" => historyData.OrderBy(history => history.OldValue).ToList(),
"NewValue" => historyData.OrderBy(history => history.NewValue).ToList(),
"ModifiedDate" => historyData.OrderBy(history => history.ModifiedDate).ToList(),
"ModifiedBy" => historyData.OrderBy(history => history.ModifiedBy).ToList(),
"Description" => historyData.OrderBy(history => history.AuditDescription).ToList(),
_ => historyData
};
}
public List<AuditHistory> OrderByDescending(List<AuditHistory> historyData, string sortByField)
{
return sortByField switch
{
"MemberNumber" => historyData.OrderByDescending(history => history.MemberNumber).ToList(),
"LoanNumber" => historyData.OrderByDescending(history => history.LoanNumber).ToList(),
"ActivityType" => historyData.OrderByDescending(history => history.ActivityType).ToList(),
"OldValue" => historyData.OrderByDescending(history => history.OldValue).ToList(),
"NewValue" => historyData.OrderByDescending(history => history.NewValue).ToList(),
"ModifiedDate" => historyData.OrderByDescending(history => history.ModifiedDate).ToList(),
"ModifiedBy" => historyData.OrderByDescending(history => history.ModifiedBy).ToList(),
"Description" => historyData.OrderByDescending(history => history.AuditDescription).ToList(),
_ => historyData
};
}
}
}
@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Serilog;
using System.Collections.Generic;
namespace ReserveManagementSystemUI.Helpers
{
public class IEHelpers
{
private IHttpContextAccessor _httpContextAccessor;
public IEHelpers(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public bool IsIE()
{
string userAgent = _httpContextAccessor.HttpContext.Request.Headers["User-Agent"];
return userAgent.Contains("MSIE") || userAgent.Contains("Trident");
}
}
}
@@ -0,0 +1,46 @@
using Microsoft.AspNetCore.Components.Authorization;
using System.Reflection;
using ReserveManagementSystemUI.Model.Configuration;
using Serilog;
namespace ReserveManagementSystemUI.Helpers
{
public class ServiceHelpers
{
private AuthenticationStateProvider _authenticationStateProvider;
private readonly RmsUIConfiguration _rmsUIConfig;
public ServiceHelpers(RmsUIConfiguration rmsUIConfig, AuthenticationStateProvider authenticationStateProvider)
{
_rmsUIConfig = rmsUIConfig;
_authenticationStateProvider = authenticationStateProvider;
}
public string GetControllerApiUrl(string apiUrl, string controller)
{
PropertyInfo propInfo = typeof(RmsUIConfiguration).GetProperty(controller);
var propValue = propInfo.GetValue(_rmsUIConfig, null);
return _rmsUIConfig.RmsApiUrl + propValue;
}
public string GetReportServerBaseUrl()
{
return _rmsUIConfig.ReportServerUrl;
}
public string GetUserName()
{
var authState = _authenticationStateProvider.GetAuthenticationStateAsync().Result;
if (authState?.User?.Identity?.Name == null)
{
Log.Error("Could not get user identity by AuthenticationState");
return "";
}
var userName = authState.User.Identity.Name;
return userName[4..];
}
}
}