sharee.bike-App/TINKLib/Model/Bikes/BikeInfoNS/CopriLock/BikeInfo.cs

174 lines
5.6 KiB
C#
Raw Normal View History

2023-01-18 14:22:51 +01:00
using System;
2022-04-25 22:15:15 +02:00
using System.Collections.Generic;
2023-01-18 14:22:51 +01:00
using TINK.Model.Bikes.BikeInfoNS.BC;
2022-08-30 15:42:25 +02:00
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
using TINK.Model.MiniSurvey;
2022-04-25 22:15:15 +02:00
using TINK.Model.State;
2022-08-30 15:42:25 +02:00
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
2022-04-25 22:15:15 +02:00
{
2022-09-06 16:08:19 +02:00
public class BikeInfo : BC.BikeInfo
{
/// <summary>
/// Constructs a bike info object for a available bike or bike for which feed back is pending.
/// </summary>
/// <param name="bike">Bike object.</param>
2023-01-18 14:22:51 +01:00
/// <param name="dataSource">Specified the source of the data.</param>
2022-09-06 16:08:19 +02:00
/// <param name="currentStationId">Id of station where bike is located.</param>
/// <param name="lockInfo">Lock info.</param>
/// <param name="isFeedbackPending">If true user has not yet given feedback after returning bike.</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>
public BikeInfo(
2023-01-18 14:22:51 +01:00
Bike bike,
2022-09-06 16:08:19 +02:00
Drive drive,
2023-01-18 14:22:51 +01:00
DataSource dataSource,
2022-09-06 16:08:19 +02:00
string currentStationId,
LockInfo lockInfo,
bool isFeedbackPending = false,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
IMiniSurveyModel miniSurvey = null,
string co2Saving = null) : base(
new StateInfo(isFeedbackPending),
bike != null
? new Bike(
bike.Id,
LockModel.Sigo,
2023-04-19 12:14:14 +02:00
bike.WheelType /* Ensure consistent lock model value */,
2022-09-06 16:08:19 +02:00
bike.TypeOfBike,
2023-04-19 12:14:14 +02:00
bike.AaRideType,
2022-09-06 16:08:19 +02:00
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
2023-01-18 14:22:51 +01:00
dataSource,
2022-09-06 16:08:19 +02:00
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = miniSurvey;
Co2Saving = co2Saving;
}
2022-04-25 22:15:15 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Constructs a bike info object for a requested bike.
/// </summary>
/// <param name="bike">Bike object.</param>
2023-01-18 14:22:51 +01:00
/// <param name="dataSource">Specified the source of the data.</param>
2022-09-06 16:08:19 +02:00
/// <param name="requestedAt">Date time when bike was requested</param>
/// <param name="mailAddress">Mail address of user which requested bike.</param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
/// <param name="lockInfo">Lock info.</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>
2023-04-19 12:14:14 +02:00
/// <param name="dateTimeProvider">Provider for current date time to calculate remaining time on demand for state of type reserved.</param>
2022-09-06 16:08:19 +02:00
public BikeInfo(
2023-01-18 14:22:51 +01:00
Bike bike,
2022-09-06 16:08:19 +02:00
Drive drive,
2023-01-18 14:22:51 +01:00
DataSource dataSource,
2022-09-06 16:08:19 +02:00
DateTime requestedAt,
string mailAddress,
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
RentalDescription tariffDescription,
Func<DateTime> dateTimeProvider,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
dateTimeProvider,
requestedAt,
mailAddress,
""),
bike != null
2023-01-18 14:22:51 +01:00
? new Bike(
2022-09-06 16:08:19 +02:00
bike.Id,
2023-04-19 12:14:14 +02:00
LockModel.Sigo /* Ensure consistent lock model value */,
2022-09-06 16:08:19 +02:00
bike.WheelType,
bike.TypeOfBike,
2023-04-19 12:14:14 +02:00
bike.AaRideType,
2022-09-06 16:08:19 +02:00
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
2023-01-18 14:22:51 +01:00
dataSource,
2022-09-06 16:08:19 +02:00
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
2022-04-25 22:15:15 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Constructs a bike info object for a booked bike.
/// </summary>
/// <param name="bike">Bike object.</param>
2023-01-18 14:22:51 +01:00
/// <param name="dataSource">Specified the source of the data.</param>
2022-09-06 16:08:19 +02:00
/// <param name="bookedAt">Date time when bike was booked</param>
/// <param name="mailAddress">Mail address of user which booked bike.</param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
/// <param name="lockInfo">Lock info.</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>
public BikeInfo(
2023-01-18 14:22:51 +01:00
Bike bike,
2022-09-06 16:08:19 +02:00
Drive drive,
2023-01-18 14:22:51 +01:00
DataSource dataSource,
2022-09-06 16:08:19 +02:00
DateTime bookedAt,
string mailAddress,
string currentStationId,
LockInfo lockInfo,
Uri operatorUri,
RentalDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null) : base(
new StateInfo(
bookedAt,
mailAddress,
""),
bike != null
2023-01-18 14:22:51 +01:00
? new Bike(
2022-09-06 16:08:19 +02:00
bike.Id,
2023-04-19 12:14:14 +02:00
LockModel.Sigo /* Ensure consistent lock model value */,
2022-09-06 16:08:19 +02:00
bike.WheelType,
bike.TypeOfBike,
2023-04-19 12:14:14 +02:00
bike.AaRideType,
2022-09-06 16:08:19 +02:00
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
2023-01-18 14:22:51 +01:00
dataSource,
2022-09-06 16:08:19 +02:00
isDemo,
group,
currentStationId,
operatorUri,
tariffDescription)
{
LockInfo = lockInfo;
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
public BikeInfo(BC.BikeInfo bikeInfo, LockInfo lockInfo) : base(
bikeInfo ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source bike info must not be null."))
{
LockInfo = lockInfo
?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source lock object must not be null.");
}
2022-04-25 22:15:15 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Holds the lock info.</summary>
public LockInfo LockInfo { get; private set; }
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
public IMiniSurveyModel MiniSurvey { get; private set; }
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
public string Co2Saving { get; private set; }
}
2022-04-25 22:15:15 +02:00
}