Skip to content

Commit

Permalink
Updated AwesomeResult
Browse files Browse the repository at this point in the history
  • Loading branch information
apfohl committed Jan 31, 2024
1 parent a97fb67 commit ebdfaf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions HotwiredBooks/Controllers/BooksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ from formData in ParseFormData(collection)
from book in booksRepository.Create(formData.Title, formData.Author)
select book
)
.Map(async book =>
.MapAsync(async book =>
View(new BooksCreateViewModel(book, (await booksRepository.All()).Count())) as IActionResult)
.OrElse(StatusCode(500, "An unexpected error occurred on the server."));

[HttpGet]
public Task<IActionResult> Edit(Guid id) =>
booksRepository
.Lookup(id)
.Map(book => View(new BooksEditViewModel(book)) as IActionResult)
.MapAsync(book => View(new BooksEditViewModel(book)) as IActionResult)
.OrElse(StatusCode(500, "An unexpected error occurred on the server."));

[HttpPatch, HttpPut]
Expand All @@ -57,7 +57,7 @@ book with
)
select updatedBook
)
.Map(book => ViewComponentRenderer.RenderAsync("Book", new BooksEditViewModel(book)))
.MapAsync(book => ViewComponentRenderer.RenderAsync("Book", new BooksEditViewModel(book)))
.OrElse(StatusCode(500, "An unexpected error occurred on the server."));

[HttpPost]
Expand All @@ -66,8 +66,8 @@ select updatedBook
public Task<IActionResult> Delete(Guid id) =>
booksRepository
.Lookup(id)
.Bind(booksRepository.Delete)
.Map(async book =>
.BindAsync(booksRepository.Delete)
.MapAsync(async book =>
View(new BooksDeleteViewModel(book, (await booksRepository.All()).Count())) as IActionResult)
.OrElse(StatusCode(500, "An unexpected error occurred on the server."));

Expand Down
2 changes: 1 addition & 1 deletion HotwiredBooks/HotwiredBooks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AwesomeResult" Version="0.5.1" />
<PackageReference Include="AwesomeResult" Version="0.6.0" />
<PackageReference Include="bridgefield.FoundationalBits" Version="0.1.2" />
<PackageReference Include="Humanizer" Version="2.14.1" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
Expand Down
5 changes: 4 additions & 1 deletion HotwiredBooksTests/HotwiredBooksTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.10.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
</ItemGroup>

Expand Down

0 comments on commit ebdfaf3

Please sign in to comment.