mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 03:56:29 +02:00
Closing lock and returning bike speeded up.
This commit is contained in:
parent
e4adeb908c
commit
db9c288584
70 changed files with 933 additions and 902 deletions
|
@ -13,6 +13,7 @@ using TINK.Model.Bikes.Bike.BC;
|
|||
using TINK.Repository;
|
||||
using System.Net;
|
||||
using TINK.MultilingualResources;
|
||||
using System.Linq;
|
||||
|
||||
namespace TINK.ViewModel
|
||||
{
|
||||
|
@ -59,9 +60,9 @@ namespace TINK.ViewModel
|
|||
/// </summary>
|
||||
/// <param name="p_oStation">Station to get id from</param>
|
||||
/// <returns></returns>
|
||||
public static int GetStationId(string p_strStationName)
|
||||
public static int GetStationId(string stationName)
|
||||
{
|
||||
return int.Parse(p_strStationName.Replace(USER_FIENDLY_STATIONNUMBER_PREFIX, "").Trim());
|
||||
return int.Parse(stationName.Replace(USER_FIENDLY_STATIONNUMBER_PREFIX, "").Trim());
|
||||
}
|
||||
|
||||
/// <summary> Get full display name of a bike which includes id. </summary>
|
||||
|
@ -91,11 +92,11 @@ namespace TINK.ViewModel
|
|||
/// <summary>
|
||||
/// Maps state to color.
|
||||
/// </summary>
|
||||
/// <param name="p_eState"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
public static Color GetColor(this InUseStateEnum p_eState)
|
||||
public static Color GetColor(this InUseStateEnum state)
|
||||
{
|
||||
switch (p_eState)
|
||||
switch (state)
|
||||
{
|
||||
case InUseStateEnum.Disposable:
|
||||
return Color.Default;
|
||||
|
@ -158,33 +159,48 @@ namespace TINK.ViewModel
|
|||
|
||||
}
|
||||
|
||||
/// <summary> Gets message that logged in user has not booked any bikes. </summary>
|
||||
public static FormattedString GetErrorInfoText(this Exception p_oException)
|
||||
/// <summary> Gets error message and handles aggegate exceptions. </summary>
|
||||
public static string GetErrorMessage(this Exception exception)
|
||||
{
|
||||
if (p_oException == null)
|
||||
if (exception == null)
|
||||
return string.Empty;
|
||||
|
||||
if (!(exception is AggregateException aggregateException))
|
||||
return exception.Message;
|
||||
|
||||
if (aggregateException.InnerExceptions.Count == 1)
|
||||
return aggregateException.InnerExceptions[0].Message;
|
||||
|
||||
return new AggregateException().Message + "\r\n"+ string.Join("\r\n", aggregateException.InnerExceptions.Select(x => x.Message));
|
||||
}
|
||||
|
||||
/// <summary> Gets message that logged in user has not booked any bikes. </summary>
|
||||
public static FormattedString GetErrorInfoText(this Exception exception)
|
||||
{
|
||||
if (exception == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
FormattedString l_oError;
|
||||
// An error occurred getting bikes information.
|
||||
if (p_oException is WebConnectFailureException)
|
||||
if (exception is WebConnectFailureException)
|
||||
{
|
||||
|
||||
l_oError = new FormattedString();
|
||||
l_oError.Spans.Add(new Span { Text = "Information!\r\n", FontAttributes = FontAttributes.Bold });
|
||||
l_oError.Spans.Add(new Span { Text = $"{p_oException.Message}\r\n{WebConnectFailureException.GetHintToPossibleExceptionsReasons}" });
|
||||
l_oError.Spans.Add(new Span { Text = $"{exception.Message}\r\n{WebConnectFailureException.GetHintToPossibleExceptionsReasons}" });
|
||||
return l_oError;
|
||||
|
||||
}
|
||||
else if (p_oException is InvalidResponseException)
|
||||
else if (exception is InvalidResponseException)
|
||||
{
|
||||
l_oError = new FormattedString();
|
||||
l_oError.Spans.Add(new Span { Text = "Fehler, ungültige Serverantwort!\r\n", FontAttributes = FontAttributes.Bold });
|
||||
l_oError.Spans.Add(new Span { Text = $"{p_oException.Message}" });
|
||||
l_oError.Spans.Add(new Span { Text = $"{exception.Message}" });
|
||||
return l_oError;
|
||||
}
|
||||
else if (p_oException is WebForbiddenException)
|
||||
else if (exception is WebForbiddenException)
|
||||
{
|
||||
l_oError = new FormattedString();
|
||||
l_oError.Spans.Add(new Span { Text = "Beschäftigt... Einen Moment bitte!" });
|
||||
|
@ -193,37 +209,37 @@ namespace TINK.ViewModel
|
|||
|
||||
l_oError = new FormattedString();
|
||||
l_oError.Spans.Add(new Span { Text = "Allgemeiner Fehler!\r\n", FontAttributes = FontAttributes.Bold });
|
||||
l_oError.Spans.Add(new Span { Text = $"{p_oException}" });
|
||||
l_oError.Spans.Add(new Span { Text = $"{exception}" });
|
||||
return l_oError;
|
||||
}
|
||||
|
||||
|
||||
/// <summary> User tabbed a URI. </summary>
|
||||
/// <param name="p_oSender">Sender of the event.</param>
|
||||
/// <param name="p_eEventArgs">Event arguments</param>
|
||||
public static void OnNavigating(object p_oSender, WebNavigatingEventArgs p_eEventArgs)
|
||||
/// <param name="sender">Sender of the event.</param>
|
||||
/// <param name="eventArgs">Event arguments</param>
|
||||
public static void OnNavigating(object sender, WebNavigatingEventArgs eventArgs)
|
||||
{
|
||||
|
||||
if (!p_eEventArgs.Url.ToUpper().StartsWith("HTTP"))
|
||||
if (!eventArgs.Url.ToUpper().StartsWith("HTTP"))
|
||||
{
|
||||
// An internal link was detected.
|
||||
// Stay inside WebView
|
||||
p_eEventArgs.Cancel = false;
|
||||
eventArgs.Cancel = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not navigate outside the document.
|
||||
p_eEventArgs.Cancel = true;
|
||||
eventArgs.Cancel = true;
|
||||
|
||||
DependencyService.Get<IExternalBrowserService>().OpenUrl(p_eEventArgs.Url);
|
||||
DependencyService.Get<IExternalBrowserService>().OpenUrl(eventArgs.Url);
|
||||
}
|
||||
|
||||
/// <summary> Gets the user group if a user friendly name.</summary>
|
||||
/// <param name="p_oUser"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetUserGroupDisplayName(this User p_oUser)
|
||||
public static string GetUserGroupDisplayName(this User user)
|
||||
{
|
||||
return string.Join(" & ", p_oUser.Group);
|
||||
return string.Join(" & ", user.Group);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue