-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
17 additions
and
15 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/Moonglade.Data/Specifications/BlogThemeForIdNameSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Moonglade.Data.Entities; | ||
|
||
namespace Moonglade.Data.Specifications; | ||
|
||
public class BlogThemeForIdNameSpec : Specification<BlogThemeEntity, ThemeSegment> | ||
{ | ||
public BlogThemeForIdNameSpec() | ||
{ | ||
Query.Select(p => new(p.Id, p.ThemeName)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Moonglade.Data; | ||
|
||
public record ThemeSegment(int Id, string Name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
using MediatR; | ||
using Moonglade.Data; | ||
using Moonglade.Data.Entities; | ||
using Moonglade.Data.Specifications; | ||
|
||
namespace Moonglade.Theme; | ||
|
||
public record GetAllThemeSegmentQuery : IRequest<List<ThemeSegment>>; | ||
|
||
public class GetAllThemeSegmentQueryHandler(MoongladeRepository<BlogThemeEntity> repo) : IRequestHandler<GetAllThemeSegmentQuery, List<ThemeSegment>> | ||
{ | ||
public Task<List<ThemeSegment>> Handle(GetAllThemeSegmentQuery request, CancellationToken ct) | ||
{ | ||
return repo.SelectAsync(p => new ThemeSegment | ||
{ | ||
Id = p.Id, | ||
Name = p.ThemeName | ||
}, ct); | ||
} | ||
public Task<List<ThemeSegment>> Handle(GetAllThemeSegmentQuery request, CancellationToken ct) => | ||
repo.ListAsync(new BlogThemeForIdNameSpec(), ct); | ||
} |
This file was deleted.
Oops, something went wrong.