blob: 34b2de36d2d11e44be80edfbaba4a8c2ee8b4bfc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
namespace Enmarcha.Backend.Data.Models;
/// <summary>
/// Defines the scope of an alert (e.g., "stop#vitrasa:1400", "route#xunta:123").
/// This follows a URI-like pattern for easy parsing and matching.
/// </summary>
public class AlertSelector
{
public string Raw { get; set; } = string.Empty;
public string Type => Raw.Split('#').FirstOrDefault() ?? string.Empty;
public string Id => Raw.Split('#').ElementAtOrDefault(1) ?? string.Empty;
public static AlertSelector FromStop(string feedId, string stopId) => new() { Raw = $"stop#{feedId}:{stopId}" };
public static AlertSelector FromRoute(string feedId, string routeId) => new() { Raw = $"route#{feedId}:{routeId}" };
public static AlertSelector FromAgency(string feedId) => new() { Raw = $"agency#{feedId}" };
public override string ToString() => Raw;
}
|