sharee.bike-App/TINKLib/ViewModel/Bikes/ViewContext.cs
2023-11-21 15:26:57 +01:00

47 lines
1.3 KiB
C#

namespace TINK.ViewModel.Bikes
{
/// Holds the view context in which a view model is used.
public class ViewContext
{
/// <summary>
/// Constructs object.
/// </summary>
/// <param name="page">Value identifying the page to which view model relates to.</param>
/// <param name="stationId">Holds the id of the station if related page is <see cref="PageContext.BikesAtStation"/> ignored otherwise.</param>
public ViewContext(PageContext page, string stationId = null) {
Page = page;
if (page != PageContext.BikesAtStation)
{
// Station id must not contain a value if view context is not bikes at station page.
return;
}
StationId = stationId ?? string.Empty;
}
/// <summary>
/// Holds the page to which view model is related to.
/// </summary>
public PageContext Page { get; }
/// <summary>
/// Holds the id of the station if related page is <see cref="PageContext.BikesAtStation"/> empty otherwise.
/// </summary>
public string StationId { get; } = string.Empty;
}
/// <summary>
/// Holds the view context in which bikes view model is used.
/// </summary>
public enum PageContext
{
/// <summary> Context is bikes at station page. </summary>
BikesAtStation,
/// <summary> Context is find bike page. </summary>
SelectBike,
/// <summary> Context is my bikes page. </summary>
MyBikes
}
}