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

+113
View File
@@ -0,0 +1,113 @@
namespace Lagerbestand.Models;
/// <summary>
/// Represents the position within a shelf slot (side + level).
/// The value corresponds to position C in the location code (ABCD format).
/// </summary>
public enum ShelfPosition
{
/// <summary>
/// Links oben - Code: 1
/// </summary>
LinksOben = 1,
/// <summary>
/// Links unten - Code: 2
/// </summary>
LinksUnten = 2,
/// <summary>
/// Rechts oben - Code: 3
/// </summary>
RechtsOben = 3,
/// <summary>
/// Rechts unten - Code: 4
/// </summary>
RechtsUnten = 4
}
/// <summary>
/// Extension methods for ShelfPosition enum.
/// </summary>
public static class ShelfPositionExtensions
{
/// <summary>
/// Gets the German display name for the shelf position.
/// </summary>
public static string GetDisplayName(this ShelfPosition position) => position switch
{
ShelfPosition.LinksOben => "Links oben",
ShelfPosition.LinksUnten => "Links unten",
ShelfPosition.RechtsOben => "Rechts oben",
ShelfPosition.RechtsUnten => "Rechts unten",
_ => position.ToString()
};
/// <summary>
/// Gets a short display name (e.g., "L↑") for compact grid views.
/// </summary>
public static string GetShortName(this ShelfPosition position) => position switch
{
ShelfPosition.LinksOben => "L↑",
ShelfPosition.LinksUnten => "L↓",
ShelfPosition.RechtsOben => "R↑",
ShelfPosition.RechtsUnten => "R↓",
_ => position.ToString()
};
/// <summary>
/// Whether the position is on the left side of the shelf.
/// </summary>
public static bool IsLeft(this ShelfPosition position) =>
position is ShelfPosition.LinksOben or ShelfPosition.LinksUnten;
/// <summary>
/// Whether the position is on the top level of the shelf.
/// </summary>
public static bool IsTop(this ShelfPosition position) =>
position is ShelfPosition.LinksOben or ShelfPosition.RechtsOben;
/// <summary>
/// Gets the single-digit code for the position.
/// </summary>
public static string GetCode(this ShelfPosition position) => ((int)position).ToString();
/// <summary>
/// Parses a code digit to ShelfPosition.
/// </summary>
/// <param name="code">Single digit code (1-4)</param>
/// <exception cref="ArgumentException">If code is not valid</exception>
public static ShelfPosition FromCode(char code) => code switch
{
'1' => ShelfPosition.LinksOben,
'2' => ShelfPosition.LinksUnten,
'3' => ShelfPosition.RechtsOben,
'4' => ShelfPosition.RechtsUnten,
_ => throw new ArgumentException($"Ungültiger Positionscode: {code}. Erlaubt: 1-4", nameof(code))
};
/// <summary>
/// Tries to parse a code digit to ShelfPosition.
/// </summary>
public static bool TryFromCode(char code, out ShelfPosition position)
{
position = default;
if (code is < '1' or > '4')
return false;
position = (ShelfPosition)(code - '0');
return true;
}
/// <summary>
/// All shelf positions in display order.
/// </summary>
public static readonly ShelfPosition[] All =
[
ShelfPosition.LinksOben,
ShelfPosition.LinksUnten,
ShelfPosition.RechtsOben,
ShelfPosition.RechtsUnten
];
}