Skip to content

Commit 429db6d

Browse files
authored
(#341) Updates to sample Nugets (#356)
* (#341) Run dotnet outdated on samples. * (#341) Updated packages for todoapp * (#341) Corrections to tutorial code
1 parent ca2650c commit 429db6d

File tree

17 files changed

+136
-47
lines changed

17 files changed

+136
-47
lines changed

Directory.Packages.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
<PackageVersion Include="FluentAssertions.Web" Version="1.8.0" />
1111
<PackageVersion Include="LiteDB" Version="5.0.21" />
1212
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.4" />
13-
<PackageVersion Include="Microsoft.AspNetCore.OData" Version="9.3.0" />
13+
<PackageVersion Include="Microsoft.AspNetCore.OData" Version="9.3.1" />
1414
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.4" />
15-
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.49.0" />
15+
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.51.0" />
1616
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
1717
<PackageVersion Include="Microsoft.EntityFrameworkCore.Cosmos" Version="9.0.4" />
1818
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.4" />
1919
<PackageVersion Include="Microsoft.EntityFrameworkCore.Proxies" Version="9.0.4" />
2020
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.4" />
2121
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.4" />
2222
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.4" />
23-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.4" />
23+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.5" />
2424
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.4" />
25-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
25+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.5" />
2626
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
2727
<PackageVersion Include="Microsoft.OData.Core" Version="8.2.3" />
2828
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />

docs/tutorial/client/part-1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,4 @@ In the [next tutorial](./part-2.md), I'm going to talk about authenticating clie
216216
[todomvc]: https://github.com/CommunityToolkit/Datasync/tree/main/samples/todoapp-mvc
217217
[todoapp]: https://github.com/CommunityToolkit/Datasync/tree/main/samples/todoapp-tutorial
218218
[CommunityToolkit.MVVM]: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/
219-
[CommunityToolkit.Datasync.Client]: https://www.nuget.org/packages/CommunityToolkit.Datasync.Client#readme-body-tab
219+
[CommunityToolkit.Datasync.Client]: https://www.nuget.org/packages/CommunityToolkit.Datasync.Client#readme-body-tab

samples/datasync-server/src/Sample.Datasync.Server/Sample.Datasync.Server.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="CommunityToolkit.Datasync.Server" Version="9.0.1" />
11-
<PackageReference Include="CommunityToolkit.Datasync.Server.EntityFrameworkCore" Version="9.0.1" />
12-
<PackageReference Include="CommunityToolkit.Datasync.Server.NSwag" Version="9.0.1" />
13-
<PackageReference Include="CommunityToolkit.Datasync.Server.OpenApi" Version="9.0.1" />
14-
<PackageReference Include="CommunityToolkit.Datasync.Server.Swashbuckle" Version="9.0.1" />
15-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.2" />
17-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
10+
<PackageReference Include="CommunityToolkit.Datasync.Server" Version="9.0.2" />
11+
<PackageReference Include="CommunityToolkit.Datasync.Server.EntityFrameworkCore" Version="9.0.2" />
12+
<PackageReference Include="CommunityToolkit.Datasync.Server.NSwag" Version="9.0.2" />
13+
<PackageReference Include="CommunityToolkit.Datasync.Server.OpenApi" Version="9.0.2" />
14+
<PackageReference Include="CommunityToolkit.Datasync.Server.Swashbuckle" Version="9.0.2" />
15+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.5" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.5">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
</PackageReference>

samples/todoapp-mvc/TodoApp.Service/TodoApp.Service.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="CommunityToolkit.Datasync.Server" Version="8.0.3" />
11-
<PackageReference Include="CommunityToolkit.Datasync.Server.EntityFrameworkCore" Version="8.0.3" />
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
13-
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
10+
<PackageReference Include="CommunityToolkit.Datasync.Server" Version="8.0.7" />
11+
<PackageReference Include="CommunityToolkit.Datasync.Server.EntityFrameworkCore" Version="8.0.7" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.5" />
13+
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="3.0.71" />
1414
</ItemGroup>
1515

1616
<Target Name="CleanWwwRootLib" AfterTargets="Clean">

samples/todoapp-tutorial/ClientApp/App.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ClientApp.Interfaces;
1+
using ClientApp.Interfaces;
22
using ClientApp.Services;
33
using ClientApp.ViewModels;
44
using Microsoft.Extensions.DependencyInjection;
@@ -29,7 +29,7 @@ private void InitializeApplication()
2929
{
3030
using IServiceScope scope = Services.CreateScope();
3131
IAppInitializer initializer = scope.ServiceProvider.GetRequiredService<IAppInitializer>();
32-
initializer.Initialize();
32+
_ = initializer.Initialize();
3333
}
3434

3535
/// <summary>

samples/todoapp-tutorial/ClientApp/ClientApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="CommunityToolkit.Datasync.Client" Version="9.0.0" />
12+
<PackageReference Include="CommunityToolkit.Datasync.Client" Version="9.0.2" />
1313
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
1414
</ItemGroup>
1515

samples/todoapp-tutorial/ClientApp/Converters/BooleanToImageConverter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
15
using System.Globalization;
26
using System.Windows.Data;
37
using System.Windows.Media.Imaging;

samples/todoapp-tutorial/ClientApp/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Window x:Class="ClientApp.MainWindow"
1+
<Window x:Class="ClientApp.MainWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using ClientApp.Interfaces;
6+
using ClientApp.Models;
7+
using CommunityToolkit.Mvvm.ComponentModel;
8+
using CommunityToolkit.Mvvm.Input;
9+
using System.ComponentModel;
10+
11+
namespace ClientApp.ViewModels;
12+
13+
public partial class TodoListViewModel(ITodoService todoService, IAlertService alertService) : ObservableRecipient
14+
{
15+
[ObservableProperty]
16+
private bool isRefreshing;
17+
18+
[ObservableProperty]
19+
private BindingList<TodoItem> items = [];
20+
21+
[ObservableProperty]
22+
private string addItemTitle = string.Empty;
23+
24+
[RelayCommand]
25+
public async Task AddItemAsync(CancellationToken cancellationToken = default)
26+
{
27+
try
28+
{
29+
var addition = await todoService.AddTodoItemAsync(AddItemTitle, cancellationToken);
30+
Items.Add(addition);
31+
AddItemTitle = string.Empty;
32+
}
33+
catch (Exception ex)
34+
{
35+
await alertService.ShowErrorAlertAsync("Error adding item", ex.Message);
36+
}
37+
}
38+
39+
[RelayCommand]
40+
public async Task UpdateItemAsync(TodoItem item, CancellationToken cancellationToken = default)
41+
{
42+
try
43+
{
44+
TodoItem? storedItem = await todoService.GetTodoItemAsync(item.Id, cancellationToken);
45+
if (storedItem is not null)
46+
{
47+
storedItem.IsComplete = !storedItem.IsComplete;
48+
var replacedItem = await todoService.ReplaceTodoItemAsync(storedItem, cancellationToken);
49+
var idx = Items.IndexOf(item);
50+
Items[idx] = replacedItem;
51+
}
52+
else
53+
{
54+
await alertService.ShowErrorAlertAsync("Item not found", "The item was not found in the database.");
55+
}
56+
}
57+
catch (Exception ex)
58+
{
59+
await alertService.ShowErrorAlertAsync("Error updating item", ex.Message);
60+
}
61+
}
62+
63+
[RelayCommand]
64+
public async Task RefreshItemsAsync(CancellationToken cancellationToken = default)
65+
{
66+
try
67+
{
68+
IsRefreshing = true;
69+
List<TodoItem> dbItems = await todoService.GetAllTodoItemsAsync(cancellationToken);
70+
Items.Clear();
71+
foreach (var dbItem in dbItems)
72+
{
73+
Items.Add(dbItem);
74+
}
75+
}
76+
catch (Exception ex)
77+
{
78+
await alertService.ShowErrorAlertAsync("Error refreshing items", ex.Message);
79+
}
80+
finally
81+
{
82+
IsRefreshing = false;
83+
}
84+
}
85+
}

samples/todoapp-tutorial/ServerApp/ServerApp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="CommunityToolkit.Datasync.Server" Version="9.0.0" />
11-
<PackageReference Include="CommunityToolkit.Datasync.Server.InMemory" Version="9.0.0" />
10+
<PackageReference Include="CommunityToolkit.Datasync.Server" Version="9.0.2" />
11+
<PackageReference Include="CommunityToolkit.Datasync.Server.InMemory" Version="9.0.2" />
1212
</ItemGroup>
1313

1414
</Project>

0 commit comments

Comments
 (0)