Skip to content

Commit a95fad3

Browse files
Add rowVersion support for api optimistic concurrency
Target net10, for now (WASM debugging is currently broken in 8, 9, pending dotnet/aspnetcore#62080
1 parent 870bd08 commit a95fad3

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/Harri.SchoolDemoAPI.BlazorWASM/Components/EditStudentForm.razor

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
{
7171
Loading = true;
7272
ExistingStudent = await _studentClient.GetStudent(StudentId.Value);
73+
var response = await _studentClient.GetStudentRestResponse(StudentId.Value);
74+
//var etag = response.Headers.Single(x => string.Equals(x.Name, "etag", StringComparison.CurrentCultureIgnoreCase));
75+
//Console.WriteLine(etag);
76+
//Console.WriteLine(RowVersion);
77+
7378
if (ExistingStudent is not null)
7479
{
7580
Student = new NewStudentDto()
@@ -135,7 +140,7 @@
135140
Name = Student.Name,
136141
GPA = Student.GPA
137142
};
138-
var response = await _studentClient.UpdateStudent(StudentId!.Value, existingStudent, null);
143+
var response = await _studentClient.UpdateStudent(StudentId!.Value, existingStudent, ExistingStudent?.RowVersion!);
139144

140145
if (response is false)
141146
{

src/Harri.SchoolDemoAPI.BlazorWASM/Harri.SchoolDemoAPI.BlazorWASM.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
88
</PropertyGroup>
9-
109
<ItemGroup>
1110
<PackageReference Include="Harri.SchoolDemoApi.Client" Version="1.0.17" />
1211
<PackageReference Include="Harri.SchoolDemoAPI.Models" Version="1.0.17" />
13-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
14-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.0-preview.6.25358.103" />
13+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.0-preview.6.25358.103" PrivateAssets="all" />
1514
<PackageReference Include="MudBlazor" Version="8.0.0-rc.2" />
1615
</ItemGroup>
1716

src/Tests/Harri.SchoolDemoAPI.BlazorWASM.Tests.UI.E2E/Features/DeleteStudent.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Feature: DeleteStudent
33
Delete individual students
44

5+
#TODO add a conditional cleanup here (only when the test fails, before performing its own delete action)
56
Scenario: Delete a student
67
Given I am on the edit page for a new student "Tester Student To Delete"
78
When I click delete

src/Tests/Harri.SchoolDemoAPI.BlazorWASM.Tests.Unit/Harri.SchoolDemoAPI.BlazorWASM.Tests.Unit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

0 commit comments

Comments
 (0)