Use Refit for APIs, make data/API stack async
This commit is contained in:
parent
9c4f01ab13
commit
b00158daa7
17 changed files with 196 additions and 124 deletions
21
Start/Shared/Api/IBookmarkContainersApi.cs
Normal file
21
Start/Shared/Api/IBookmarkContainersApi.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Refit;
|
||||
|
||||
namespace Start.Shared.Api {
|
||||
public interface IBookmarkContainersApi {
|
||||
[Get("/")]
|
||||
Task<ApiResponse<IEnumerable<BookmarkContainerDto>>> GetAllBookmarkContainers();
|
||||
|
||||
[Get("/{bookmarkContainerId}")]
|
||||
Task<ApiResponse<BookmarkContainerDto?>> GetBookmarkContainer(int bookmarkContainerId);
|
||||
|
||||
[Post("/Create")]
|
||||
Task<ApiResponse<BookmarkContainerDto?>> CreateBookmarkContainer(
|
||||
[Body(BodySerializationMethod.Serialized)] string title);
|
||||
|
||||
[Delete("/Delete/{bookmarkContainerId}")]
|
||||
Task<HttpResponseMessage> DeleteBookmarkContainer(int bookmarkContainerId);
|
||||
}
|
||||
}
|
||||
15
Start/Shared/Api/IBookmarksApi.cs
Normal file
15
Start/Shared/Api/IBookmarksApi.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System.Threading.Tasks;
|
||||
using Refit;
|
||||
|
||||
namespace Start.Shared.Api {
|
||||
public interface IBookmarksApi {
|
||||
[Get("{bookmarkId}")]
|
||||
Task<BookmarkDto?> GetBookmark(int bookmarkId);
|
||||
|
||||
[Post("/Create")]
|
||||
Task CreateBookmark(string title, string url, string? notes, int bookmarkGroupId);
|
||||
|
||||
[Delete("/Delete/{bookmarkId}")]
|
||||
Task DeleteBookmark(int bookmarkId);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,4 +9,14 @@
|
|||
<ItemGroup>
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Refit" />
|
||||
<None Remove="Api\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Api\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Refit" Version="6.1.15" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue