28 lines
771 B
C#
28 lines
771 B
C#
using System;
|
|
using System.Text.RegularExpressions;
|
|
using LeafWeb.Core.Entities;
|
|
using LeafWeb.Core.Utility;
|
|
|
|
namespace LeafWeb.Core.Remote
|
|
{
|
|
public static class PiscalUtility
|
|
{
|
|
public static string GetPiscalDirectoryName(int id, string identifier)
|
|
{
|
|
return $"{id}_{identifier.FilterAlphaNumeric()}";
|
|
}
|
|
|
|
public static string GetPiscalDirectoryName(LeafInput leafInput)
|
|
{
|
|
return GetPiscalDirectoryName(leafInput.Id, leafInput.Identifier);
|
|
}
|
|
|
|
public static int GetIdFromDirectoryName(string directoryName)
|
|
{
|
|
var match = Regex.Match(directoryName, @"\d_");
|
|
if (!match.Success)
|
|
throw new FormatException("DirectoryName expected to be formatted {number}_{identifier}: " + directoryName);
|
|
return int.Parse(match.Captures[0].Value);
|
|
}
|
|
}
|
|
} |