Initial commit: Lagerbestand Blazor Projekt

This commit is contained in:
spaethf committed 2026-09-21 21:28:23 +02:00
commit cba9414e92
105 files changed
+36431

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
namespace Lagerbestand.Models;
/// <summary>
/// Represents the storage area type for tire storage locations.
/// The value corresponds to position A in the location code (ABCD format).
/// </summary>
public enum AreaType
{
/// <summary>
/// Werkstatt (Gebäude 1, 3 Regalreihen) - Code prefix: 1
/// </summary>
Werkstatt = 1,
/// <summary>
/// Lager (Gebäude 2, 5 Regalreihen) - Code prefix: 2
/// </summary>
Lager = 2
}
/// <summary>
/// Extension methods for AreaType enum.
/// </summary>
public static class AreaTypeExtensions
{
/// <summary>
/// Gets the German display name for the area type.
/// </summary>
public static string GetDisplayName(this AreaType areaType) => areaType switch
{
AreaType.Lager => "Lager",
AreaType.Werkstatt => "Werkstatt",
_ => areaType.ToString()
};
/// <summary>
/// Gets the single-digit code for the area type.
/// </summary>
public static string GetCode(this AreaType areaType) => ((int)areaType).ToString();
/// <summary>
/// Gets the maximum shelf row number for the building.
/// Werkstatt (Gebäude 1) has 3 rows, Lager (Gebäude 2) has 5 rows.
/// </summary>
public static int GetMaxRow(this AreaType areaType) => areaType switch
{
AreaType.Werkstatt => 3,
AreaType.Lager => 5,
_ => 1
};
/// <summary>
/// Gets a display label including the building number (e.g., "Gebäude 1 – Werkstatt").
/// </summary>
public static string GetBuildingLabel(this AreaType areaType) =>
$"Gebäude {(int)areaType} – {areaType.GetDisplayName()}";
/// <summary>
/// Parses a code digit to AreaType.
/// </summary>
/// <param name="code">Single digit code (1 or 2)</param>
/// <returns>The corresponding AreaType</returns>
/// <exception cref="ArgumentException">If code is not valid</exception>
public static AreaType FromCode(char code) => code switch
{
'1' => AreaType.Werkstatt,
'2' => AreaType.Lager,
_ => throw new ArgumentException($"Ungültiger Bereichscode: {code}. Erlaubt: 1 (Werkstatt), 2 (Lager)", nameof(code))
};
/// <summary>
/// Tries to parse a code digit to AreaType.
/// </summary>
public static bool TryFromCode(char code, out AreaType areaType)
{
areaType = default;
if (code == '1')
{
areaType = AreaType.Werkstatt;
return true;
}
if (code == '2')
{
areaType = AreaType.Lager;
return true;
}
return false;
}
}