From 8b3bd3b7e2db2d9be0419382ef16f9789657abae Mon Sep 17 00:00:00 2001 From: David Britch Date: Tue, 7 Mar 2017 11:56:18 +0000 Subject: [PATCH] Ensured that calls to NavigationService.NavigateAsync are awaited. --- .../ViewModels/BasketViewModel.cs | 6 +++--- .../ViewModels/CheckoutViewModel.cs | 4 ++-- .../ViewModels/LoginViewModel.cs | 12 ++++++------ .../ViewModels/MainViewModel.cs | 6 +++--- .../ViewModels/ProfileViewModel.cs | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/BasketViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/BasketViewModel.cs index 7890784de..a19e8dcdd 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/BasketViewModel.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/BasketViewModel.cs @@ -63,7 +63,7 @@ namespace eShopOnContainers.Core.ViewModels public ICommand AddCommand => new Command(AddItem); - public ICommand CheckoutCommand => new Command(Checkout); + public ICommand CheckoutCommand => new Command(async () => await CheckoutAsync()); public override async Task InitializeAsync(object navigationData) { @@ -151,11 +151,11 @@ namespace eShopOnContainers.Core.ViewModels }, authToken); } - private void Checkout() + private async Task CheckoutAsync() { if (BasketItems.Any()) { - NavigationService.NavigateToAsync(BasketItems); + await NavigationService.NavigateToAsync(BasketItems); } } } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CheckoutViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CheckoutViewModel.cs index 197306e3b..41b8220e6 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CheckoutViewModel.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CheckoutViewModel.cs @@ -66,7 +66,7 @@ namespace eShopOnContainers.Core.ViewModels } } - public ICommand CheckoutCommand => new Command(Checkout); + public ICommand CheckoutCommand => new Command(async () => await CheckoutAsync()); public override async Task InitializeAsync(object navigationData) { @@ -125,7 +125,7 @@ namespace eShopOnContainers.Core.ViewModels } } - private async void Checkout() + private async Task CheckoutAsync() { try { diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs index ef1f4f31b..53f5998a0 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/LoginViewModel.cs @@ -121,15 +121,15 @@ namespace eShopOnContainers.Core.ViewModels } } - public ICommand MockSignInCommand => new Command(MockSignInAsync); + public ICommand MockSignInCommand => new Command(async () => await MockSignInAsync()); public ICommand SignInCommand => new Command(async () => await SignInAsync()); public ICommand RegisterCommand => new Command(Register); - public ICommand NavigateCommand => new Command(NavigateAsync); + public ICommand NavigateCommand => new Command(async (url) => await NavigateAsync(url)); - public ICommand SettingsCommand => new Command(SettingsAsync); + public ICommand SettingsCommand => new Command(async () => await SettingsAsync()); public override Task InitializeAsync(object navigationData) { @@ -146,7 +146,7 @@ namespace eShopOnContainers.Core.ViewModels return base.InitializeAsync(navigationData); } - private async void MockSignInAsync() + private async Task MockSignInAsync() { IsBusy = true; IsValid = true; @@ -219,7 +219,7 @@ namespace eShopOnContainers.Core.ViewModels } } - private async void NavigateAsync(string url) + private async Task NavigateAsync(string url) { if (url.Equals(GlobalSetting.Instance.LogoutCallback)) { @@ -246,7 +246,7 @@ namespace eShopOnContainers.Core.ViewModels } } - private async void SettingsAsync() + private async Task SettingsAsync() { await NavigationService.NavigateToAsync(); } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs index b1bbceb31..aa279ee0d 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs @@ -9,7 +9,7 @@ namespace eShopOnContainers.Core.ViewModels { public class MainViewModel : ViewModelBase { - public ICommand SettingsCommand => new Command(Settings); + public ICommand SettingsCommand => new Command(async () => await SettingsAsync()); public override Task InitializeAsync(object navigationData) { @@ -25,9 +25,9 @@ namespace eShopOnContainers.Core.ViewModels return base.InitializeAsync(navigationData); } - private void Settings() + private async Task SettingsAsync() { - NavigationService.NavigateToAsync(); + await NavigationService.NavigateToAsync(); } } } \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/ProfileViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/ProfileViewModel.cs index 4c6ac2b2a..9856b7a21 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/ProfileViewModel.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/ProfileViewModel.cs @@ -32,9 +32,9 @@ namespace eShopOnContainers.Core.ViewModels } } - public ICommand LogoutCommand => new Command(LogoutAsync); + public ICommand LogoutCommand => new Command(async () => await LogoutAsync()); - public ICommand OrderDetailCommand => new Command(OrderDetail); + public ICommand OrderDetailCommand => new Command(async (order) => await OrderDetailAsync(order)); public override async Task InitializeAsync(object navigationData) { @@ -48,7 +48,7 @@ namespace eShopOnContainers.Core.ViewModels IsBusy = false; } - private async void LogoutAsync() + private async Task LogoutAsync() { IsBusy = true; @@ -59,9 +59,9 @@ namespace eShopOnContainers.Core.ViewModels IsBusy = false; } - private void OrderDetail(Order order) + private async Task OrderDetailAsync(Order order) { - NavigationService.NavigateToAsync(order); + await NavigationService.NavigateToAsync(order); } } } \ No newline at end of file