created all endpoints
This commit is contained in:
42
.idea/.idea.BookHive/.idea/workspace.xml
generated
42
.idea/.idea.BookHive/.idea/workspace.xml
generated
@@ -5,7 +5,13 @@
|
|||||||
<projectFile profileName="https">BookHive/BookHive.csproj</projectFile>
|
<projectFile profileName="https">BookHive/BookHive.csproj</projectFile>
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="4c0ad985-5b6e-4587-85a5-1b48273bdb1d" name="Changes" comment="" />
|
<list default="true" id="4c0ad985-5b6e-4587-85a5-1b48273bdb1d" name="Changes" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/BookHive/Endpoints/Books/UpdateBookEndpoit.cs" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/BookHive/Endpoints/Loans/PatchReturnLoanEndpoint.cs" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/BookHive/Endpoints/Members/UpdateMemberEndpoint.cs" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/BookHive/Endpoints/Reviews/CreateReviewEndpoint.cs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.BookHive/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.BookHive/.idea/workspace.xml" afterDir="false" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
@@ -14,17 +20,28 @@
|
|||||||
<component name="DpaMonitoringSettings">
|
<component name="DpaMonitoringSettings">
|
||||||
<option name="firstShow" value="false" />
|
<option name="firstShow" value="false" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
<component name="HighlightingSettingsPerFile">
|
<component name="HighlightingSettingsPerFile">
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/93684fd365e5462ea2f83c3be1bf1d6149908/6c/02001336/HttpServiceCollectionExtensions.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/93684fd365e5462ea2f83c3be1bf1d6149908/6c/02001336/HttpServiceCollectionExtensions.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/5023b5be698d783ffe9f42b2e944a85a7a66b61bc5e19c76c591036343fd16/RepositoryBaseOfT.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/5023b5be698d783ffe9f42b2e944a85a7a66b61bc5e19c76c591036343fd16/RepositoryBaseOfT.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Books/CreateBookEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Books/CreateBookEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Books/UpdateBookEndpoit.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Loans/CreateLoanEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Loans/CreateLoanEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Loans/PatchReturnLoanEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Members/CreateMemberEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Members/CreateMemberEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Members/UpdateMemberEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/BookHive/Endpoints/Reviews/CreateReviewEndpoint.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
|
||||||
<component name="ProjectColorInfo">{
|
<component name="ProjectColorInfo">{
|
||||||
"associatedIndex": 5
|
"associatedIndex": 5
|
||||||
}</component>
|
}</component>
|
||||||
<component name="ProjectId" id="3Aiuj7MQNTWLiWp2KXQdFXkcvkz" />
|
<component name="ProjectId" id="3Aiuj7MQNTWLiWp2KXQdFXkcvkz" />
|
||||||
|
<component name="ProjectLevelVcsManager">
|
||||||
|
<ConfirmationsSetting value="2" id="Add" />
|
||||||
|
</component>
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
@@ -35,6 +52,7 @@
|
|||||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||||
|
"git-widget-placeholder": "master",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}]]></component>
|
||||||
@@ -80,16 +98,36 @@
|
|||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1773087844958</updated>
|
<updated>1773087844958</updated>
|
||||||
<workItem from="1773087846465" duration="527000" />
|
<workItem from="1773087846465" duration="527000" />
|
||||||
<workItem from="1773088517368" duration="1882000" />
|
<workItem from="1773088517368" duration="3370000" />
|
||||||
</task>
|
</task>
|
||||||
|
<task id="LOCAL-00001" summary="first commit">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1773090602496</created>
|
||||||
|
<option name="number" value="00001" />
|
||||||
|
<option name="presentableId" value="LOCAL-00001" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1773090602496</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00002" summary="first commit">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1773090621044</created>
|
||||||
|
<option name="number" value="00002" />
|
||||||
|
<option name="presentableId" value="LOCAL-00002" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1773090621044</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="3" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
|
||||||
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
|
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||||
|
<MESSAGE value="first commit" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="first commit" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
|||||||
30
BookHive/Endpoints/Books/UpdateBookEndpoit.cs
Normal file
30
BookHive/Endpoints/Books/UpdateBookEndpoit.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using BookHive.DTO.Book;
|
||||||
|
using BookHive.Models;
|
||||||
|
using BookHive.Repositories;
|
||||||
|
using BookHive.Specifications.Books;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace BookHive.Endpoints.Books;
|
||||||
|
|
||||||
|
public class UpdateBookEndpoit(BookRepository bookRepository, AutoMapper.IMapper mapper) : Endpoint<UpdateBookDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/books/{@Id}/", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateBookDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Book? book = await bookRepository.SingleOrDefaultAsync(new GetBookByIdSpec(req.Id), ct);
|
||||||
|
if (book is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapper.Map(req, book);
|
||||||
|
await bookRepository.SaveChangesAsync(ct);
|
||||||
|
await Send.OkAsync(cancellation: ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
BookHive/Endpoints/Loans/PatchReturnLoanEndpoint.cs
Normal file
35
BookHive/Endpoints/Loans/PatchReturnLoanEndpoint.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using BookHive.Models;
|
||||||
|
using BookHive.Repositories;
|
||||||
|
using BookHive.Specifications.Loans;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace BookHive.Endpoints.Loans;
|
||||||
|
|
||||||
|
public class PatchReturnLoanRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public DateOnly ReturnDate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PatchReturnLoanEndpoint(LoanRepository loanRepository) : Endpoint<PatchReturnLoanRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Patch("/loans/{@Id}/return/", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(PatchReturnLoanRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Loan? loan = await loanRepository.SingleOrDefaultAsync(new GetLoanByIdSpec(req.Id), ct);
|
||||||
|
if (loan is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
await Send.OkAsync(cancellation: ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
loan?.ReturnDate = req.ReturnDate;
|
||||||
|
await loanRepository.SaveChangesAsync(ct);
|
||||||
|
await Send.OkAsync(cancellation: ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
BookHive/Endpoints/Members/UpdateMemberEndpoint.cs
Normal file
30
BookHive/Endpoints/Members/UpdateMemberEndpoint.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using BookHive.DTO.Member;
|
||||||
|
using BookHive.Models;
|
||||||
|
using BookHive.Repositories;
|
||||||
|
using BookHive.Specifications.Members;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace BookHive.Endpoints.Members;
|
||||||
|
|
||||||
|
public class UpdateMemberEndpoint(MemberRepository memberRepository, AutoMapper.IMapper mapper) : Endpoint<UpdateMemberDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/members/{@Id}/", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateMemberDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Member? member = await memberRepository.SingleOrDefaultAsync(new GetMemberByIdSpec(req.Id), ct);
|
||||||
|
if (member is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapper.Map(req, member);
|
||||||
|
await memberRepository.SaveChangesAsync(ct);
|
||||||
|
await Send.OkAsync(cancellation: ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
BookHive/Endpoints/Reviews/CreateReviewEndpoint.cs
Normal file
42
BookHive/Endpoints/Reviews/CreateReviewEndpoint.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using BookHive.DTO.Review;
|
||||||
|
using BookHive.Models;
|
||||||
|
using BookHive.Repositories;
|
||||||
|
using BookHive.Specifications.Books;
|
||||||
|
using BookHive.Specifications.Members;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace BookHive.Endpoints.Reviews;
|
||||||
|
|
||||||
|
public class CreateReviewEndpoint(
|
||||||
|
ReviewRepository reviewRepository,
|
||||||
|
MemberRepository memberRepository,
|
||||||
|
BookRepository bookRepository,
|
||||||
|
AutoMapper.IMapper mapper)
|
||||||
|
: Endpoint<CreateReviewDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/books/{@BookId}/reviews/");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateReviewDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Book? book = await bookRepository.SingleOrDefaultAsync(new GetBookByIdSpec(req.BookId), ct);
|
||||||
|
if (book is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Member? member = await memberRepository.SingleOrDefaultAsync(new GetMemberByIdSpec(req.MemberId), ct);
|
||||||
|
if (member is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await reviewRepository.AddAsync(mapper.Map<Review>(req), ct);
|
||||||
|
await Send.OkAsync(cancellation: ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user