Code updated to 3.0.238

This commit is contained in:
Oliver Hauff 2021-06-26 20:57:55 +02:00
parent 3302d80678
commit 9c6a1fa92b
257 changed files with 7763 additions and 2861 deletions

View file

@ -21,13 +21,13 @@ namespace TINK.Model.Bike.BC
/// <summary> Constructs a bike object.</summary>
protected BikeInfo(
IStateInfo stateInfo,
int id,
string id,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null,
int? currentStationId = null,
string currentStationId = null,
Uri operatorUri = null,
TariffDescription tariffDescription = null)
{
@ -63,8 +63,8 @@ namespace TINK.Model.Bike.BC
/// <param name="tariffDescription">Hold tariff description of bike.</param>
/// <param name="wheelType"></param>
public BikeInfo(
int id,
int? currentStationId,
string id,
string currentStationId,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
@ -99,13 +99,13 @@ namespace TINK.Model.Bike.BC
/// <param name="code">Booking code.</param>
/// <param name="p_oDateTimeNowProvider">Date time provider to calculate reaining time.</param>
public BikeInfo(
int id,
string id,
bool? isDemo,
IEnumerable<string> group,
WheelType? wheelType,
TypeOfBike? typeOfBike,
string description,
int? stationId,
string stationId,
Uri operatorUri,
TariffDescription tariffDescription,
DateTime requestedAt,
@ -142,13 +142,13 @@ namespace TINK.Model.Bike.BC
/// <param name="mailAddress">Mail address of user which booked bike.</param>
/// <param name="code">Booking code.</param>
public BikeInfo(
int id,
string id,
bool? isDemo,
IEnumerable<string> group,
WheelType? wheelType,
TypeOfBike? typeOfBike,
string description,
int? currentStationId,
string currentStationId,
Uri operatorUri,
TariffDescription tariffDescription,
DateTime bookedAt,
@ -179,7 +179,7 @@ namespace TINK.Model.Bike.BC
/// <summary>
/// Station a which bike is located, null otherwise.
/// </summary>
public int? CurrentStation { get; }
public string CurrentStation { get; }
/// <summary> Holds description about the tarif. </summary>
public TariffDescription TariffDescription { get; }
@ -192,7 +192,7 @@ namespace TINK.Model.Bike.BC
get { return m_oStateInfo; }
}
public int Id => Bike.Id;
public string Id => Bike.Id;
public WheelType? WheelType => Bike.WheelType;
@ -210,7 +210,7 @@ namespace TINK.Model.Bike.BC
/// </summary>
public new string ToString()
{
return $"Id={Bike.Id}{(Bike.WheelType != null ? $", wheel(s)={Bike.WheelType}" : string.Empty)}{(Bike.TypeOfBike != null ? $"type={Bike.TypeOfBike}" : "")}, state={State}, location={(CurrentStation.HasValue ? $"Station {CurrentStation}" : "On the road")}, is demo={IsDemo}.";
return $"Id={Bike.Id}{(Bike.WheelType != null ? $", wheel(s)={Bike.WheelType}" : string.Empty)}{(Bike.TypeOfBike != null ? $"type={Bike.TypeOfBike}" : "")}, state={State}, location={(!string.IsNullOrEmpty(CurrentStation)? $"Station {CurrentStation}" : "On the road")}, is demo={IsDemo}.";
}
}
}

View file

@ -29,13 +29,13 @@ namespace TINK.Model.Bike.BC
/// <param name="tariffDescription">Hold tariff description of bike.</param>
/// <param name="stateInfo">Bike state info.</param>
protected BikeInfoMutable(
int id,
string id,
bool isDemo = BikeInfo.DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null,
int? currentStationId = null,
string currentStationId = null,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
@ -71,7 +71,7 @@ namespace TINK.Model.Bike.BC
/// Station a which bike is located, null otherwise.
/// </summary>
[DataMember]
public int? CurrentStation { get; }
public string CurrentStation { get; }
/// <summary> Holds description about the tarif. </summary>
[DataMember]
@ -94,7 +94,7 @@ namespace TINK.Model.Bike.BC
/// <summary> Unused member. </summary>
IStateInfoMutable IBikeInfoMutable.State => m_oStateInfo;
public int Id => m_oBike.Id;
public string Id => m_oBike.Id;
public bool IsDemo { get; }
@ -118,7 +118,7 @@ namespace TINK.Model.Bike.BC
/// <returns></returns>
public new string ToString()
{
return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(CurrentStation.HasValue ? $"Station {CurrentStation}" : "On the road")}.";
return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(!string.IsNullOrEmpty(CurrentStation) ? $"Station {CurrentStation}" : "On the road")}.";
}
}
}

View file

@ -13,7 +13,7 @@ namespace TINK.Model.Bike.BC
/// <summary>
/// Holds the unique id of the bike;
/// </summary>
int Id { get; }
string Id { get; }
/// <summary> True if bike is a demo bike. </summary>
bool IsDemo { get; }
@ -37,7 +37,7 @@ namespace TINK.Model.Bike.BC
/// <summary>
/// Station a which bike is located, null otherwise.
/// </summary>
int? CurrentStation { get; }
string CurrentStation { get; }
/// <summary>
/// Uri of the operator or null, in case of single operator setup.

View file

@ -11,7 +11,7 @@ namespace TINK.Model.Bikes.Bike.BC
/// <summary>
/// Holds the unique id of the bike;
/// </summary>
int Id { get; }
string Id { get; }
/// <summary> True if bike is a demo bike. </summary>
bool IsDemo { get; }
@ -35,7 +35,7 @@ namespace TINK.Model.Bikes.Bike.BC
/// <summary>
/// Station a which bike is located, null otherwise.
/// </summary>
int? CurrentStation { get; }
string CurrentStation { get; }
/// <summary>
/// Holds the rent state of the bike.

View file

@ -29,7 +29,7 @@ namespace TINK.Model.Bike
/// <param name="p_iId">Unique id of bike.</param>
/// <param name="p_strCurrentStationName">Name of station where bike is located, null if bike is on the road.</param>
public Bike(
int p_iId,
string p_iId,
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null)
@ -43,7 +43,7 @@ namespace TINK.Model.Bike
/// <summary>
/// Holds the unique id of the bike;
/// </summary>
public int Id { get; }
public string Id { get; }
/// <summary>
/// Holds the count of wheels.

View file

@ -18,10 +18,10 @@ namespace TINK.Model.Bike.BluetoothLock
/// <param name="tariffDescription">Hold tariff description of bike.</param>
/// <param name="wheelType">Trike, two wheels, mono, ....</param>
public BikeInfo(
int bikeId,
string bikeId,
int lockId,
Guid lockGuid,
int? currentStationId,
string currentStationId,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,
@ -58,7 +58,7 @@ namespace TINK.Model.Bike.BluetoothLock
/// <param name="p_oDateTimeNowProvider">Date time provider to calculate reaining time.</param>
/// <param name="wheelType"></param>
public BikeInfo(
int id,
string id,
int lockId,
Guid lockGuid,
byte[] userKey,
@ -66,7 +66,7 @@ namespace TINK.Model.Bike.BluetoothLock
byte[] seed,
DateTime requestedAt,
string mailAddress,
int? currentStationId,
string currentStationId,
Uri operatorUri,
TariffDescription tariffDescription,
Func<DateTime> dateTimeProvider,
@ -106,7 +106,7 @@ namespace TINK.Model.Bike.BluetoothLock
/// <param name="tariffDescription">Hold tariff description of bike.</param>
/// <param name="wheelType"></param>
public BikeInfo(
int id,
string id,
int lockId,
Guid lockGuid,
byte[] userKey,
@ -114,7 +114,7 @@ namespace TINK.Model.Bike.BluetoothLock
byte[] seed,
DateTime bookedAt,
string mailAddress,
int? currentStationId,
string currentStationId,
Uri operatorUri,
TariffDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO,

View file

@ -5,8 +5,9 @@ namespace TINK.Model.Bikes.Bike
/// <summary>
/// Holds tariff info for a single bike.
/// </summary>
#if USCSHARP9
public record TariffDescription
{
{
/// <summary>
/// Name of the tariff.
/// </summary>
@ -37,4 +38,38 @@ namespace TINK.Model.Bikes.Bike
/// </summary>
public double MaxFeeEuroPerDay { get; init; }
}
#else
public class TariffDescription
{
/// <summary>
/// Name of the tariff.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Number of the tariff.
/// </summary>
public int? Number { get; set; }
/// <summary>
/// Costs per hour in euro.
/// </summary>
public double FeeEuroPerHour { get; set; }
/// <summary>
/// Costs of the abo per month.
/// </summary>
public double AboEuroPerMonth { get; set; }
/// <summary>
/// Costs per hour in euro.
/// </summary>
public TimeSpan FreeTimePerSession { get; set; }
/// <summary>
/// Max. costs per day in euro.
/// </summary>
public double MaxFeeEuroPerDay { get; set; }
}
#endif
}

View file

@ -11,37 +11,37 @@ namespace TINK.Model.Bike
public class BikeCollection : IBikeDictionary<BikeInfo>
{
/// <summary> Holds the bike dictionary object.</summary>
private Dictionary<int, BikeInfo> BikeDictionary { get; }
private Dictionary<string, BikeInfo> BikeDictionary { get; }
/// <summary>Constructs an empty bike info dictionary object.</summary>
public BikeCollection()
{
BikeDictionary = new Dictionary<int, BikeInfo>();
BikeDictionary = new Dictionary<string, BikeInfo>();
}
/// <summary> Constructs a bike collection object.</summary>
/// <param name="bikeDictionary"></param>
public BikeCollection(Dictionary<int, BikeInfo> bikeDictionary)
public BikeCollection(Dictionary<string, BikeInfo> bikeDictionary)
{
BikeDictionary = bikeDictionary ??
throw new ArgumentNullException(nameof(bikeDictionary), "Can not construct BikeCollection object.");
}
/// <summary> Gets a bike by its id.</summary>
/// <param name="p_iId">Id of the bike to get.</param>
/// <param name="id">Id of the bike to get.</param>
/// <returns></returns>
public BikeInfo GetById(int p_iId)
public BikeInfo GetById(string id)
{
return BikeDictionary.FirstOrDefault(x => x.Key == p_iId).Value;
return BikeDictionary.FirstOrDefault(x => x.Key == id).Value;
}
/// <summary> Gets the count of bikes. </summary>
public int Count => BikeDictionary.Count;
/// <summary> Gets if a bike with given id exists.</summary>
/// <param name="p_iId">Id of bike.</param>
/// <param name="id">Id of bike.</param>
/// <returns>True if bike is contained, false otherwise.</returns>
public bool ContainsKey(int p_iId) => BikeDictionary.Keys.Contains(p_iId);
public bool ContainsKey(string id) => BikeDictionary.Keys.Contains(id);
/// <summary> Gets the enumerator. </summary>
/// <returns>Enumerator object.</returns>

View file

@ -14,11 +14,11 @@ namespace TINK.Model
/// <returns>BikeCollection holding bikes at given station or empty BikeCollection, if there are no bikes.</returns>
public static BikeCollection GetAtStation(
this BikeCollection bikesAtAnyStation,
int? selectedStation)
string selectedStation)
{
return new BikeCollection(bikesAtAnyStation?
.Where(bike => selectedStation.HasValue && bike.CurrentStation == selectedStation.Value)
.ToDictionary(x => x.Id) ?? new Dictionary<int, BikeInfo>());
.Where(bike => !string.IsNullOrEmpty(selectedStation) && bike.CurrentStation == selectedStation)
.ToDictionary(x => x.Id) ?? new Dictionary<string, BikeInfo>());
}
/// <summary> Filters bikes by bike type. </summary>
@ -28,7 +28,7 @@ namespace TINK.Model
{
return new BikeCollection(bcAndLockItBikes?
.Where(bike => bike is Bike.BluetoothLock.BikeInfo)
.ToDictionary(x => x.Id) ?? new Dictionary<int, BikeInfo>());
.ToDictionary(x => x.Id) ?? new Dictionary<string, BikeInfo>());
}
}
}

View file

@ -44,7 +44,7 @@ namespace TINK.Model.Bike
// Update bike.
GetById(bikeInfo.Id).State.Load(bikeInfo.State);
if (bikesToBeRemoved.Contains<int>(bikeInfo.Id))
if (bikesToBeRemoved.Contains<string>(bikeInfo.Id))
{
// Remove list from obsolete list.
bikesToBeRemoved.Remove(bikeInfo.Id);
@ -86,20 +86,20 @@ namespace TINK.Model.Bike
private set;
}
public void SetSelectedBike(int p_intId)
public void SetSelectedBike(string id)
{
SelectedBike = GetById(p_intId);
SelectedBike = GetById(id);
}
/// <summary>
/// Gets a bike by its id.
/// </summary>
/// <param name="p_iId"></param>
/// <param name="id"></param>
/// <returns></returns>
public BikeInfoMutable GetById(int p_iId)
public BikeInfoMutable GetById(string id)
{
{
return this.FirstOrDefault(bike => bike.Id == p_iId);
return this.FirstOrDefault(bike => bike.Id == id);
}
}
@ -108,18 +108,18 @@ namespace TINK.Model.Bike
/// </summary>
/// <param name="p_strKey">Key to check.</param>
/// <returns>True if bike exists.</returns>
public bool ContainsKey(int p_iId)
public bool ContainsKey(string id)
{
return GetById(p_iId) != null;
return GetById(id) != null;
}
/// <summary>
/// Removes a bike by its id.
/// </summary>
/// <param name="p_iId">Id of bike to be removed.</param>
public void RemoveById(int p_iId)
/// <param name="id">Id of bike to be removed.</param>
public void RemoveById(string id)
{
var l_oBike = GetById(p_iId);
var l_oBike = GetById(id);
if (l_oBike == null)
{
// Nothing to do if bike does not exists.

View file

@ -14,7 +14,7 @@ namespace TINK.Model.Bike
IEnumerable<BluetoothLock.LockInfo> locksInfo)
{
var updatedBikesCollection = new Dictionary<int, BC.BikeInfo>();
var updatedBikesCollection = new Dictionary<string, BC.BikeInfo>();
foreach (var bikeInfo in bikes)
{

View file

@ -7,29 +7,29 @@ namespace TINK.Model.Bike
/// <summary>
/// Gets a bike by its id.
/// </summary>
/// <param name="p_iId"></param>
/// <param name="id"></param>
/// <returns></returns>
T GetById(int p_iId);
T GetById(string id);
/// <summary>
/// Deteermines whether a bike by given key exists.
/// </summary>
/// <param name="p_strKey">Key to check.</param>
/// <returns>True if bike exists.</returns>
bool ContainsKey(int p_iId);
bool ContainsKey(string id);
}
public interface IBikeDictionaryMutable<T> : IBikeDictionary<T>
{
/// <summary>
/// Removes a bike by its id.
/// </summary>
/// <param name="p_iId">Id of bike to be removed.</param>
void RemoveById(int p_iId);
/// <param name="id">Id of bike to be removed.</param>
void RemoveById(string id);
/// <summary>
/// Adds a new element to dictinary.
/// </summary>
/// <param name="p_oNewElement">New element to add.</param>
void Add(T p_oNewElement);
/// <param name="newElement">New element to add.</param>
void Add(T newElement);
}
}