1
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
public async Task<GetArticleQueryResponse> Handle(GetArticleQuery request, CancellationToken cancellationToken)
|
public async Task<GetArticleQueryResponse> Handle(GetArticleQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var article = await _db.Articles.FindAsync(request.Id);
|
var article = await _db.Articles.FindAsync(request.Id);
|
||||||
if (article == null)
|
if (article == null|| article.Status== ArticleStatusEnum.Deleted)
|
||||||
{
|
{
|
||||||
throw new ArticleNotExistsException(request.Id);
|
throw new ArticleNotExistsException(request.Id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
private readonly BlogDbContext _db = db;
|
private readonly BlogDbContext _db = db;
|
||||||
public async Task<List<GetLatestArticlesQueryResponse>> Handle(GetLatestArticlesQuery request, CancellationToken cancellationToken)
|
public async Task<List<GetLatestArticlesQueryResponse>> Handle(GetLatestArticlesQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var query = _db.Articles.AsNoTracking().Where(x=>x.Type==ArticleTypeEnum.Article).OrderByDescending(x => x.Id).Select(article =>
|
var query = _db.Articles.AsNoTracking().Where(x=>x.Type==ArticleTypeEnum.Article x.Status != ArticleStatusEnum.Deleted).OrderByDescending(x => x.Id).Select(article =>
|
||||||
new GetLatestArticlesQueryResponse(
|
new GetLatestArticlesQueryResponse(
|
||||||
article.Id,
|
article.Id,
|
||||||
article.Title,
|
article.Title,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
public async Task<GetPageQueryResponse> Handle(GetPageQuery request, CancellationToken cancellationToken)
|
public async Task<GetPageQueryResponse> Handle(GetPageQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var page = await _db.Articles.FindAsync(request.Id);
|
var page = await _db.Articles.FindAsync(request.Id);
|
||||||
if (page == null)
|
if (page == null || page.Status == ArticleStatusEnum.Deleted)
|
||||||
{
|
{
|
||||||
throw new PageNotExistsException(request.Id);
|
throw new PageNotExistsException(request.Id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user