mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-01-21 20:14:27 +01:00
Mini survey added.
Minor fiexes.
This commit is contained in:
parent
ddfea49ea6
commit
e321764119
73 changed files with 1628 additions and 185 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.hauffware.sharee" android:versionName="3.0.242" android:versionCode="242">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.hauffware.sharee" android:versionName="3.0.243" android:versionCode="243">
|
||||
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="30" />
|
||||
<!-- Google Maps related permissions -->
|
||||
<permission android:name="com.ecs.google.maps.v2.actionbarsherlock.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
|
||||
|
|
|
@ -49,8 +49,8 @@
|
|||
<key>CFBundleDisplayName</key>
|
||||
<string>sharee.bike</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>242</string>
|
||||
<string>243</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.0.242</string>
|
||||
<string>3.0.241</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -43,6 +43,19 @@
|
|||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)View\ListViewAttachedBehavior.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)View\MiniSurvey\MiniSurveyPage.xaml.cs">
|
||||
<DependentUpon>MiniSurveyPage.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)View\MiniSurvey\Question\CheckOneViewCell.xaml.cs">
|
||||
<DependentUpon>CheckOneViewCell.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)View\MiniSurvey\Question\FreeTextViewCell.xaml.cs">
|
||||
<DependentUpon>FreeTextViewCell.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)View\MiniSurvey\Question\QuestionViewCellTemplateSelector.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)View\RootShell\FlyoutHeader.xaml.cs">
|
||||
<DependentUpon>FlyoutHeader.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
@ -335,4 +348,22 @@
|
|||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)View\MiniSurvey\MiniSurveyPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)View\MiniSurvey\Question\CheckOneViewCell.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)View\MiniSurvey\Question\FreeTextViewCell.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -101,8 +101,8 @@ namespace TINK.View.Account
|
|||
|
||||
/// <summary> Pushes a page onto the modal stack. </summary>
|
||||
/// <param name="p_oTypeOfPage">Page to display.</param>
|
||||
public Task PushModalAsync(ViewTypes p_oTypeOfPage)
|
||||
=> throw new NotImplementedException();
|
||||
public Task PushModalAsync(ViewTypes typeOfPage)
|
||||
=> Navigation.PushModalAsync((Page)Activator.CreateInstance(typeOfPage.GetViewType()));
|
||||
|
||||
/// <summary> Pops a page from the modal stack. </summary>
|
||||
public Task PopModalAsync()
|
||||
|
|
|
@ -194,11 +194,9 @@ using TINK.View.MasterDetail;
|
|||
|
||||
|
||||
/// <summary> Pushes a page onto the modal stack. </summary>
|
||||
/// <param name="p_oTypeOfPage">Page to display.</param>
|
||||
public Task PushModalAsync(ViewTypes p_oTypeOfPage)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
/// <param name="typeOfPage">Page to display.</param>
|
||||
public async Task PushModalAsync(ViewTypes typeOfPage)
|
||||
=> await Navigation.PushModalAsync((Page)Activator.CreateInstance(typeOfPage.GetViewType()));
|
||||
|
||||
/// <summary> Pops a page from the modal stack. </summary>
|
||||
public Task PopModalAsync()
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
IsVisible="{Binding
|
||||
Path=IsOperatorInfoAvaliable,
|
||||
Converter={StaticResource BoolInvert_Converter}}">
|
||||
<!-- Button to select station and explanation text -->
|
||||
<StackLayout>
|
||||
<Label
|
||||
TextType="Html"
|
||||
|
@ -28,11 +29,17 @@
|
|||
</Frame>
|
||||
<Frame
|
||||
IsVisible="{Binding IsOperatorInfoAvaliable}">
|
||||
<!-- Operator info -->
|
||||
<StackLayout>
|
||||
<Label
|
||||
IsVisible="{Binding IsOperatorInfoAvaliable}"
|
||||
HorizontalOptions="Center"
|
||||
FontAttributes="Bold"
|
||||
Text="{Binding ProviderNameText}"/>
|
||||
<!--- Mail address -->
|
||||
<Label
|
||||
IsVisible="{Binding MailAddressText, Converter={StaticResource StringNotNullOrEmpty_Converter}}"
|
||||
FormattedText="{Binding MaliAddressAndMotivationsText}"/>
|
||||
FormattedText="{Binding MailAddressAndMotivationsText}"/>
|
||||
<Button
|
||||
x:Name="MailAddressButton"
|
||||
IsVisible="{Binding MailAddressText, Converter={StaticResource StringNotNullOrEmpty_Converter}}"
|
||||
|
|
|
@ -5,54 +5,54 @@ using Xamarin.Forms.Xaml;
|
|||
namespace TINK.View
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class FeedbackPopup : Popup<FeedbackPopup.Result>
|
||||
{
|
||||
public FeedbackPopup ()
|
||||
{
|
||||
InitializeComponent ();
|
||||
}
|
||||
public partial class FeedbackPopup : Popup<FeedbackPopup.Result>
|
||||
{
|
||||
public FeedbackPopup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override FeedbackPopup.Result GetLightDismissResult()
|
||||
{
|
||||
return new Result
|
||||
{
|
||||
Message = feedbackMessage.Text,
|
||||
IsBikeBroken = brockenCheckBox.IsChecked
|
||||
};
|
||||
{
|
||||
Message = feedbackMessage.Text,
|
||||
IsBikeBroken = brockenCheckBox.IsChecked
|
||||
};
|
||||
}
|
||||
|
||||
private void OnOkClicked(object sender, EventArgs eventArgs)
|
||||
private void OnOkClicked(object sender, EventArgs eventArgs)
|
||||
{
|
||||
var result = new Result
|
||||
{
|
||||
Message = feedbackMessage.Text,
|
||||
IsBikeBroken = brockenCheckBox.IsChecked
|
||||
};
|
||||
var result = new Result
|
||||
{
|
||||
Message = feedbackMessage.Text,
|
||||
IsBikeBroken = brockenCheckBox.IsChecked
|
||||
};
|
||||
|
||||
base.Dismiss(result);
|
||||
Dismiss(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Feedback given by user when returning bike.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Feedback given by user when returning bike.
|
||||
/// </summary>
|
||||
#if USCSHARP9
|
||||
public class Result : IViewService.IUserFeedback
|
||||
#else
|
||||
public class Result : IUserFeedback
|
||||
public new class Result : IUserFeedback
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds whether bike is broken or not.
|
||||
/// </summary>
|
||||
public bool IsBikeBroken { get; set; }
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds whether bike is broken or not.
|
||||
/// </summary>
|
||||
public bool IsBikeBroken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds either
|
||||
/// - general feedback
|
||||
/// - error description of broken bike
|
||||
/// or both.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Holds either
|
||||
/// - general feedback
|
||||
/// - error description of broken bike
|
||||
/// or both.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -124,8 +124,9 @@ namespace TINK.View.FindBike
|
|||
#endif
|
||||
|
||||
/// <summary> Pushes a page onto the modal stack. </summary>
|
||||
/// <param name="p_oTypeOfPage">Page to display.</param>
|
||||
public Task PushModalAsync(ViewTypes p_oTypeOfPage) => throw new NotSupportedException();
|
||||
/// <param name="typeOfPage">Page to display.</param>
|
||||
public async Task PushModalAsync(ViewTypes typeOfPage)
|
||||
=> await Navigation.PushModalAsync((Page)Activator.CreateInstance(typeOfPage.GetViewType()));
|
||||
|
||||
/// <summary> Pops a page from the modal stack. </summary>
|
||||
public Task PopModalAsync() => throw new NotSupportedException();
|
||||
|
@ -139,6 +140,5 @@ namespace TINK.View.FindBike
|
|||
#else
|
||||
public async Task<IUserFeedback> DisplayUserFeedbackPopup() => await Navigation.ShowPopupAsync<FeedbackPopup.Result>(new FeedbackPopup());
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
|
@ -81,10 +81,9 @@ namespace TINK.View.Login
|
|||
|
||||
/// <summary> Pushes a page onto the modal stack. </summary>
|
||||
/// <param name="p_oTypeOfPage">Page to display.</param>
|
||||
public Task PushModalAsync(ViewTypes p_oTypeOfPage)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
public async Task PushModalAsync(ViewTypes typeOfPage)
|
||||
=> await Navigation.PushModalAsync((Page)Activator.CreateInstance(typeOfPage.GetViewType()));
|
||||
|
||||
|
||||
/// <summary> Pops a page from the modal stack. </summary>
|
||||
public Task PopModalAsync()
|
||||
|
|
34
TINK/TINK/View/MiniSurvey/MiniSurveyPage.xaml
Normal file
34
TINK/TINK/View/MiniSurvey/MiniSurveyPage.xaml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:local_minisurvey="clr-namespace:TINK.View.MiniSurvey.Question"
|
||||
x:Class="TINK.View.MiniSurvey.MiniSurveyPage">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<local_minisurvey:QuestionViewCellTemplateSelector x:Key="questionViewCellTemplateSelector"/>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ContentPage.Content>
|
||||
<Frame>
|
||||
<StackLayout>
|
||||
<Label
|
||||
FontSize="Large"
|
||||
FontAttributes="Bold"
|
||||
Text="{Binding Title}"/>
|
||||
<Label
|
||||
Text="{Binding Subtitle}"/>
|
||||
<ListView
|
||||
x:Name="MiniSurveyListView"
|
||||
HasUnevenRows="True"
|
||||
ItemTemplate="{StaticResource questionViewCellTemplateSelector}">
|
||||
</ListView>
|
||||
<Label
|
||||
Text="{Binding Footer}"/>
|
||||
<Button
|
||||
IsEnabled="False"
|
||||
Command="{Binding OnButtonClicked}"
|
||||
Text="OK"/>
|
||||
</StackLayout>
|
||||
</Frame>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
95
TINK/TINK/View/MiniSurvey/MiniSurveyPage.xaml.cs
Normal file
95
TINK/TINK/View/MiniSurvey/MiniSurveyPage.xaml.cs
Normal file
|
@ -0,0 +1,95 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.ViewModel.MiniSurvey;
|
||||
using Xamarin.CommunityToolkit.Extensions;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace TINK.View.MiniSurvey
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class MiniSurveyPage : ContentPage, IViewService
|
||||
{
|
||||
public MiniSurveyPage()
|
||||
{
|
||||
var model = App.ModelRoot;
|
||||
|
||||
var vm = new MiniSurveyViewModel(
|
||||
() => model.GetIsConnected(),
|
||||
(isConnected) => model.GetConnector(isConnected),
|
||||
this);
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
BindingContext = vm;
|
||||
MiniSurveyListView.ItemsSource = vm;
|
||||
}
|
||||
/// <summary>
|
||||
/// Displays alert message.
|
||||
/// </summary>
|
||||
/// <param name="p_strTitle">Title of message.</param>
|
||||
/// <param name="p_strMessage">Message to display.</param>
|
||||
/// <param name="p_strCancel">Type of buttons.</param>
|
||||
public new async Task DisplayAlert(string p_strTitle, string p_strMessage, string p_strCancel)
|
||||
=> await App.Current.MainPage.DisplayAlert(p_strTitle, p_strMessage, p_strCancel);
|
||||
|
||||
/// <summary> Displays alert message.</summary>
|
||||
/// <param name="title">Title of message.</param>
|
||||
/// <param name="message">Message to display.</param>
|
||||
/// <param name="details">Detailed error description.</param>
|
||||
/// <param name="cancel">Type of buttons.</param>
|
||||
public async Task DisplayAdvancedAlert(
|
||||
string title,
|
||||
string message,
|
||||
string details,
|
||||
string cancel)
|
||||
=> await App.Current.MainPage.DisplayAlert(title, $"{message}\r\nDetails:\r\n{details}", cancel);
|
||||
|
||||
/// <summary> Displays detailed alert message.</summary>
|
||||
/// <param name="title">Title of message.</param>
|
||||
/// <param name="message">Message to display.</param>
|
||||
/// <param name="details">Detailed error description.</param>
|
||||
/// <param name="accept">Text of accept button.</param>
|
||||
/// <param name="cancel">Text of cancel button.</param>
|
||||
/// <returns>True if user pressed accept.</returns>
|
||||
public async Task<bool> DisplayAdvancedAlert(string title, string message, string details, string accept, string cancel)
|
||||
=> await App.Current.MainPage.DisplayAlert(title, $"{message}\r\nDetails:\r\n{details}", accept, cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Displays alert message.
|
||||
/// </summary>
|
||||
/// <param name="p_strTitle">Title of message.</param>
|
||||
/// <param name="p_strMessage">Message to display.</param>
|
||||
/// <param name="p_strAccept">Text of accept button.</param>
|
||||
/// <param name="p_strCancel">Text of button.</param>
|
||||
/// <returns>True if user pressed accept.</returns>
|
||||
public new async Task<bool> DisplayAlert(string p_strTitle, string p_strMessage, string p_strAccept, string p_strCancel)
|
||||
=> await App.Current.MainPage.DisplayAlert(p_strTitle, p_strMessage, p_strAccept, p_strCancel);
|
||||
|
||||
#if USEMASTERDETAIL || USEFLYOUT
|
||||
public void ShowPage(ViewTypes p_oType, string p_strTitle = null)
|
||||
=> throw new NotImplementedException();
|
||||
#else
|
||||
/// <summary> Shows a page.</summary>
|
||||
/// <param name="route">Route of the page to show.</param>
|
||||
public async Task ShowPage(string route) => await Shell.Current.GoToAsync(route);
|
||||
#endif
|
||||
|
||||
/// <summary> Pushes a page onto the modal stack. </summary>
|
||||
/// <param name="p_oTypeOfPage">Page to display.</param>
|
||||
public Task PushModalAsync(ViewTypes p_oTypeOfPage) => throw new NotSupportedException();
|
||||
|
||||
/// <summary> Pops a page from the modal stack. </summary>
|
||||
public Task PopModalAsync() => Navigation.PopModalAsync();
|
||||
|
||||
/// <summary> Pushes a page onto the stack. </summary>
|
||||
/// <param name="p_oTypeOfPage">Page to display.</param>
|
||||
public Task PushAsync(ViewTypes p_oTypeOfPage) => throw new NotSupportedException();
|
||||
|
||||
#if USCSHARP9
|
||||
public async Task<IViewService.IUserFeedback> DisplayUserFeedbackPopup() => await Navigation.ShowPopupAsync<FeedbackPopup.Result>(new FeedbackPopup());
|
||||
#else
|
||||
public async Task<IUserFeedback> DisplayUserFeedbackPopup() => await Navigation.ShowPopupAsync<FeedbackPopup.Result>(new FeedbackPopup());
|
||||
#endif
|
||||
}
|
||||
}
|
19
TINK/TINK/View/MiniSurvey/Question/CheckOneViewCell.xaml
Normal file
19
TINK/TINK/View/MiniSurvey/Question/CheckOneViewCell.xaml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:resources="clr-namespace:TINK.MultilingualResources;assembly=TINKLib"
|
||||
x:Class="TINK.View.MiniSurvey.Question.CheckOneViewCell">
|
||||
<ViewCell.View>
|
||||
<Frame>
|
||||
<StackLayout>
|
||||
<Label
|
||||
FontSize="Medium"
|
||||
Text="{Binding QuestionText}" />
|
||||
<Picker
|
||||
Title="{x:Static resources:AppResources.MiniSurveyAskForAnswer}"
|
||||
SelectedItem="{Binding AnswerText}"
|
||||
ItemsSource="{Binding AnswersText}"/>
|
||||
</StackLayout>
|
||||
</Frame>
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
14
TINK/TINK/View/MiniSurvey/Question/CheckOneViewCell.xaml.cs
Normal file
14
TINK/TINK/View/MiniSurvey/Question/CheckOneViewCell.xaml.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace TINK.View.MiniSurvey.Question
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class CheckOneViewCell : ViewCell
|
||||
{
|
||||
public CheckOneViewCell ()
|
||||
{
|
||||
InitializeComponent ();
|
||||
}
|
||||
}
|
||||
}
|
20
TINK/TINK/View/MiniSurvey/Question/FreeTextViewCell.xaml
Normal file
20
TINK/TINK/View/MiniSurvey/Question/FreeTextViewCell.xaml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:resources="clr-namespace:TINK.MultilingualResources;assembly=TINKLib"
|
||||
x:Class="TINK.View.MiniSurvey.Question.FreeTextViewCell">
|
||||
<ViewCell.View>
|
||||
<Frame>
|
||||
<StackLayout>
|
||||
<Label
|
||||
FontSize="Medium"
|
||||
Text="{Binding QuestionText}" />
|
||||
<Editor
|
||||
AutoSize="TextChanges"
|
||||
Text="{Binding AnswerText}"
|
||||
Placeholder="{x:Static resources:AppResources.MiniSurveyEnterAnswer}">
|
||||
</Editor>
|
||||
</StackLayout>
|
||||
</Frame>
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
15
TINK/TINK/View/MiniSurvey/Question/FreeTextViewCell.xaml.cs
Normal file
15
TINK/TINK/View/MiniSurvey/Question/FreeTextViewCell.xaml.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace TINK.View.MiniSurvey.Question
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class FreeTextViewCell : ViewCell
|
||||
{
|
||||
public FreeTextViewCell ()
|
||||
{
|
||||
InitializeComponent ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace TINK.View.MiniSurvey.Question
|
||||
{
|
||||
/// <summary>
|
||||
/// Selects different templates for different question types.
|
||||
/// </summary>
|
||||
public class QuestionViewCellTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
DataTemplate checkOneViewCell;
|
||||
DataTemplate freeTextViewCell;
|
||||
|
||||
public QuestionViewCellTemplateSelector()
|
||||
{
|
||||
checkOneViewCell = new DataTemplate(typeof(CheckOneViewCell));
|
||||
freeTextViewCell = new DataTemplate(typeof(FreeTextViewCell));
|
||||
}
|
||||
|
||||
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
|
||||
{
|
||||
return item is ViewModel.MiniSurvey.Question.FreeTextViewModel
|
||||
? freeTextViewCell
|
||||
: checkOneViewCell;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -148,8 +148,10 @@ namespace TINK.View.MyBikes
|
|||
#endif
|
||||
|
||||
/// <summary> Pushes a page onto the modal stack. </summary>
|
||||
/// <param name="p_oTypeOfPage">Page to display.</param>
|
||||
public Task PushModalAsync(ViewTypes p_oTypeOfPage) => throw new NotSupportedException();
|
||||
/// <param name="typeOfPage">Page to display.</param>
|
||||
public async Task PushModalAsync(ViewTypes typeOfPage)
|
||||
=> await Navigation.PushModalAsync((Page)Activator.CreateInstance(typeOfPage.GetViewType()));
|
||||
|
||||
|
||||
/// <summary> Pops a page from the modal stack. </summary>
|
||||
public Task PopModalAsync() => throw new NotSupportedException();
|
||||
|
|
|
@ -11,6 +11,7 @@ using TINK.View.WhatsNew;
|
|||
using TINK.View.WhatsNew.Agb;
|
||||
using TINK.View.BikesAtStation;
|
||||
using Xamarin.Forms;
|
||||
using TINK.View.MiniSurvey;
|
||||
|
||||
namespace TINK.View
|
||||
{
|
||||
|
@ -65,6 +66,9 @@ namespace TINK.View
|
|||
case ViewTypes.SelectStationPage:
|
||||
return typeof(SelectStationPage);
|
||||
|
||||
case ViewTypes.MiniSurvey:
|
||||
return typeof(MiniSurveyPage);
|
||||
|
||||
default:
|
||||
return typeof(ContentPage);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.User.Account;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
|
@ -120,14 +122,13 @@ namespace TINK.Model.Connector
|
|||
Log.ForContext<Command>().Error("Unexpected booking request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task DoReturn(
|
||||
public async Task<MiniSurveyModel> DoReturn(
|
||||
Bikes.Bike.BluetoothLock.IBikeInfoMutable bike,
|
||||
LocationDto location,
|
||||
ISmartDevice smartDevice)
|
||||
{
|
||||
Log.ForContext<Command>().Error("Unexpected returning request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
return await Task.FromResult(new MiniSurveyModel());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -143,5 +144,13 @@ namespace TINK.Model.Connector
|
|||
Log.ForContext<Command>().Error("Unexpected submit feedback request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public async Task DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
{
|
||||
Log.ForContext<Command>().Error("Unexpected submit mini survey request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.User.Account;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
|
@ -246,7 +248,7 @@ namespace TINK.Model.Connector
|
|||
/// <param name="bike">Bike to return.</param>
|
||||
/// <param name="locaton">Position of the bike.</param>
|
||||
/// <param name="smartDevice">Provides info about hard and software.</param>
|
||||
public async Task DoReturn(
|
||||
public async Task<MiniSurveyModel> DoReturn(
|
||||
Bikes.Bike.BluetoothLock.IBikeInfoMutable bike,
|
||||
LocationDto location,
|
||||
ISmartDevice smartDevice)
|
||||
|
@ -256,10 +258,10 @@ namespace TINK.Model.Connector
|
|||
throw new ArgumentNullException("Can not return bike. No bike object available.");
|
||||
}
|
||||
|
||||
ReservationCancelReturnResponse l_oResponse;
|
||||
ReservationCancelReturnResponse response;
|
||||
try
|
||||
{
|
||||
l_oResponse = (await CopriServer.DoReturn(bike.Id, location, smartDevice, bike.OperatorUri)).GetIsReturnBikeResponseOk(bike.Id);
|
||||
response = (await CopriServer.DoReturn(bike.Id, location, smartDevice, bike.OperatorUri)).GetIsReturnBikeResponseOk(bike.Id);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -268,6 +270,7 @@ namespace TINK.Model.Connector
|
|||
}
|
||||
|
||||
bike.Load(Bikes.Bike.BC.NotifyPropertyChangedLevel.None);
|
||||
return response?.Create() ?? new MiniSurveyModel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -281,5 +284,10 @@ namespace TINK.Model.Connector
|
|||
public async Task DoSubmitFeedback(IUserFeedback userFeedback, Uri opertorUri)
|
||||
=> await CopriServer.DoSubmitFeedback(userFeedback.BikeId, userFeedback.Message, userFeedback.IsBikeBroken, opertorUri);
|
||||
#endif
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public async Task DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> await CopriServer.DoSubmitMiniSurvey(answers);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ using System.Threading.Tasks;
|
|||
using TINK.Repository.Request;
|
||||
using TINK.Model.User.Account;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
|
@ -48,7 +50,7 @@ namespace TINK.Model.Connector
|
|||
/// <param name="bike">Bike to return.</param>
|
||||
/// <param name="location">Geolocation of lock when returning bike.</param>
|
||||
/// <param name="smartDevice">Provides info about hard and software.</param>
|
||||
Task DoReturn(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null);
|
||||
Task<MiniSurveyModel> DoReturn(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null);
|
||||
|
||||
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
|
||||
bool IsConnected { get; }
|
||||
|
@ -57,6 +59,11 @@ namespace TINK.Model.Connector
|
|||
string SessionCookie { get; }
|
||||
|
||||
Task DoSubmitFeedback(IUserFeedback userFeedback, Uri opertorUri);
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
Task DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
||||
|
||||
#if USCSHARP9
|
||||
/// <summary>
|
||||
/// Feedback given by user when returning bike.
|
||||
|
|
|
@ -13,6 +13,8 @@ using IBikeInfoMutable = TINK.Model.Bikes.Bike.BC.IBikeInfoMutable;
|
|||
using System.Globalization;
|
||||
using TINK.Model.Station.Operator;
|
||||
using Xamarin.Forms;
|
||||
using System.Linq;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
|
@ -507,5 +509,39 @@ namespace TINK.Model.Connector
|
|||
MaxFeeEuroPerDay = double.TryParse(tariffDesciption?.max_eur_per_day, NumberStyles.Any, CultureInfo.InvariantCulture, out double maxEuroPerDay) ? maxEuroPerDay : double.NaN,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary> Creates a survey object from response.</summary>
|
||||
/// <param name="response">Response to create survey object from.</param>
|
||||
public static MiniSurveyModel Create(this ReservationCancelReturnResponse response)
|
||||
{
|
||||
if (response?.user_miniquery == null)
|
||||
{
|
||||
return new MiniSurveyModel();
|
||||
}
|
||||
|
||||
var miniquery = response.user_miniquery;
|
||||
var survey = new MiniSurveyModel
|
||||
{
|
||||
Title = miniquery.title,
|
||||
Subtitle = miniquery.subtitle,
|
||||
Footer = miniquery.footer
|
||||
};
|
||||
|
||||
foreach (var question in miniquery?.questions?.OrderBy(x => x.Key) ?? new Dictionary<string, MiniSurveyResponse.Question>().OrderBy(x => x.Key))
|
||||
{
|
||||
if (string.IsNullOrEmpty(question.Key.Trim())
|
||||
|| question.Value.query == null)
|
||||
{
|
||||
// Skip invalid entries.
|
||||
continue;
|
||||
}
|
||||
|
||||
survey.Questions.Add(
|
||||
question.Key,
|
||||
new MiniSurveyModel.QuestionModel());
|
||||
}
|
||||
|
||||
return survey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
40
TINKLib/Model/MiniSurvey/MiniSurveyModel.cs
Normal file
40
TINKLib/Model/MiniSurvey/MiniSurveyModel.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.Model.MiniSurvey
|
||||
|
||||
{
|
||||
public class MiniSurveyModel
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
SingleAnswer,
|
||||
CustomText
|
||||
}
|
||||
public class QuestionModel
|
||||
{
|
||||
public QuestionModel()
|
||||
{
|
||||
PossibleAnswers = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public Type Type { get; set; }
|
||||
|
||||
public Dictionary<string, string> PossibleAnswers { get; private set; }
|
||||
}
|
||||
|
||||
public MiniSurveyModel()
|
||||
{
|
||||
Questions = new Dictionary<string, QuestionModel>();
|
||||
}
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Subtitle { get; set; }
|
||||
|
||||
public string Footer { get; set; }
|
||||
|
||||
public Dictionary<string, QuestionModel> Questions { get; }
|
||||
}
|
||||
}
|
|
@ -421,6 +421,10 @@ namespace TINK.Model
|
|||
{
|
||||
new Version(3, 0, 242),
|
||||
AppResources.ChangeLog3_0_242
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 243),
|
||||
AppResources.ChangeLog3_0_243
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -769,6 +769,16 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Mini survey implemented.
|
||||
///Minor fixes..
|
||||
/// </summary>
|
||||
public static string ChangeLog3_0_243 {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangeLog3_0_243", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Lock of rented bike can not be found..
|
||||
/// </summary>
|
||||
|
@ -1074,6 +1084,24 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Operator: {0}..
|
||||
/// </summary>
|
||||
public static string MarkingBikeSharingOperator {
|
||||
get {
|
||||
return ResourceManager.GetString("MarkingBikeSharingOperator", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Contact Operator..
|
||||
/// </summary>
|
||||
public static string MarkingBikeSharingOperatorNoOperatorInfoAvailable {
|
||||
get {
|
||||
return ResourceManager.GetString("MarkingBikeSharingOperatorNoOperatorInfoAvailable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please open a bike station page to to contact the bike sharing operator..
|
||||
/// </summary>
|
||||
|
@ -1589,7 +1617,7 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Urgent question related to {0}?.
|
||||
/// Looks up a localized string similar to Urgent questions?.
|
||||
/// </summary>
|
||||
public static string MessagePhoneMail {
|
||||
get {
|
||||
|
@ -1660,6 +1688,24 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Select an answer please..
|
||||
/// </summary>
|
||||
public static string MiniSurveyAskForAnswer {
|
||||
get {
|
||||
return ResourceManager.GetString("MiniSurveyAskForAnswer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enter answer here please..
|
||||
/// </summary>
|
||||
public static string MiniSurveyEnterAnswer {
|
||||
get {
|
||||
return ResourceManager.GetString("MiniSurveyEnterAnswer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No.
|
||||
/// </summary>
|
||||
|
|
|
@ -157,9 +157,6 @@ Eine Radrückgabe ist nur möglich, wenn das Rad in Reichweite ist und Standorti
|
|||
<data name="MessageContactMail" xml:space="preserve">
|
||||
<value>Fragen? Hinweise? Kritik?</value>
|
||||
</data>
|
||||
<data name="MessagePhoneMail" xml:space="preserve">
|
||||
<value>Eilige Frage rund um {0}?</value>
|
||||
</data>
|
||||
<data name="MessageRateMail" xml:space="preserve">
|
||||
<value>Gefällt die {0}-App?</value>
|
||||
</data>
|
||||
|
@ -637,4 +634,22 @@ Layout Anzeige Radnamen und nummern verbessert.</value>
|
|||
<data name="ChangeLog3_0_242" xml:space="preserve">
|
||||
<value>Seite zur Auswahl einer Station hinzugefügt zum Abrufen von Kontaktinformationen.</value>
|
||||
</data>
|
||||
<data name="MessagePhoneMail" xml:space="preserve">
|
||||
<value>Eilige Fragen?</value>
|
||||
</data>
|
||||
<data name="MarkingBikeSharingOperator" xml:space="preserve">
|
||||
<value>Betreiber: {0}.</value>
|
||||
</data>
|
||||
<data name="MarkingBikeSharingOperatorNoOperatorInfoAvailable" xml:space="preserve">
|
||||
<value>Betreiber Kontaktieren.</value>
|
||||
</data>
|
||||
<data name="MiniSurveyAskForAnswer" xml:space="preserve">
|
||||
<value>Bitte eine Antwort auswählen.</value>
|
||||
</data>
|
||||
<data name="MiniSurveyEnterAnswer" xml:space="preserve">
|
||||
<value>Bitte Antwort hier eingeben.</value>
|
||||
</data>
|
||||
<data name="ChangeLog3_0_241" xml:space="preserve">
|
||||
<value>Auf der Kontaktseite werden Kontaktinformationen betreiberspezifisch angezeigt.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -248,7 +248,7 @@ Use of app is restricted to maximu 8 devices per account.
|
|||
Please login to app once again. In case this fails please check on website if the account is still valid.</value>
|
||||
</data>
|
||||
<data name="MessagePhoneMail" xml:space="preserve">
|
||||
<value>Urgent question related to {0}?</value>
|
||||
<value>Urgent questions?</value>
|
||||
</data>
|
||||
<data name="MessageRateMail" xml:space="preserve">
|
||||
<value>Are you enjoying the {0}-App?</value>
|
||||
|
@ -733,4 +733,20 @@ Layout of bike names and id display improved.</value>
|
|||
<data name="ChangeLog3_0_242" xml:space="preserve">
|
||||
<value>Select station page added to ease getting operator specific contact information.</value>
|
||||
</data>
|
||||
<data name="MarkingBikeSharingOperator" xml:space="preserve">
|
||||
<value>Operator: {0}.</value>
|
||||
</data>
|
||||
<data name="MarkingBikeSharingOperatorNoOperatorInfoAvailable" xml:space="preserve">
|
||||
<value>Contact Operator.</value>
|
||||
</data>
|
||||
<data name="MiniSurveyAskForAnswer" xml:space="preserve">
|
||||
<value>Select an answer please.</value>
|
||||
</data>
|
||||
<data name="MiniSurveyEnterAnswer" xml:space="preserve">
|
||||
<value>Enter answer here please.</value>
|
||||
</data>
|
||||
<data name="ChangeLog3_0_243" xml:space="preserve">
|
||||
<value>Mini survey implemented.
|
||||
Minor fixes.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -202,10 +202,6 @@ Eine Radrückgabe ist nur möglich, wenn das Rad in Reichweite ist und Standorti
|
|||
<source>Questions? Remarks? Criticism?</source>
|
||||
<target state="translated">Fragen? Hinweise? Kritik?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MessagePhoneMail" translate="yes" xml:space="preserve">
|
||||
<source>Urgent question related to {0}?</source>
|
||||
<target state="translated">Eilige Frage rund um {0}?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MessageRateMail" translate="yes" xml:space="preserve">
|
||||
<source>Are you enjoying the {0}-App?</source>
|
||||
<target state="translated">Gefällt die {0}-App?</target>
|
||||
|
@ -853,6 +849,32 @@ Layout Anzeige Radnamen und nummern verbessert.</target>
|
|||
<source>Select station page added to ease getting operator specific contact information.</source>
|
||||
<target state="translated">Seite zur Auswahl einer Station hinzugefügt zum Abrufen von Kontaktinformationen.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MessagePhoneMail" translate="yes" xml:space="preserve">
|
||||
<source>Urgent questions?</source>
|
||||
<target state="translated">Eilige Fragen?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MarkingBikeSharingOperator" translate="yes" xml:space="preserve">
|
||||
<source>Operator: {0}.</source>
|
||||
<target state="translated">Betreiber: {0}.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MarkingBikeSharingOperatorNoOperatorInfoAvailable" translate="yes" xml:space="preserve">
|
||||
<source>Contact Operator.</source>
|
||||
<target state="translated">Betreiber Kontaktieren.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MiniSurveyAskForAnswer" translate="yes" xml:space="preserve">
|
||||
<source>Select an answer please.</source>
|
||||
<target state="translated">Bitte eine Antwort auswählen.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MiniSurveyEnterAnswer" translate="yes" xml:space="preserve">
|
||||
<source>Enter answer here please.</source>
|
||||
<target state="translated">Bitte Antwort hier eingeben.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog3_0_243" translate="yes" xml:space="preserve">
|
||||
<source>Mini survey implemented.
|
||||
Minor fixes.</source>
|
||||
<target state="translated">Miniumfrage implementiert.
|
||||
Kleinere Verbesserungen.</target>
|
||||
</trans-unit>
|
||||
</group>
|
||||
</body>
|
||||
</file>
|
||||
|
|
|
@ -10,6 +10,7 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.Logging;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.Repository
|
||||
{
|
||||
|
@ -231,6 +232,14 @@ namespace TINK.Repository
|
|||
requestBuilder.DoSubmitFeedback(bikeId, message, isBikeBroken),
|
||||
UserAgent);
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> DoSubmitMiniSurvey(
|
||||
m_oCopriHost.AbsoluteUri,
|
||||
requestBuilder.DoSubmitMiniSurvey(answers),
|
||||
UserAgent);
|
||||
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <param name="copriHost">Host to connect to. </param>
|
||||
/// <param name="command">Command to log user in.</param>
|
||||
|
@ -612,10 +621,10 @@ namespace TINK.Repository
|
|||
string userAgent = null)
|
||||
{
|
||||
#if !WINDOWS_UWP
|
||||
string l_oBikesAvaialbeResponse;
|
||||
string cancelOrReturnResponse;
|
||||
try
|
||||
{
|
||||
l_oBikesAvaialbeResponse = await PostAsync(copriHost, command, userAgent);
|
||||
cancelOrReturnResponse = await PostAsync(copriHost, command, userAgent);
|
||||
}
|
||||
catch (System.Exception l_oException)
|
||||
{
|
||||
|
@ -633,7 +642,7 @@ namespace TINK.Repository
|
|||
}
|
||||
|
||||
// Extract bikes from response.
|
||||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(l_oBikesAvaialbeResponse)?.shareejson;
|
||||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(cancelOrReturnResponse)?.shareejson;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
|
@ -672,6 +681,40 @@ namespace TINK.Repository
|
|||
#endif
|
||||
}
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
public async Task<ResponseBase> DoSubmitMiniSurvey(
|
||||
string copriHost,
|
||||
string command,
|
||||
string userAgent = null)
|
||||
{
|
||||
#if !WINDOWS_UWP
|
||||
string miniSurveyResponse;
|
||||
try
|
||||
{
|
||||
miniSurveyResponse = await PostAsync(copriHost, command, userAgent);
|
||||
}
|
||||
catch (System.Exception l_oException)
|
||||
{
|
||||
if (l_oException.GetIsConnectFailureException())
|
||||
{
|
||||
throw new WebConnectFailureException("Senden der Miniumfrage aufgrund eines Netzwerkfehlers fehlgeschlagen.", l_oException);
|
||||
}
|
||||
|
||||
if (l_oException.GetIsForbiddenException())
|
||||
{
|
||||
throw new WebForbiddenException("Senden der der Miniumfrage aufgrund eines Netzwerkfehlers fehlgeschlagen.", l_oException);
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
// Extract bikes from response.
|
||||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ResponseBase>>(miniSurveyResponse)?.shareejson;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary> http get- request.</summary>
|
||||
/// <param name="Url">Ulr to get info from.</param>
|
||||
/// <returns>response from server</returns>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Device;
|
||||
|
@ -1633,7 +1634,13 @@ namespace TINK.Repository
|
|||
return null;
|
||||
}
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri) => null;
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> null ;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
|
||||
|
|
|
@ -5,6 +5,7 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.Repository
|
||||
{
|
||||
|
@ -183,6 +184,11 @@ namespace TINK.Repository
|
|||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri) =>
|
||||
throw new System.Exception("Übermittlung von Feedback im Offlinemodus nicht möglich!");
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new System.Exception("Übermittlung von der Miniumfrage im Offlinemodus nicht möglich!");
|
||||
|
||||
public Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
||||
{
|
||||
throw new System.Exception("Anmelden im Offlinemodus nicht möglich!");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Request;
|
||||
|
@ -97,6 +98,10 @@ namespace TINK.Repository
|
|||
bool isBikeBroken,
|
||||
Uri operatorUri);
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
||||
|
||||
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Device;
|
||||
|
||||
namespace TINK.Repository.Request
|
||||
|
@ -85,6 +86,12 @@ namespace TINK.Repository.Request
|
|||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
string DoSubmitFeedback(string bikeId, string message = null, bool isBikeBroken = false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
string DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
||||
}
|
||||
|
||||
/// <summary> Copri locking states</summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
@ -111,5 +112,12 @@ namespace TINK.Repository.Request
|
|||
string bikeId,
|
||||
string message = null,
|
||||
bool isBikeBroken = false) => throw new NotSupportedException();
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
@ -76,21 +78,21 @@ namespace TINK.Repository.Request
|
|||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to reserve.</param>
|
||||
/// <returns>Requst to reserve bike.</returns>
|
||||
public string DoReserve(string bikeId)
|
||||
public string DoReserve(string bikeId)
|
||||
=> $"request=booking_request&bike={bikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
/// <summary> Gets request to cancel reservation. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to cancel reservation for.</param>
|
||||
/// <returns>Requst on cancel booking request.</returns>
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
=> $"request=booking_cancel&bike={p_iBikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
/// <summary> Request to get keys. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
||||
/// <returns>Request to get keys.</returns>
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&genkey=1";
|
||||
|
||||
/// <summary> Gets the request for updating lock state for a booked bike. </summary>
|
||||
|
@ -99,7 +101,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="state">New locking state.</param>
|
||||
/// <returns>Request to update locking state.</returns>
|
||||
public string UpateLockingState(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
|
||||
{
|
||||
{
|
||||
return $"request=booking_update&bike={bikeId}{GetLocationParameters(geolocation)}&lock_state={state}{GetBatteryPercentageParameters(batteryPercentage)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
|
@ -109,7 +111,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
|
||||
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
|
||||
/// <returns>Request to booking bike.</returns>
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&Ilockit_GUID={guid}&state=occupied&lock_state=unlocked{GetBatteryPercentageParameters(batteryPercentage)}";
|
||||
|
||||
/// <summary> Gets request for returning the bike. </summary>
|
||||
|
@ -118,7 +120,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="geolocation">Geolocation of lock when returning bike.</param>
|
||||
/// <returns>Requst on returning request.</returns>
|
||||
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
|
||||
{
|
||||
{
|
||||
return $"request=booking_update" +
|
||||
$"&bike={bikeId}" +
|
||||
$"&authcookie={SessionCookie}{MerchantId}" +
|
||||
|
@ -133,10 +135,10 @@ namespace TINK.Repository.Request
|
|||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
/// <returns>Submit feedback request.</returns>
|
||||
public string DoSubmitFeedback(
|
||||
public string DoSubmitFeedback(
|
||||
string bikeId,
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(message) && !isBikeBroken)
|
||||
{
|
||||
|
@ -161,7 +163,7 @@ namespace TINK.Repository.Request
|
|||
return $"request=user_feedback&bike={bikeId}&bike_broken=1&message={WebUtility.UrlEncode(message)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
private string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
private string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
? $"&voltage={batteryPercentage.ToString(CultureInfo.InvariantCulture)}"
|
||||
: string.Empty;
|
||||
|
||||
|
@ -169,7 +171,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="geolocation">Geolocation or null.</param>
|
||||
private string GetLocationParameters(LocationDto geolocation)
|
||||
{
|
||||
if (geolocation == null)
|
||||
if (geolocation == null)
|
||||
return string.Empty;
|
||||
|
||||
if (geolocation.Accuracy == null)
|
||||
|
@ -188,5 +190,21 @@ namespace TINK.Repository.Request
|
|||
$"{(!string.IsNullOrEmpty(smartDevice.VersionText) ? $"&user_device_version={smartDevice.VersionText}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Identifier) ? $"&user_device_id={smartDevice.Identifier}" : string.Empty)}"
|
||||
: string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
{
|
||||
// Remove entires which invalid keys or values.
|
||||
var validAnsers = answers?.Where(x => !string.IsNullOrEmpty(x.Key?.Trim()) && !string.IsNullOrEmpty(x.Value?.Trim()));
|
||||
// Create quersy
|
||||
return validAnsers != null && validAnsers.Count() > 0
|
||||
? $"request=user_minianswer&{string.Join("&", validAnsers.Select(x => $"{x.Key}={WebUtility.UrlEncode(x.Value)}"))}&authcookie={SessionCookie}{MerchantId}"
|
||||
: $"request=user_minianswer&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
34
TINKLib/Repository/Response/MiniSurvey.cs
Normal file
34
TINKLib/Repository/Response/MiniSurvey.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
[DataContract]
|
||||
public class MiniSurveyResponse
|
||||
{
|
||||
[DataContract]
|
||||
public class Question
|
||||
{
|
||||
[DataMember]
|
||||
public string quest_text { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string type { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public Dictionary<string, string> query { get; private set; }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string title { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string subtitle { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string footer { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public Dictionary<string, Question> questions { get; private set; }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -6,5 +8,8 @@ namespace TINK.Repository.Response
|
|||
/// </summary>
|
||||
public class ReservationCancelReturnResponse : BikesReservedOccupiedResponse
|
||||
{
|
||||
/// <summary> Mini survey.</summary>
|
||||
[DataMember]
|
||||
public MiniSurveyResponse user_miniquery { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
|
@ -250,5 +251,11 @@ namespace TINK.Model.Services.CopriApi
|
|||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
public async Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri opertorUri) =>
|
||||
await HttpsServer.DoSubmitFeedback(bikeId, message, isBikeBroken, opertorUri);
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public async Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> await HttpsServer.DoSubmitMiniSurvey(answers);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
|
@ -61,7 +62,14 @@ namespace TINK.Model.Services.CopriApi
|
|||
return await monkeyStore.DoReturn(bikeId, geolocation, smartDevice, operatorUri);
|
||||
}
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string messge, bool bIsBikeBroke, Uri operatorUri) => throw new NotImplementedException();
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string messge, bool bIsBikeBroke, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
|
||||
public async Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace TINK.ViewModel.Account
|
|||
private int? m_iMyBikesCount;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private readonly IViewService m_oViewService;
|
||||
|
||||
|
@ -56,11 +56,11 @@ namespace TINK.ViewModel.Account
|
|||
/// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param>
|
||||
/// <param name="p_oDefaultPollingPeriode">Default polling periode lenght.</param>
|
||||
/// <param name="p_oMinimumLogEventLevel">Controls logging level.</param>
|
||||
/// <param name="p_oViewService">Interface to view</param>
|
||||
/// <param name="viewService">Interface to view</param>
|
||||
public AccountPageViewModel(
|
||||
ITinkApp tinkApp,
|
||||
Action<string> openUrlInExternalBrowser,
|
||||
IViewService p_oViewService)
|
||||
IViewService viewService)
|
||||
{
|
||||
TinkApp = tinkApp
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No tink app object available.");
|
||||
|
@ -68,7 +68,7 @@ namespace TINK.ViewModel.Account
|
|||
OpenUrlInExternalBrowser = openUrlInExternalBrowser
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No user external browse service available.");
|
||||
|
||||
m_oViewService = p_oViewService
|
||||
m_oViewService = viewService
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No user view service available.");
|
||||
|
||||
m_oViewUpdateManager = new IdlePollingUpdateTaskManager();
|
||||
|
|
|
@ -31,11 +31,11 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
|
|||
protected ISmartDevice SmartDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
/// <summary> Provides an connector object.</summary>
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
protected Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
|
|||
public string ButtonText => AppResources.ActionReturn; // "Miete beenden"
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
|
|||
public string ActionText { get => BikesViewModel.ActionText; private set => BikesViewModel.ActionText = value; }
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
protected ISmartDevice SmartDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
/// <summary> Provides an connector object.</summary>
|
||||
/// <summary> Provides a connect orobject.</summary>
|
||||
protected Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
|
|
|
@ -15,6 +15,7 @@ using TINK.Model.User;
|
|||
using Xamarin.Essentials;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -126,10 +127,10 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
|
||||
var feedBackUri = SelectedBike?.OperatorUri;
|
||||
|
||||
MiniSurveyModel miniSurvey;
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoReturn(
|
||||
miniSurvey = await ConnectorFactory(IsConnected).Command.DoReturn(
|
||||
SelectedBike,
|
||||
currentLocationDto);
|
||||
|
||||
|
@ -229,11 +230,11 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
if (exception is ResponseException copriException)
|
||||
{
|
||||
// Copri server is not reachable.
|
||||
Log.ForContext<BookedOpen>().Information("User selected booked bike {bike} but returing failed. COPRI returned an error.", SelectedBike);
|
||||
Log.ForContext<BookedOpen>().Information("Submitting feedback for bike {bike} failed. COPRI returned an error.", SelectedBike);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<BookedOpen>().Error("User selected availalbe bike {bike} but reserving failed. {@l_oException}", SelectedBike.Id, exception);
|
||||
Log.ForContext<BookedOpen>().Error("Submitting feedback for bike {bike} failed. {@l_oException}", SelectedBike.Id, exception);
|
||||
}
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
|
@ -250,6 +251,10 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
return RequestHandlerFactory.Create(SelectedBike, IsConnectedDelegate, ConnectorFactory, Geolocation, LockService, ViewUpdateManager, SmartDevice, ViewService, BikesViewModel, ActiveUser);
|
||||
}
|
||||
#endif
|
||||
if (miniSurvey != null && miniSurvey.Questions.Count > 0)
|
||||
{
|
||||
await ViewService.PushModalAsync(ViewTypes.MiniSurvey);
|
||||
}
|
||||
|
||||
// Restart polling again.
|
||||
BikesViewModel.ActionText = AppResources.ActivityTextStartingUpdater;
|
||||
|
|
|
@ -15,6 +15,7 @@ using TINK.Model.Bikes.Bike.BluetoothLock;
|
|||
using TINK.Model.User;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -195,10 +196,10 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
|
||||
var feedBackUri = SelectedBike?.OperatorUri;
|
||||
|
||||
MiniSurveyModel miniSurvey;
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoReturn(
|
||||
miniSurvey = await ConnectorFactory(IsConnected).Command.DoReturn(
|
||||
SelectedBike,
|
||||
currentLocation != null
|
||||
? new LocationDto.Builder
|
||||
|
@ -304,11 +305,11 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
if (exception is ResponseException copriException)
|
||||
{
|
||||
// Copri server is not reachable.
|
||||
Log.ForContext<BookedOpen>().Information("User selected booked bike {bike} but returing failed. COPRI returned an error.", SelectedBike);
|
||||
Log.ForContext<BookedOpen>().Information("Submitting feedback for bike {bike} failed. COPRI returned an error.", SelectedBike);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<BookedOpen>().Error("User selected availalbe bike {bike} but reserving failed. {@l_oException}", SelectedBike.Id, exception);
|
||||
Log.ForContext<BookedOpen>().Error("Submitting feedback for bike {bike} failed. {@l_oException}", SelectedBike.Id, exception);
|
||||
}
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
|
@ -325,6 +326,11 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
}
|
||||
#endif
|
||||
|
||||
if (miniSurvey != null && miniSurvey.Questions.Count > 0)
|
||||
{
|
||||
await ViewService.PushModalAsync(ViewTypes.MiniSurvey);
|
||||
}
|
||||
|
||||
BikesViewModel.ActionText = AppResources.ActivityTextStartingUpdater;
|
||||
await ViewUpdateManager().StartUpdateAyncPeridically();
|
||||
BikesViewModel.ActionText = string.Empty;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
public string LockitButtonText => GetType().Name;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace TINK.ViewModel.Bikes
|
|||
protected ISmartDevice SmartDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
|
@ -34,12 +34,12 @@ namespace TINK.ViewModel.Bikes
|
|||
/// </summary>
|
||||
private Exception m_oException;
|
||||
|
||||
/// <summary> Provides an connector object.</summary>
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
protected Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
protected IGeolocation Geolocation { get; }
|
||||
|
||||
/// <summary> Provides an connector object.</summary>
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
protected ILocksService LockService { get; }
|
||||
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
|
@ -88,7 +88,7 @@ namespace TINK.ViewModel.Bikes
|
|||
/// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param>
|
||||
/// <param name="postAction">Executes actions on GUI thread.</param>
|
||||
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...)</param>
|
||||
/// <param name="p_oViewService">Interface to actuate methodes on GUI.</param>
|
||||
/// <param name="viewService">Interface to actuate methodes on GUI.</param>
|
||||
public BikesViewModel(
|
||||
User user,
|
||||
IPermissions permissions,
|
||||
|
|
|
@ -195,7 +195,7 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
// Switch to map page
|
||||
|
||||
#if USEMASTERDETAIL || USEFLYOUT
|
||||
ViewService.ShowPage(ViewTypes.ContactPage, m_oStation?.OperatorData?.Name ?? AppResources.MarkingFeedbackAndContact);
|
||||
ViewService.ShowPage(ViewTypes.ContactPage, AppResources.MarkingFeedbackAndContact);
|
||||
#else
|
||||
await ViewService.ShowPage("//LoginPage");
|
||||
#endif
|
||||
|
|
|
@ -226,8 +226,14 @@ namespace TINK.ViewModel.Info
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary> Text providing mail address and possilbe reasons to contact. </summary>
|
||||
public FormattedString MaliAddressAndMotivationsText
|
||||
public string ProviderNameText
|
||||
=> string.Format("Betreiber: {0}", SelectedStation?.OperatorData?.Name)
|
||||
;
|
||||
/// <summary> Text providing mail address and possilbe reasons to contact. </summary>
|
||||
public FormattedString MailAddressAndMotivationsText
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace TINK.ViewModel.Contact
|
|||
/// <summary> Holds the count of custom icons availalbe.</summary>
|
||||
private const int CUSTOM_ICONS_COUNT = 30;
|
||||
|
||||
/// <summary> Reference on view servcie to show modal notifications and to perform navigation. </summary>
|
||||
/// <summary> Reference on view service to show modal notifications and to perform navigation. </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace TINK.ViewModel.Info.BikeInfo
|
|||
public class BikeInfoViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private readonly IViewService m_oViewService;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace TINK.ViewModel
|
|||
public class LoginPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private readonly IViewService m_oViewService;
|
||||
|
||||
|
@ -178,7 +178,7 @@ namespace TINK.ViewModel
|
|||
{
|
||||
if (CrossConnectivity.Current.IsConnected)
|
||||
{
|
||||
await m_oViewService.PushAsync(ViewTypes.RegisterPage);
|
||||
await m_oViewService.PushAsync(ViewTypes.RegisterPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace TINK.ViewModel.Map
|
|||
/// <summary> Holds the count of custom icons availalbe.</summary>
|
||||
private const int CUSTOM_ICONS_COUNT = 30;
|
||||
|
||||
/// <summary> Reference on view servcie to show modal notifications and to perform navigation. </summary>
|
||||
/// <summary> Reference on view service to show modal notifications and to perform navigation. </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -315,55 +315,52 @@ namespace TINK.ViewModel.Map
|
|||
// Update map page filter
|
||||
ActiveFilterMap = TinkApp.GroupFilterMapPage;
|
||||
|
||||
if (Pins.Count <= 0)
|
||||
{
|
||||
ActionText = AppResources.ActivityTextMyBikesLoadingBikes;
|
||||
ActionText = AppResources.ActivityTextMyBikesLoadingBikes;
|
||||
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckPermissionStatusAsync<LocationPermission>();
|
||||
if (TinkApp.CenterMapToCurrentLocation
|
||||
&& !GeolocationService.IsSimulation
|
||||
&& status != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestPermissionAsync<LocationPermission>();
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckPermissionStatusAsync<LocationPermission>();
|
||||
if (TinkApp.CenterMapToCurrentLocation
|
||||
&& !GeolocationService.IsSimulation
|
||||
&& status != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestPermissionAsync<LocationPermission>();
|
||||
|
||||
if (permissionResult != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
var dialogResult = await m_oViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageCenterMapLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
|
||||
if (dialogResult)
|
||||
{
|
||||
// User decided to give access to locations permissions.
|
||||
PermissionsService.OpenAppSettings();
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
return;
|
||||
}
|
||||
if (dialogResult)
|
||||
{
|
||||
// User decided to give access to locations permissions.
|
||||
PermissionsService.OpenAppSettings();
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = TinkApp.CenterMapToCurrentLocation
|
||||
? await GeolocationService.GetAsync()
|
||||
: null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.Uris.ActiveUri, ActiveFilterMap, currentLocation);
|
||||
}
|
||||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = TinkApp.CenterMapToCurrentLocation
|
||||
? await GeolocationService.GetAsync()
|
||||
: null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.Uris.ActiveUri, ActiveFilterMap, currentLocation);
|
||||
|
||||
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
|
||||
IsConnected = TinkApp.GetIsConnected();
|
||||
var resultStationsAndBikes = await TinkApp.GetConnector(IsConnected).Query.GetBikesAndStationsAsync();
|
||||
|
|
153
TINKLib/ViewModel/MiniSurvey/MiniSurveyViewModel.cs
Normal file
153
TINKLib/ViewModel/MiniSurvey/MiniSurveyViewModel.cs
Normal file
|
@ -0,0 +1,153 @@
|
|||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.MiniSurvey;
|
||||
using TINK.MultilingualResources;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.View;
|
||||
using TINK.ViewModel.MiniSurvey.Question;
|
||||
|
||||
namespace TINK.ViewModel.MiniSurvey
|
||||
{
|
||||
public class MiniSurveyViewModel : ObservableCollection<IMiniSurveyQuestion>
|
||||
{
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
protected Func<bool> IsConnectedDelegate { get; }
|
||||
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
private Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
private MiniSurveyModel MiniSurvey { get; }
|
||||
|
||||
/// <summary> Constructs mini survey view model.</summary>
|
||||
/// <param name="connectorFactory">Connects system to copri for purposes of requesting a bike/ cancel request.</param>
|
||||
/// <param name="viewService">Interface to actuate methodes on GUI.</param>
|
||||
public MiniSurveyViewModel(
|
||||
Func<bool> isConnectedDelegate,
|
||||
Func<bool, IConnector> connectorFactory,
|
||||
IViewService viewService)
|
||||
{
|
||||
IsConnectedDelegate = isConnectedDelegate
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(MiniSurveyViewModel)}-object. No connector available.");
|
||||
|
||||
ConnectorFactory = connectorFactory
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(MiniSurveyViewModel)}-object. No connector available.");
|
||||
|
||||
ViewService = viewService
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(MiniSurveyViewModel)}-object. No view available.");
|
||||
|
||||
MiniSurvey = new MiniSurveyModel
|
||||
{
|
||||
Title = "Bitte unterstützen Sie unsere Begleitforschung",
|
||||
Subtitle = "Ihre drei Antworten werden anonym gespeichert.",
|
||||
Footer = "Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"
|
||||
};
|
||||
|
||||
MiniSurvey.Questions.Add(
|
||||
"q1",
|
||||
new MiniSurveyModel.QuestionModel
|
||||
{
|
||||
Text = "1. Was war der Hauptzweck dieser Ausleihe?",
|
||||
Type = MiniSurveyModel.Type.SingleAnswer
|
||||
});
|
||||
|
||||
MiniSurvey.Questions.Add(
|
||||
"q2",
|
||||
new MiniSurveyModel.QuestionModel
|
||||
{
|
||||
Text = "2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?",
|
||||
Type = MiniSurveyModel.Type.SingleAnswer
|
||||
});
|
||||
|
||||
MiniSurvey.Questions.Add(
|
||||
"q3",
|
||||
new MiniSurveyModel.QuestionModel
|
||||
{
|
||||
Text = "3. Haben Sie Anmerkungen oder Anregungen?",
|
||||
Type = MiniSurveyModel.Type.CustomText
|
||||
});
|
||||
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt1", "a. Einkauf");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt2", "b. Kinderbeförderung");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt3", "c. Lastentransport");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt4", "d. Freizeit");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt5", "e. Ausprobieren");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt6", "f. Sonstiges");
|
||||
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt1", "a. Auto");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt2", "b. Motorrad oder Motorroller");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt3", "c. Bus oder Bahn");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt4", "d. Eigenes Fahrrad");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt5", "e. Zu Fuß");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt6", "f. Keines (ich hätte die Fahrt sonst nicht gemacht)");
|
||||
|
||||
Title = MiniSurvey.Title;
|
||||
Subtitle = MiniSurvey.Subtitle;
|
||||
Footer = MiniSurvey.Footer;
|
||||
|
||||
foreach (var question in MiniSurvey.Questions)
|
||||
{
|
||||
switch (question.Value.Type)
|
||||
{
|
||||
case MiniSurveyModel.Type.SingleAnswer:
|
||||
Add(new CheckOneViewModel(
|
||||
new KeyValuePair<string, string>(question.Key, question.Value.Text),
|
||||
question.Value.PossibleAnswers));
|
||||
break;
|
||||
|
||||
case MiniSurveyModel.Type.CustomText:
|
||||
Add(new FreeTextViewModel(new KeyValuePair<string, string>(question.Key, question.Value.Text)));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Subtitle { get; set; }
|
||||
|
||||
public string Footer { get; set; }
|
||||
|
||||
/// <summary> Processes request to perform a copri action (reserve bike and cancel reservation). </summary>
|
||||
public System.Windows.Input.ICommand OnButtonClicked => new Xamarin.Forms.Command(async () =>
|
||||
{
|
||||
Log.ForContext<MiniSurveyViewModel>().Information($"User result {this[0].Answer.Value}, {this[1].Answer.Value}");
|
||||
|
||||
var isConnected = IsConnectedDelegate();
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(isConnected).Command.DoSubmitMiniSurvey(this.ToDictionary(x => x.Question.Key, x => x.Answer.Key));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (exception is ResponseException copriException)
|
||||
{
|
||||
// Copri server is not reachable.
|
||||
Log.ForContext<MiniSurveyViewModel>().Information("Submitting mini survay answer failed. COPRI returned an error.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<MiniSurveyViewModel>().Error("Submitting mini survay answer failed. {@l_oException}", exception);
|
||||
}
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.ErrorReturnSubmitFeedbackTitle,
|
||||
AppResources.ErrorReturnSubmitFeedbackMessage,
|
||||
AppResources.MessageAnswerOk);
|
||||
}
|
||||
|
||||
await ViewService.PopModalAsync();
|
||||
});
|
||||
}
|
||||
}
|
45
TINKLib/ViewModel/MiniSurvey/Question/CheckOneViewModel.cs
Normal file
45
TINKLib/ViewModel/MiniSurvey/Question/CheckOneViewModel.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace TINK.ViewModel.MiniSurvey.Question
|
||||
{
|
||||
public class CheckOneViewModel : IMiniSurveyQuestion
|
||||
{
|
||||
/// <summary> Constructs object. </summary>
|
||||
/// <param name="question">Holds the question with key asked to user.</param>
|
||||
/// <param name="answers">Holds the list of possible answers with their option keys.</param>
|
||||
public CheckOneViewModel(
|
||||
KeyValuePair<string, string> question,
|
||||
Dictionary<string, string> answers)
|
||||
{
|
||||
Question = question;
|
||||
Answers = answers ?? new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
/// <summary> Holds the question with key asked to user. </summary>
|
||||
public KeyValuePair<string, string> Question { get; }
|
||||
|
||||
/// <summary> Holds the question with key asked to user exposed to GUI. </summary>
|
||||
public string QuestionText => Question.Value;
|
||||
|
||||
/// <summary> Holds the list of possible answers with their option keys. </summary>
|
||||
public Dictionary<string, string> Answers { get; }
|
||||
|
||||
/// <summary> Holds the list of possible answers exposed to GUI. </summary>
|
||||
public IEnumerable<string> AnswersText
|
||||
{
|
||||
get => Answers.Select(x => x.Value).ToList();
|
||||
set => AnswersText = Answers.Select(x => x.Value).ToList();
|
||||
}
|
||||
|
||||
/// <summary> Holds the users selected answer (one of answers) with its option key. </summary>
|
||||
public KeyValuePair<string, string> Answer { get; private set; }
|
||||
|
||||
/// <summary> Holds the users selected answer (one of answers) in GUI. </summary>
|
||||
public string AnswerText
|
||||
{
|
||||
get => Answer.Value;
|
||||
set => Answer = Answers.FirstOrDefault(x => x.Value == value);
|
||||
}
|
||||
}
|
||||
}
|
32
TINKLib/ViewModel/MiniSurvey/Question/FreeTextViewModel.cs
Normal file
32
TINKLib/ViewModel/MiniSurvey/Question/FreeTextViewModel.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.ViewModel.MiniSurvey.Question
|
||||
{
|
||||
public class FreeTextViewModel : IMiniSurveyQuestion
|
||||
{
|
||||
/// <summary> Constructs object. </summary>
|
||||
/// <param name="question">Holds the question with key asked to user.</param>
|
||||
/// <param name="answers">Holds the list of possible answers with their option keys.</param>
|
||||
public FreeTextViewModel(
|
||||
KeyValuePair<string, string> question)
|
||||
{
|
||||
Question = question;
|
||||
}
|
||||
|
||||
/// <summary> Holds the question with key asked to user. </summary>
|
||||
public KeyValuePair<string, string> Question { get; }
|
||||
|
||||
/// <summary> Holds the question with key asked to user exposed to GUI. </summary>
|
||||
public string QuestionText => Question.Value;
|
||||
|
||||
/// <summary> Holds the users selected answer with its option key. </summary>
|
||||
public KeyValuePair<string, string> Answer { get; private set; }
|
||||
|
||||
/// <summary> Holds the list of possible answers exposed to GUI. </summary>
|
||||
public string AnswerText
|
||||
{
|
||||
get => null;
|
||||
set => Answer = new KeyValuePair<string, string>(value, null);
|
||||
}
|
||||
}
|
||||
}
|
13
TINKLib/ViewModel/MiniSurvey/Question/IMiniSurveyQuestion.cs
Normal file
13
TINKLib/ViewModel/MiniSurvey/Question/IMiniSurveyQuestion.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.ViewModel.MiniSurvey.Question
|
||||
{
|
||||
public interface IMiniSurveyQuestion
|
||||
{
|
||||
/// <summary> Holds the question with key asked to user. </summary>
|
||||
KeyValuePair<string, string> Question { get; }
|
||||
|
||||
/// <summary> Holds the users selected answer with its option key. </summary>
|
||||
KeyValuePair<string, string> Answer { get; }
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ namespace TINK.ViewModel
|
|||
public class SettingsPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private IViewService m_oViewService;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
WhatsNewPage,
|
||||
BikesAtStation,
|
||||
ContactPage,
|
||||
SelectStationPage
|
||||
SelectStationPage,
|
||||
MiniSurvey
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ using static TINK.Repository.CopriCallsMemory;
|
|||
using BikeInfo = TINK.Model.Bike.BluetoothLock.BikeInfo;
|
||||
using TINK.Model.User.Account;
|
||||
using Xamarin.Forms;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TestTINKLib.Fixtures.Connector
|
||||
{
|
||||
|
@ -844,7 +845,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
|
@ -877,7 +878,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_Name()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
|
@ -894,7 +895,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_Number()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
|
@ -911,7 +912,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_FreeTimePerSession()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
|
@ -928,7 +929,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_FeeEuroPerHour()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
|
@ -945,7 +946,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_AboEuroPerMonth()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
|
@ -962,7 +963,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_Name_Empty()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
|
@ -973,7 +974,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_Number_Empty()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
|
@ -984,7 +985,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_FreeTimePerSession_Empty()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
|
@ -995,7 +996,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_FeeEuroPerHour_Empty()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
|
@ -1006,7 +1007,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestCreateTariffDescription_AboEuroPerMonth_Empty()
|
||||
{
|
||||
var tariffDescription = TINK.Repository.Response.JsonConvertRethrow.DeserializeObject<TINK.Repository.Response.TariffDescription>(
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
|
@ -1018,7 +1019,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
public void TestCreateTariffDescription_Name_Null()
|
||||
{
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create((TINK.Repository.Response.TariffDescription)null).Name,
|
||||
BikeInfoFactory.Create((TariffDescription)null).Name,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
|
@ -1026,7 +1027,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
public void TestCreateTariffDescription_Number_Null()
|
||||
{
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create((TINK.Repository.Response.TariffDescription)null).Number,
|
||||
BikeInfoFactory.Create((TariffDescription)null).Number,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
|
@ -1034,7 +1035,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
public void TestCreateTariffDescription_FreeTimePerSession_Null()
|
||||
{
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create((TINK.Repository.Response.TariffDescription)null).FreeTimePerSession,
|
||||
BikeInfoFactory.Create((TariffDescription)null).FreeTimePerSession,
|
||||
Is.EqualTo(TimeSpan.Zero));
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1043,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
public void TestCreateTariffDescription_FeeEuroPerHour_Null()
|
||||
{
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create((TINK.Repository.Response.TariffDescription)null).FeeEuroPerHour,
|
||||
BikeInfoFactory.Create((TariffDescription)null).FeeEuroPerHour,
|
||||
Is.NaN);
|
||||
}
|
||||
|
||||
|
@ -1050,8 +1051,230 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
public void TestCreateTariffDescription_AboEuroPerMonth_Null()
|
||||
{
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create((TINK.Repository.Response.TariffDescription)null).AboEuroPerMonth,
|
||||
BikeInfoFactory.Create((TariffDescription)null).AboEuroPerMonth,
|
||||
Is.NaN);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""user_miniquery"" : {
|
||||
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
||||
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
||||
""questions"" : {
|
||||
""q3"" : {
|
||||
""quest_text"" : ""3. Haben Sie Anmerkungen oder Anregungen?"",
|
||||
""type"" : ""text"",
|
||||
""query"" : {
|
||||
""opt1"" : """"
|
||||
}
|
||||
},
|
||||
""q1"" : {
|
||||
""type"" : ""check_one"",
|
||||
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
||||
""query"" : {
|
||||
""opt2"" : ""b. Kinderbeförderung"",
|
||||
""opt5"" : ""e. Ausprobieren"",
|
||||
""opt4"" : ""d. Freizeit"",
|
||||
""opt1"" : ""a. Einkauf"",
|
||||
""opt3"" : ""c. Lastentransport"",
|
||||
""opt6"" : ""f. Sonstiges""
|
||||
}
|
||||
},
|
||||
""q2"" : {
|
||||
""type"" : ""check_one"",
|
||||
""quest_text"" : ""2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?"",
|
||||
""query"" : {
|
||||
""opt6"" : ""f. Keines (ich hätte die Fahrt sonst nicht gemacht)"",
|
||||
""opt3"" : ""c. Bus oder Bahn"",
|
||||
""opt1"" : ""a. Auto"",
|
||||
""opt2"" : ""b. Motorrad oder Motorroller"",
|
||||
""opt7"" : ""g. Sonstige"",
|
||||
""opt4"" : ""d. Eigenes Fahrrad"",
|
||||
""opt5"" : ""e. Zu Fuß""
|
||||
}
|
||||
}
|
||||
},
|
||||
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var survey = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
survey,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Title,
|
||||
Is.EqualTo("Bitte unterstützen Sie unsere Begleitforschung"));
|
||||
|
||||
Assert.That(
|
||||
survey.Subtitle,
|
||||
Is.EqualTo("Ihre drei Antworten werden anonym gespeichert."));
|
||||
|
||||
Assert.That(
|
||||
survey.Footer,
|
||||
Is.EqualTo("Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"));
|
||||
|
||||
Assert.That(
|
||||
survey.Questions.Count,
|
||||
Is.EqualTo(3));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_Null()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var survey = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
survey,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Title,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Subtitle,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Footer,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_EmptyQuery()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""user_miniquery"" : {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var survey = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
survey,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Title,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Subtitle,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Footer,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_InvalidQuestion_KeyNull()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""user_miniquery"" : {
|
||||
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
||||
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
||||
""questions"" : {
|
||||
"""" : {
|
||||
""type"" : ""check_one"",
|
||||
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
||||
""query"" : {
|
||||
""opt2"" : ""b. Kinderbeförderung"",
|
||||
""opt5"" : ""e. Ausprobieren"",
|
||||
""opt4"" : ""d. Freizeit"",
|
||||
""opt1"" : ""a. Einkauf"",
|
||||
""opt3"" : ""c. Lastentransport"",
|
||||
""opt6"" : ""f. Sonstiges""
|
||||
}
|
||||
},
|
||||
},
|
||||
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var survey = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
survey,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Questions.Count,
|
||||
Is.EqualTo(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_InvalidQuestion_ValueNull()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""user_miniquery"" : {
|
||||
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
||||
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
||||
""questions"" : {
|
||||
""q1"" : {
|
||||
},
|
||||
},
|
||||
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var survey = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
survey,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
survey.Questions.Count,
|
||||
Is.EqualTo(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
20
TestShareeLib/Model/MiniSurvey/TestMiniSurveyModel.cs
Normal file
20
TestShareeLib/Model/MiniSurvey/TestMiniSurveyModel.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TestShareeLib.Model.MiniSurvey
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestMiniSurveyModel
|
||||
{
|
||||
[Test]
|
||||
public void TestCtor()
|
||||
{
|
||||
Assert.That(
|
||||
new MiniSurveyModel().Questions,
|
||||
Is.Not.Null);
|
||||
}
|
||||
}
|
||||
}
|
16
TestShareeLib/Model/MiniSurvey/TestQuestionModel.cs
Normal file
16
TestShareeLib/Model/MiniSurvey/TestQuestionModel.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TestShareeLib.Model.MiniSurvey
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestQuestionModel
|
||||
{
|
||||
public void TestCtro()
|
||||
{
|
||||
Assert.That(
|
||||
new MiniSurveyModel.QuestionModel().PossibleAnswers,
|
||||
Is.Not.Null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ using System;
|
|||
using TINK.Repository.Exception;
|
||||
using TINK.Repository.Request;
|
||||
|
||||
namespace UITest.Fixtures.ObjectTests.Connector.Request
|
||||
namespace TestShareeLib.Repository.Request
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestRequestBuilder
|
|
@ -1,9 +1,10 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Repository.Request;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Connector.Request
|
||||
namespace TestShareeLib.Repository.Request
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestRequestBuilderLoggedIn
|
||||
|
@ -108,5 +109,37 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector.Request
|
|||
"request=booking_update&bike=42&authcookie=456123&Ilockit_GUID=0000f00d-1212-efde-1523-785fef13d123&state=occupied&lock_state=unlocked",
|
||||
new RequestBuilderLoggedIn("123", "456").DoBook("42", new Guid("0000f00d-1212-efde-1523-785fef13d123"), double.NaN));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoSubmitMiniSurvey()
|
||||
{
|
||||
Assert.That(
|
||||
new RequestBuilderLoggedIn("Merchy", "Keksi").DoSubmitMiniSurvey(new Dictionary<string, string> { { "q1", "opt5" }, { "q2", "opt4" }, { "q3", "der Freitext" } }),
|
||||
Is.EqualTo("request=user_minianswer&q1=opt5&q2=opt4&q3=der+Freitext&authcookie=KeksiMerchy"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoSubmitMiniSurveyNull()
|
||||
{
|
||||
Assert.That(
|
||||
new RequestBuilderLoggedIn("Merchy", "Keksi").DoSubmitMiniSurvey(null),
|
||||
Is.EqualTo("request=user_minianswer&authcookie=KeksiMerchy"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoSubmitMiniSurveyEmptyDict()
|
||||
{
|
||||
Assert.That(
|
||||
new RequestBuilderLoggedIn("Merchy", "Keksi").DoSubmitMiniSurvey(new Dictionary<string, string>()),
|
||||
Is.EqualTo("request=user_minianswer&authcookie=KeksiMerchy"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoSubmitMiniSurveyFilterInvalidEntries()
|
||||
{
|
||||
Assert.That(
|
||||
new RequestBuilderLoggedIn("Merchy", "Keksi").DoSubmitMiniSurvey(new Dictionary<string, string> { { "q1", "opt5" }, { "", "opt99" }, { "q99", "" }, { "q2", "opt4" }, { "q3", "der Freitext" } }),
|
||||
Is.EqualTo("request=user_minianswer&q1=opt5&q2=opt4&q3=der+Freitext&authcookie=KeksiMerchy"));
|
||||
}
|
||||
}
|
||||
}
|
153
TestShareeLib/Repository/Response/TestMiniSurvey.cs
Normal file
153
TestShareeLib/Repository/Response/TestMiniSurvey.cs
Normal file
|
@ -0,0 +1,153 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using TINK.Repository.Response;
|
||||
|
||||
namespace TestShareeLib.Repository.Response
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestMiniSurvey
|
||||
{
|
||||
[DataContract]
|
||||
public class MiniSurveyTestContainer
|
||||
{
|
||||
[DataMember]
|
||||
public MiniSurveyResponse user_miniquery { get; set;}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtor()
|
||||
{
|
||||
var mini = JsonConvert.DeserializeObject<MiniSurveyTestContainer>(@"{
|
||||
""user_miniquery"" : {
|
||||
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
||||
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert."",
|
||||
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
||||
""questions"" : {
|
||||
""q1"" : {
|
||||
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
||||
""type"" : ""check_one"",
|
||||
""query"" : {
|
||||
""opt5"" : ""e. Ausprobieren"",
|
||||
""opt3"" : ""c. Lastentransport"",
|
||||
""opt6"" : ""f. Sonstiges"",
|
||||
""opt1"" : ""a. Einkauf"",
|
||||
""opt4"" : ""d. Freizeit"",
|
||||
""opt2"" : ""b. Kinderbeförderung""
|
||||
}
|
||||
},
|
||||
""q2"" : {
|
||||
""type"" : ""check_one"",
|
||||
""quest_text"" : ""2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?"",
|
||||
""query"" : {
|
||||
""opt1"" : ""a. Auto"",
|
||||
""opt7"" : ""g. Sonstige"",
|
||||
""opt2"" : ""b. Motorrad oder Motorroller"",
|
||||
""opt4"" : ""d. Eigenes Fahrrad"",
|
||||
""opt6"" : ""f. Keines (ich hätte die Fahrt sonst nicht gemacht)"",
|
||||
""opt5"" : ""e. Zu Fuß"",
|
||||
""opt3"" : ""c. Bus oder Bahn""
|
||||
},
|
||||
},
|
||||
""q3"" : {
|
||||
""type"" : ""text"",
|
||||
""quest_text"" : ""3. Haben Sie Anmerkungen oder Anregungen?"",
|
||||
""query"" : {
|
||||
""opt1"" : """"
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
mini.user_miniquery.title,
|
||||
Is.EqualTo("Bitte unterstützen Sie unsere Begleitforschung"));
|
||||
|
||||
Assert.That(
|
||||
mini.user_miniquery.subtitle,
|
||||
Is.EqualTo("Ihre drei Antworten werden anonym gespeichert."));
|
||||
|
||||
Assert.That(
|
||||
mini.user_miniquery.subtitle,
|
||||
Is.EqualTo("Ihre drei Antworten werden anonym gespeichert."));
|
||||
|
||||
Assert.That(
|
||||
mini.user_miniquery.questions.Count,
|
||||
Is.EqualTo(3));
|
||||
|
||||
Assert.That(
|
||||
mini.user_miniquery.questions.Count,
|
||||
Is.EqualTo(3));
|
||||
|
||||
// Verify first question.
|
||||
var query = mini.user_miniquery.questions.OrderBy(x => x.Key).ToArray()[0];
|
||||
|
||||
Assert.That(
|
||||
query.Value.quest_text,
|
||||
Is.EqualTo("1. Was war der Hauptzweck dieser Ausleihe?"));
|
||||
|
||||
Assert.That(
|
||||
query.Value.type,
|
||||
Is.EqualTo("check_one"));
|
||||
|
||||
Assert.That(
|
||||
query.Value.query.Count,
|
||||
Is.EqualTo(6));
|
||||
|
||||
var answer = query.Value.query.OrderBy(x => x.Key).ToArray()[0];
|
||||
|
||||
Assert.That(
|
||||
answer.Value,
|
||||
Is.EqualTo("a. Einkauf"));
|
||||
|
||||
answer = query.Value.query.OrderBy(x => x.Key).ToArray()[2];
|
||||
Assert.That(
|
||||
answer.Value,
|
||||
Is.EqualTo("c. Lastentransport"));
|
||||
|
||||
// Verify second question.
|
||||
query = mini.user_miniquery.questions.OrderBy(x => x.Key).ToArray()[1];
|
||||
|
||||
Assert.That(
|
||||
query.Value.quest_text,
|
||||
Is.EqualTo("2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?"));
|
||||
|
||||
Assert.That(
|
||||
query.Value.type,
|
||||
Is.EqualTo("check_one"));
|
||||
|
||||
Assert.That(
|
||||
query.Value.query.Count,
|
||||
Is.EqualTo(7));
|
||||
|
||||
answer = query.Value.query.OrderBy(x => x.Key).ToArray()[1];
|
||||
|
||||
Assert.That(
|
||||
answer.Value,
|
||||
Is.EqualTo("b. Motorrad oder Motorroller"));
|
||||
|
||||
// Verify thired question.
|
||||
query = mini.user_miniquery.questions.OrderBy(x => x.Key).ToArray()[2];
|
||||
|
||||
Assert.That(
|
||||
query.Value.quest_text,
|
||||
Is.EqualTo("3. Haben Sie Anmerkungen oder Anregungen?"));
|
||||
|
||||
Assert.That(
|
||||
query.Value.type,
|
||||
Is.EqualTo("text"));
|
||||
|
||||
Assert.That(
|
||||
query.Value.query.Count,
|
||||
Is.EqualTo(1));
|
||||
|
||||
answer = query.Value.query.OrderBy(x => x.Key).ToArray()[0];
|
||||
|
||||
Assert.That(
|
||||
answer.Value,
|
||||
Is.EqualTo(""));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TINK.ViewModel.MiniSurvey.Question;
|
||||
|
||||
namespace TestShareeLib.ViewModel.MiniSurvey.Question
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCheckOneViewModel
|
||||
{
|
||||
[Test]
|
||||
public void TestCtor()
|
||||
{
|
||||
var vm = new CheckOneViewModel(
|
||||
new KeyValuePair<string, string>("q5", "wie ist das Wetter heute"),
|
||||
new Dictionary<string, string> { { "opt1", "regnerisch"}, { "opt2", "bewölkt" }, { "opt3", "sonnig" } });
|
||||
|
||||
Assert.That(
|
||||
vm.Question.Key,
|
||||
Is.EqualTo("q5"),
|
||||
"Key is essential for COPRI request.");
|
||||
|
||||
Assert.That(
|
||||
vm.QuestionText,
|
||||
Is.EqualTo("wie ist das Wetter heute"),
|
||||
"Question shown to user.");
|
||||
|
||||
Assert.That(
|
||||
string.Join(',', vm.AnswersText),
|
||||
Is.EqualTo("regnerisch,bewölkt,sonnig"),
|
||||
"Gui must show three options.");
|
||||
|
||||
Assert.That(
|
||||
vm.AnswerText,
|
||||
Is.EqualTo(null),
|
||||
"GUI should not show selected entry.");
|
||||
|
||||
Assert.That(
|
||||
vm.Answer.Key,
|
||||
Is.EqualTo(null),
|
||||
"View model shold not hold any selected endtry.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelected()
|
||||
{
|
||||
var vm = new CheckOneViewModel(
|
||||
new KeyValuePair<string, string>("q5", "wie ist das Wetter heute"),
|
||||
new Dictionary<string, string> { { "opt1", "regnerisch" }, { "opt2", "bewölkt" }, { "opt3", "sonnig" } });
|
||||
|
||||
vm.AnswerText = "sonnig"; // Member is called if user selects an entry.
|
||||
Assert.That(
|
||||
vm.Answer.Key,
|
||||
Is.EqualTo("opt3"),
|
||||
"Key matching to selected item must be set as answer.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TINK.ViewModel.MiniSurvey.Question;
|
||||
|
||||
namespace TestShareeLib.ViewModel.MiniSurvey.Question
|
||||
{
|
||||
[TestFixture]
|
||||
class TestFreeTextViewModel
|
||||
{
|
||||
[Test]
|
||||
public void TestCtor()
|
||||
{
|
||||
var vm = new FreeTextViewModel(
|
||||
new KeyValuePair<string, string>("q9", "War das essen heute gut?"));
|
||||
|
||||
Assert.That(
|
||||
vm.Question.Key,
|
||||
Is.EqualTo("q9"),
|
||||
"Key is essential for COPRI request.");
|
||||
|
||||
Assert.That(
|
||||
vm.QuestionText,
|
||||
Is.EqualTo("War das essen heute gut?"),
|
||||
"Question shown to user.");
|
||||
|
||||
Assert.That(
|
||||
vm.AnswerText,
|
||||
Is.EqualTo(null),
|
||||
"GUI should not show selected entry.");
|
||||
|
||||
Assert.That(
|
||||
vm.Answer.Key,
|
||||
Is.EqualTo(null),
|
||||
"View model shold not hold any selected endtry.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelected()
|
||||
{
|
||||
var vm = new FreeTextViewModel(
|
||||
new KeyValuePair<string, string>("q9", "War das essen heute gut?"));
|
||||
|
||||
vm.AnswerText = "Sehr wohlschmeckend!"; // Member is called if user enters text.
|
||||
|
||||
Assert.That(
|
||||
vm.Answer.Key,
|
||||
Is.EqualTo("Sehr wohlschmeckend!"),
|
||||
"Key is the answer for COPRI.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using Newtonsoft.Json;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -337,7 +338,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns(x => throw new WebConnectFailureException("Context info", new Exception("hoppla")));
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x => throw new WebConnectFailureException("Context info", new Exception("hoppla")));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // Requsthandler factory queries lock state to create appropriate request handler object.
|
||||
|
@ -408,7 +409,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
NotAtStationException.IsNotAtStation("Failure 2178: bike 1545 out of GEO fencing. 15986 meter distance to next station 42. OK: bike 1545 locked confirmed", out NotAtStationException notAtStationException);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x =>
|
||||
throw notAtStationException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
|
@ -478,7 +479,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
NoGPSDataException.IsNoGPSData("Failure 2245: No GPS data, state change forbidden.", out NoGPSDataException noGPSDataException);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x =>
|
||||
throw noGPSDataException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
|
@ -546,7 +547,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x =>
|
||||
throw new ReturnBikeException(JsonConvert.DeserializeObject<ReservationCancelReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
|
@ -614,7 +615,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns(x => throw new Exception("Exception message."));
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x => throw new Exception("Exception message."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // Requsthandler factory queries lock state to create appropriate request handler object.
|
||||
|
|
|
@ -21,6 +21,7 @@ using TINK.Repository.Request;
|
|||
using Newtonsoft.Json;
|
||||
using TINK.Repository.Response;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -472,7 +473,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns(x => throw new WebConnectFailureException("Context info", new System.Exception("hoppla")));
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x => throw new WebConnectFailureException("Context info", new System.Exception("hoppla")));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
||||
|
@ -541,7 +542,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns(x => throw new System.Exception("Exception message."));
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x => throw new System.Exception("Exception message."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
||||
|
@ -612,7 +613,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
NotAtStationException.IsNotAtStation("Failure 2178: bike 1545 out of GEO fencing. 15986 meter distance to next station 77. OK: bike 1545 locked confirmed", out NotAtStationException notAtStationException);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x =>
|
||||
throw notAtStationException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
@ -684,7 +685,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
NoGPSDataException.IsNoGPSData("Failure 2245: No GPS data, state change forbidden.", out NoGPSDataException noGPSDataException);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x =>
|
||||
throw noGPSDataException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
@ -754,7 +755,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x =>
|
||||
throw new ReturnBikeException(JsonConvert.DeserializeObject<ReservationCancelReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
|
|
@ -6,6 +6,7 @@ using TINK.Repository.Response;
|
|||
using static TINK.Repository.CopriCallsMemory;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TestTINKLib.Mocks.Connector
|
||||
{
|
||||
|
@ -88,6 +89,11 @@ namespace TestTINKLib.Mocks.Connector
|
|||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
{
|
||||
return server.GetBikesAvailableAsync();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
|
@ -64,6 +65,11 @@ namespace TestTINKLib.Mocks.Connector
|
|||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetBikesAvailableAsync)}.");
|
||||
|
|
|
@ -70,8 +70,6 @@
|
|||
<Compile Include="Fixtures\ObjectTests\Connector\TestConnectorCache.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestCopriCallsHttps.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestCopriCallsStatic.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\Request\TestRequestBuilder.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\Request\TestRequestBuilderLoggedIn.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\Response\TestResponseHelper.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestCommandLoggedIn.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestConnector.cs" />
|
||||
|
|
Loading…
Add table
Reference in a new issue