using AyCode.Core.Enums;

namespace AyCode.Services.SignalRs;

public sealed class SignalRCrudTags(int getAllTag, int getItemTag, int addTag, int updateTag, int removeTag)
{
    public int GetAllMessageTag { get; } = getAllTag;
    public int GetItemMessageTag { get; } = getItemTag;
    public int AddMessageTag { get; } = addTag;
    public int UpdateMessageTag { get; } = updateTag;
    public int RemoveMessageTag { get; } = removeTag;

    public int GetMessageTagByTrackingState(TrackingState trackingState)
    {
        return trackingState switch
        {
            TrackingState.None => 0,
            TrackingState.Get => GetItemMessageTag,
            TrackingState.GetAll => GetAllMessageTag,
            TrackingState.Add => AddMessageTag,
            TrackingState.Update => UpdateMessageTag,
            TrackingState.Remove => RemoveMessageTag,
            _ => throw new ArgumentOutOfRangeException()
        };
    }
}