50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
|
using System.Text;
|
|
|
|
namespace LCU.API.Internal.MemberPreferencesApi.Models;
|
|
|
|
public class XdiBatchFile
|
|
{
|
|
public XdiFileType Type { get; set; }
|
|
public List<XdiBatchFileRow> Data { get; set; } = new List<XdiBatchFileRow>();
|
|
public string GetFileName()
|
|
{
|
|
switch (Type)
|
|
{
|
|
case XdiFileType.AddMemberElectronic: return $"Enrollment_AddElectronic_LMCU";
|
|
case XdiFileType.UpdateMemberEmail: return $"Enrollment_UpdateEmail_LMCU";
|
|
case XdiFileType.UpdateMemberToElectronic: return $"Enrollment_UpdateToElectronic_LMCU";
|
|
case XdiFileType.UpdateMemberToPrint: return $"Enrollment_UpdateToPrint_LMCU";
|
|
default: throw new Exception($"Unknown File Type in XDI BatchFile: {Type}");
|
|
}
|
|
}
|
|
|
|
public void AddRow(string userId, string email)
|
|
{
|
|
var row = new XdiBatchFileRow()
|
|
{
|
|
UserId = $"{userId}",
|
|
Email = email
|
|
};
|
|
|
|
Data.Add(row);
|
|
}
|
|
|
|
public IEnumerable<string> ConvertToDataRows()
|
|
{
|
|
return Data.Select(batchRow => batchRow.ConvertToRow(Type));
|
|
}
|
|
|
|
public string ConvertToDataFile()
|
|
{
|
|
var allRows = ConvertToDataRows();
|
|
return string.Join("\n", allRows);
|
|
}
|
|
|
|
public bool HasRows()
|
|
{
|
|
return Data != null && Data.Any();
|
|
}
|
|
}
|
|
|