2021-05-13 20:03:07 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
|
|
|
|
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
using TINK.Model.State;
|
|
|
|
|
|
2022-08-30 15:42:25 +02:00
|
|
|
|
namespace TINK.Model.Bikes.BikeInfoNS.BC
|
2021-05-13 20:03:07 +02:00
|
|
|
|
{
|
|
|
|
|
public class BikeInfo : IBikeInfo
|
|
|
|
|
{
|
|
|
|
|
/// <summary> Default value of demo property. </summary>
|
|
|
|
|
public const bool DEFAULTVALUEISDEMO = false;
|
|
|
|
|
|
|
|
|
|
/// <summary> Holds the info about the bike state. </summary>
|
2022-08-30 15:42:25 +02:00
|
|
|
|
private readonly IStateInfo _StateInfo;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Holds the bike object.
|
|
|
|
|
/// </summary>
|
2022-08-30 15:42:25 +02:00
|
|
|
|
public BikeNS.Bike Bike { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Holds the drive object.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Drive Drive { get; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
/// <summary> Constructs a bike object.</summary>
|
|
|
|
|
protected BikeInfo(
|
|
|
|
|
IStateInfo stateInfo,
|
2022-08-30 15:42:25 +02:00
|
|
|
|
BikeNS.Bike bike,
|
|
|
|
|
Drive drive,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
bool? isDemo = DEFAULTVALUEISDEMO,
|
2022-08-30 15:42:25 +02:00
|
|
|
|
IEnumerable<string> group = null,
|
2022-01-04 18:59:16 +01:00
|
|
|
|
string stationId = null,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
Uri operatorUri = null,
|
2022-08-30 15:42:25 +02:00
|
|
|
|
RentalDescription tariffDescription = null)
|
2021-05-13 20:03:07 +02:00
|
|
|
|
{
|
2022-08-30 15:42:25 +02:00
|
|
|
|
Bike = bike ?? throw new ArgumentNullException(nameof(bike));
|
|
|
|
|
Drive = drive ?? throw new ArgumentNullException(nameof(drive));
|
|
|
|
|
_StateInfo = stateInfo;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
IsDemo = isDemo ?? DEFAULTVALUEISDEMO;
|
|
|
|
|
Group = group ?? new List<string>();
|
2022-01-04 18:59:16 +01:00
|
|
|
|
StationId = stationId;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
OperatorUri = operatorUri;
|
|
|
|
|
TariffDescription = tariffDescription;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BikeInfo(BikeInfo bikeInfo) : this(
|
2022-08-30 15:42:25 +02:00
|
|
|
|
bikeInfo != null ? bikeInfo?.State : throw new ArgumentNullException(nameof(bikeInfo)),
|
|
|
|
|
bikeInfo.Bike,
|
|
|
|
|
bikeInfo.Drive,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
bikeInfo.IsDemo,
|
|
|
|
|
bikeInfo.Group,
|
2022-01-04 18:59:16 +01:00
|
|
|
|
bikeInfo.StationId,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
bikeInfo.OperatorUri,
|
2022-08-30 15:42:25 +02:00
|
|
|
|
bikeInfo.TariffDescription)
|
|
|
|
|
{ }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a bike info object for a available bike.
|
|
|
|
|
/// </summary>
|
2022-01-04 18:59:16 +01:00
|
|
|
|
/// <param name="stationId">Id of station where bike is located.</param>
|
2021-05-13 20:03:07 +02:00
|
|
|
|
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
|
|
|
|
/// <param name="tariffDescription">Hold tariff description of bike.</param>
|
|
|
|
|
public BikeInfo(
|
2022-08-30 15:42:25 +02:00
|
|
|
|
BikeNS.Bike bike,
|
|
|
|
|
Drive drive,
|
2022-01-04 18:59:16 +01:00
|
|
|
|
string stationId,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
Uri operatorUri = null,
|
2022-06-17 14:17:58 +02:00
|
|
|
|
RentalDescription tariffDescription = null,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
bool? isDemo = DEFAULTVALUEISDEMO,
|
2022-08-30 15:42:25 +02:00
|
|
|
|
IEnumerable<string> group = null) : this(
|
2021-05-13 20:03:07 +02:00
|
|
|
|
new StateInfo(),
|
2022-08-30 15:42:25 +02:00
|
|
|
|
bike,
|
|
|
|
|
drive,
|
|
|
|
|
isDemo,
|
|
|
|
|
group,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
stationId,
|
|
|
|
|
operatorUri,
|
|
|
|
|
tariffDescription)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a bike info object for a booked bike.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
|
|
|
|
|
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
|
|
|
|
|
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
|
|
|
|
/// <param name="tariffDescription">Hold tariff description of bike.</param>
|
|
|
|
|
/// <param name="bookedAt">Date time when bike was booked</param>
|
|
|
|
|
/// <param name="mailAddress">Mail address of user which booked bike.</param>
|
|
|
|
|
/// <param name="code">Booking code.</param>
|
|
|
|
|
public BikeInfo(
|
2022-08-30 15:42:25 +02:00
|
|
|
|
BikeNS.Bike bike,
|
|
|
|
|
Drive drive,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
bool? isDemo,
|
|
|
|
|
IEnumerable<string> group,
|
2021-06-26 20:57:55 +02:00
|
|
|
|
string currentStationId,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
Uri operatorUri,
|
2022-06-17 14:17:58 +02:00
|
|
|
|
RentalDescription tariffDescription,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
DateTime bookedAt,
|
|
|
|
|
string mailAddress,
|
|
|
|
|
string code) : this(
|
|
|
|
|
new StateInfo(
|
|
|
|
|
bookedAt,
|
|
|
|
|
mailAddress,
|
|
|
|
|
code),
|
2022-08-30 15:42:25 +02:00
|
|
|
|
bike,
|
|
|
|
|
drive,
|
|
|
|
|
isDemo,
|
|
|
|
|
group,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
currentStationId,
|
|
|
|
|
operatorUri,
|
|
|
|
|
tariffDescription)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> True if device is demo device, false otherwise. </summary>
|
|
|
|
|
public bool IsDemo { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary> Returns the group (TINK, Konrad, ...). </summary>
|
|
|
|
|
public IEnumerable<string> Group { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Station a which bike is located, null otherwise.
|
|
|
|
|
/// </summary>
|
2022-01-04 18:59:16 +01:00
|
|
|
|
public string StationId { get; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
/// <summary> Holds description about the tarif. </summary>
|
2022-06-17 14:17:58 +02:00
|
|
|
|
public RentalDescription TariffDescription { get; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Holds the rent state of the bike.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IStateInfo State
|
|
|
|
|
{
|
2022-08-30 15:42:25 +02:00
|
|
|
|
get { return _StateInfo; }
|
2021-05-13 20:03:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public string Id => Bike.Id;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
public WheelType? WheelType => Bike.WheelType;
|
|
|
|
|
|
|
|
|
|
public TypeOfBike? TypeOfBike => Bike.TypeOfBike;
|
|
|
|
|
|
2022-04-25 22:15:15 +02:00
|
|
|
|
/// <summary> Gets the model of the lock. </summary>
|
|
|
|
|
public LockModel LockModel => Bike.LockModel;
|
|
|
|
|
|
2021-05-13 20:03:07 +02:00
|
|
|
|
public string Description => Bike.Description;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Uri of the operator or null, in case of single operator setup.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Uri OperatorUri { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Converts the instance to text.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public new string ToString()
|
|
|
|
|
{
|
2022-08-30 15:42:25 +02:00
|
|
|
|
return $"Id={Bike.Id}{(Bike.WheelType != null ? $", wheel(s)={Bike.WheelType}" : string.Empty)}{(Bike.TypeOfBike != null ? $"type={Bike.TypeOfBike}" : "")}, state={State}, location={(!string.IsNullOrEmpty(StationId) ? $"Station {StationId}" : "On the road")}, is demo={IsDemo}.";
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
}
|
|
|
|
|
}
|