mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-23 13:26:29 +02:00
Version 3.0.337
This commit is contained in:
parent
fd0e63cf10
commit
573fe77e12
2336 changed files with 33688 additions and 86082 deletions
161
TINKLib/Model/Bikes/BikeInfoNS/CopriLock/BikeInfo.cs
Normal file
161
TINKLib/Model/Bikes/BikeInfoNS/CopriLock/BikeInfo.cs
Normal file
|
@ -0,0 +1,161 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.MiniSurvey;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
|
||||
{
|
||||
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>
|
||||
/// <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(
|
||||
BikeNS.Bike bike,
|
||||
Drive drive,
|
||||
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,
|
||||
bike.WheelType /* Ensure consistend lock model value */,
|
||||
bike.TypeOfBike,
|
||||
bike.Description)
|
||||
: throw new ArgumentNullException(nameof(bike)),
|
||||
drive,
|
||||
isDemo,
|
||||
group,
|
||||
currentStationId,
|
||||
operatorUri,
|
||||
tariffDescription)
|
||||
{
|
||||
LockInfo = lockInfo;
|
||||
MiniSurvey = miniSurvey;
|
||||
Co2Saving = co2Saving;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a bike info object for a requested bike.
|
||||
/// </summary>
|
||||
/// <param name="bike">Bike object.</param>
|
||||
/// <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>
|
||||
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
|
||||
public BikeInfo(
|
||||
BikeNS.Bike bike,
|
||||
Drive drive,
|
||||
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
|
||||
? new BikeNS.Bike(
|
||||
bike.Id,
|
||||
LockModel.Sigo /* Ensure consistend lock model value */,
|
||||
bike.WheelType,
|
||||
bike.TypeOfBike,
|
||||
bike.Description)
|
||||
: throw new ArgumentNullException(nameof(bike)),
|
||||
drive,
|
||||
isDemo,
|
||||
group,
|
||||
currentStationId,
|
||||
operatorUri,
|
||||
tariffDescription)
|
||||
{
|
||||
LockInfo = lockInfo;
|
||||
MiniSurvey = new MiniSurveyModel();
|
||||
Co2Saving = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a bike info object for a booked bike.
|
||||
/// </summary>
|
||||
/// <param name="bike">Bike object.</param>
|
||||
/// <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(
|
||||
BikeNS.Bike bike,
|
||||
Drive drive,
|
||||
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
|
||||
? new BikeNS.Bike(
|
||||
bike.Id,
|
||||
LockModel.Sigo /* Ensure consistend lock model value */,
|
||||
bike.WheelType,
|
||||
bike.TypeOfBike,
|
||||
bike.Description)
|
||||
: throw new ArgumentNullException(nameof(bike)),
|
||||
drive,
|
||||
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.");
|
||||
}
|
||||
|
||||
/// <summary> Holds the lock info.</summary>
|
||||
public LockInfo LockInfo { get; private set; }
|
||||
|
||||
public IMiniSurveyModel MiniSurvey { get; private set; }
|
||||
|
||||
public string Co2Saving { get; private set; }
|
||||
}
|
||||
}
|
47
TINKLib/Model/Bikes/BikeInfoNS/CopriLock/BikeInfoMutable.cs
Normal file
47
TINKLib/Model/Bikes/BikeInfoNS/CopriLock/BikeInfoMutable.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
|
||||
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
|
||||
{
|
||||
public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable
|
||||
{
|
||||
/// <summary> Constructs a bike object from source. </summary>
|
||||
public BikeInfoMutable(BikeInfo bike, string stationName) : base(
|
||||
bike != null
|
||||
? bike.Bike
|
||||
: throw new ArgumentNullException(nameof(bike)),
|
||||
bike.Drive,
|
||||
bike.IsDemo,
|
||||
bike.Group,
|
||||
bike.StationId,
|
||||
stationName,
|
||||
bike.OperatorUri,
|
||||
bike.TariffDescription,
|
||||
() => DateTime.Now,
|
||||
bike.State)
|
||||
{
|
||||
LockInfo = new LockInfoMutable(bike.LockInfo.State);
|
||||
|
||||
BookingFinishedModel = new BookingFinishedModel
|
||||
{
|
||||
Co2Saving = bike.Co2Saving,
|
||||
MiniSurvey = new MiniSurvey.MiniSurveyModel()
|
||||
};
|
||||
|
||||
if ((bike?.MiniSurvey?.Questions) == null
|
||||
|| bike.MiniSurvey.Questions.Count <= 0)
|
||||
{
|
||||
// No querries to add.
|
||||
return;
|
||||
}
|
||||
|
||||
// Add a dummy querry. Querries are not yet read from COPRI but compiled into the app.
|
||||
BookingFinishedModel.MiniSurvey.Questions.Add("q1", new MiniSurvey.QuestionModel());
|
||||
}
|
||||
|
||||
public LockInfoMutable LockInfo { get; }
|
||||
|
||||
ILockInfoMutable IBikeInfoMutable.LockInfo => LockInfo;
|
||||
|
||||
public IBookingFinishedModel BookingFinishedModel { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
|
||||
{
|
||||
public interface IBikeInfoMutable : BikeInfoNS.BC.IBikeInfoMutable
|
||||
{
|
||||
ILockInfoMutable LockInfo { get; }
|
||||
|
||||
IBookingFinishedModel BookingFinishedModel { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
|
||||
{
|
||||
public interface ILockInfoMutable
|
||||
{
|
||||
LockingState State { get; set; }
|
||||
}
|
||||
}
|
30
TINKLib/Model/Bikes/BikeInfoNS/CopriLock/LockInfoMutable.cs
Normal file
30
TINKLib/Model/Bikes/BikeInfoNS/CopriLock/LockInfoMutable.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
|
||||
{
|
||||
public class LockInfoMutable : ILockInfoMutable
|
||||
{
|
||||
/// <summary> Lock info object. </summary>
|
||||
private LockInfo LockInfo { get; set; }
|
||||
|
||||
/// <summary> Constructs a bluetooth lock info object. </summary>
|
||||
/// <param name="id">Id of lock must always been known when constructing an lock info object.</param>
|
||||
public LockInfoMutable(LockingState state)
|
||||
{
|
||||
LockInfo = new LockInfo.Builder() { State = state }.Build();
|
||||
}
|
||||
|
||||
public LockingState State
|
||||
{
|
||||
get => LockInfo.State;
|
||||
set => LockInfo = new LockInfo.Builder(LockInfo) { State = value }.Build();
|
||||
}
|
||||
|
||||
/// <summary> Holds the percentage of lock battery.</summary>
|
||||
public double BatteryPercentage { get; set; } = double.NaN;
|
||||
|
||||
/// <summary> Loads lock info object from values. </summary>
|
||||
public void Load()
|
||||
{
|
||||
LockInfo = new LockInfo.Builder(LockInfo) { }.Build();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue