mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-07-07 20:16:44 +02:00
Version 3.0.376
This commit is contained in:
parent
ca080c87c0
commit
f963c0a219
158 changed files with 3228 additions and 1279 deletions
|
@ -72,17 +72,18 @@ namespace TINK.Model.Connector
|
|||
|
||||
/// <summary> Gets bikes available. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Collection of bikes.</returns>
|
||||
public async Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null)
|
||||
public async Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
{
|
||||
var result = await server.GetBikesAvailable(operatorUri: operatorUri);
|
||||
var result = await server.GetBikesAvailable(operatorUri: operatorUri, stationId: stationId, bikeId: bikeId);
|
||||
|
||||
if (result.Source != typeof(CopriCallsMonkeyStore))
|
||||
{
|
||||
server.AddToCache(result, operatorUri);
|
||||
server.AddToCache(result, operatorUri, stationId, bikeId);
|
||||
}
|
||||
|
||||
|
||||
return new Result<BikeCollection>(
|
||||
result.Source,
|
||||
result.Response.GetBikesAvailable(result.Source == typeof(CopriCallsMonkeyStore)
|
||||
|
|
|
@ -128,10 +128,12 @@ namespace TINK.Model.Connector
|
|||
|
||||
/// <summary> Gets bikes available and bikes occupied. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Collection of bikes.</returns>
|
||||
public async Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null)
|
||||
public async Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
{
|
||||
var bikesAvailableResponse = await Server.GetBikesAvailable(operatorUri: operatorUri);
|
||||
var bikesAvailableResponse = await Server.GetBikesAvailable(operatorUri: operatorUri, stationId: stationId, bikeId: bikeId);
|
||||
|
||||
if (bikesAvailableResponse.Source == typeof(CopriCallsMonkeyStore)
|
||||
|| bikesAvailableResponse.Exception != null)
|
||||
|
@ -155,7 +157,7 @@ namespace TINK.Model.Connector
|
|||
if (operatorUri?.AbsoluteUri != null)
|
||||
{
|
||||
// Both types bikes could read from copri successfully => update cache
|
||||
Server.AddToCache(bikesAvailableResponse, operatorUri);
|
||||
Server.AddToCache(bikesAvailableResponse, operatorUri, stationId, bikeId);
|
||||
|
||||
Log.ForContext<CachedQueryLoggedIn>().Debug("Bikes available and occupied read successfully from server invoking one single request.");
|
||||
return new Result<BikeCollection>(
|
||||
|
@ -181,7 +183,7 @@ namespace TINK.Model.Connector
|
|||
return new Result<BikeCollection>(
|
||||
bikesOccupiedResponse.Source,
|
||||
BikeCollectionFactory.GetBikesAll(
|
||||
(await Server.GetBikesAvailable(true, operatorUri)).Response?.bikes?.Values,
|
||||
(await Server.GetBikesAvailable(true, operatorUri, stationId, bikeId)).Response?.bikes?.Values,
|
||||
bikesOccupiedResponse.Response?.bikes_occupied?.Values,
|
||||
Mail,
|
||||
DateTimeProvider,
|
||||
|
@ -191,7 +193,7 @@ namespace TINK.Model.Connector
|
|||
}
|
||||
|
||||
// Both types bikes could read from copri => update cache
|
||||
Server.AddToCache(bikesAvailableResponse, operatorUri);
|
||||
Server.AddToCache(bikesAvailableResponse, operatorUri, stationId, bikeId);
|
||||
Server.AddToCache(bikesOccupiedResponse);
|
||||
|
||||
Log.ForContext<CachedQueryLoggedIn>().Debug("Bikes available and occupied read successfully from server.");
|
||||
|
|
|
@ -16,7 +16,8 @@ namespace TINK.Model.Connector
|
|||
|
||||
/// <summary> Gets bikes either bikes available if no user is logged in or bikes available and bikes occupied if a user is logged in. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Collection of bikes.</returns>
|
||||
Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null);
|
||||
Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null, string stationId = null, string bikeId = null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,14 +55,18 @@ namespace TINK.Model.Connector
|
|||
|
||||
/// <summary> Gets bikes occupied. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns> Collection of bikes. </returns>
|
||||
public async Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null)
|
||||
public async Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
{
|
||||
var bikesAvailableResponse = await server.GetBikesAvailableAsync(operatorUri);
|
||||
var bikesAvailableResponse = await server.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
return new Result<BikeCollection>(
|
||||
typeof(CopriCallsMonkeyStore),
|
||||
bikesAvailableResponse.GetBikesAvailable(Bikes.BikeInfoNS.BC.DataSource.Cache),
|
||||
bikesAvailableResponse.GetGeneralData());
|
||||
bikesAvailableResponse != null
|
||||
? bikesAvailableResponse.GetBikesAvailable(Bikes.BikeInfoNS.BC.DataSource.Cache)
|
||||
: await Task.FromResult(new BikeCollection(new Dictionary<string, BikeInfo>())),
|
||||
bikesAvailableResponse?.GetGeneralData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,10 +70,26 @@ namespace TINK.Model.Connector
|
|||
|
||||
/// <summary> Gets bikes available and bikes occupied. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Collection of bikes.</returns>
|
||||
public async Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null)
|
||||
public async Task<Result<BikeCollection>> GetBikesAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
{
|
||||
var bikesAvailableResponse = await server.GetBikesAvailableAsync(operatorUri);
|
||||
var bikesAvailableResponse = await server.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
|
||||
if (operatorUri?.AbsoluteUri != null)
|
||||
{
|
||||
return new Result<BikeCollection>(
|
||||
typeof(CopriCallsMonkeyStore),
|
||||
BikeCollectionFactory.GetBikesAll(
|
||||
bikesAvailableResponse?.bikes?.Values,
|
||||
bikesAvailableResponse?.bikes_occupied?.Values,
|
||||
Mail,
|
||||
DateTimeProvider,
|
||||
Bikes.BikeInfoNS.BC.DataSource.Cache),
|
||||
bikesAvailableResponse?.GetGeneralData());
|
||||
}
|
||||
|
||||
var bikesOccupiedResponse = await server.GetBikesOccupiedAsync();
|
||||
|
||||
return new Result<BikeCollection>(
|
||||
|
@ -84,7 +100,7 @@ namespace TINK.Model.Connector
|
|||
Mail,
|
||||
DateTimeProvider,
|
||||
Bikes.BikeInfoNS.BC.DataSource.Cache),
|
||||
bikesAvailableResponse.GetGeneralData());
|
||||
bikesAvailableResponse?.GetGeneralData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue