Skip to content

Commit 77b64d5

Browse files
David BritchDavid Britch
authored andcommitted
Replaced async void methods with async Task methods, where appropriate.
Also removed AnimationExtensions as it’s not used.
1 parent 14efed1 commit 77b64d5

4 files changed

Lines changed: 15 additions & 37 deletions

File tree

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/AnimationExtension.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/BasketViewModel.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public decimal Total
5959
}
6060
}
6161

62-
public ICommand AddCommand => new Command<BasketItem>(AddItem);
62+
public ICommand AddCommand => new Command<BasketItem>(async (item) => await AddItemAsync(item));
6363

6464
public ICommand CheckoutCommand => new Command(async () => await CheckoutAsync());
6565

@@ -80,22 +80,22 @@ public override async Task InitializeAsync(object navigationData)
8080
foreach (var basketItem in basket.Items)
8181
{
8282
BadgeCount += basketItem.Quantity;
83-
AddBasketItem(basketItem);
83+
await AddBasketItemAsync(basketItem);
8484
}
8585
}
8686

8787
MessagingCenter.Unsubscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct);
88-
MessagingCenter.Subscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct, (sender, arg) =>
88+
MessagingCenter.Subscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct, async (sender, arg) =>
8989
{
9090
BadgeCount++;
9191

92-
AddCatalogItem(arg);
92+
await AddCatalogItemAsync(arg);
9393
});
9494

9595
await base.InitializeAsync(navigationData);
9696
}
9797

98-
private void AddCatalogItem(CatalogItem item)
98+
private async Task AddCatalogItemAsync(CatalogItem item)
9999
{
100100
BasketItems.Add(new BasketItem
101101
{
@@ -106,26 +106,23 @@ private void AddCatalogItem(CatalogItem item)
106106
Quantity = 1
107107
});
108108

109-
ReCalculateTotal();
109+
await ReCalculateTotal();
110110
}
111111

112-
private void AddItem(BasketItem item)
112+
private async Task AddItemAsync(BasketItem item)
113113
{
114114
BadgeCount++;
115-
116-
AddBasketItem(item);
117-
115+
await AddBasketItemAsync(item);
118116
RaisePropertyChanged(() => BasketItems);
119117
}
120118

121-
private void AddBasketItem(BasketItem item)
119+
private async Task AddBasketItemAsync(BasketItem item)
122120
{
123121
BasketItems.Add(item);
124-
125-
ReCalculateTotal();
122+
await ReCalculateTotal();
126123
}
127124

128-
private async void ReCalculateTotal()
125+
private async Task ReCalculateTotal()
129126
{
130127
Total = 0;
131128

src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public CatalogType Type
8888

8989
public ICommand AddCatalogItemCommand => new Command<CatalogItem>(AddCatalogItem);
9090

91-
public ICommand FilterCommand => new Command(Filter);
91+
public ICommand FilterCommand => new Command(async () => await FilterAsync());
9292

93-
public ICommand ClearFilterCommand => new Command(ClearFilter);
93+
public ICommand ClearFilterCommand => new Command(async () => await ClearFilterAsync());
9494

9595
public override async Task InitializeAsync(object navigationData)
9696
{
@@ -110,7 +110,7 @@ private void AddCatalogItem(CatalogItem catalogItem)
110110
MessagingCenter.Send(this, MessengerKeys.AddProduct, catalogItem);
111111
}
112112

113-
private async void Filter()
113+
private async Task FilterAsync()
114114
{
115115
if (Brand == null && Type == null)
116116
{
@@ -126,7 +126,7 @@ private async void Filter()
126126
IsBusy = false;
127127
}
128128

129-
private async void ClearFilter()
129+
private async Task ClearFilterAsync()
130130
{
131131
IsBusy = true;
132132

src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
<Compile Include="Converters\ToUpperConverter.cs" />
6161
<Compile Include="Effects\LineColorEffect.cs" />
6262
<Compile Include="Exceptions\ServiceAuthenticationException.cs" />
63-
<Compile Include="Extensions\AnimationExtension.cs" />
6463
<Compile Include="Extensions\ObservableExtension.cs" />
6564
<Compile Include="GlobalSettings.cs" />
6665
<Compile Include="Helpers\EasingHelper.cs" />

0 commit comments

Comments
 (0)