Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 63540b2

Browse files
ArticleManager and ArticlesController refactored
1 parent e23f12c commit 63540b2

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

‎src/v2/CmnSoftwareBackend.API/Controllers/ArticlesController.cs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ public async Task<IActionResult> GetById(int articleId, bool includeArticlePictu
4444
[HttpGet]
4545
[ProducesResponseType(200)]
4646
[Route("[action]")]
47+
public async Task<IActionResult> GetArticleByCommentWithoutUserId(int commentWithoutUserId)
48+
{
49+
var result = await _articleService.GetArticleByCommentWithoutUserIdAsync(commentWithoutUserId);
50+
return Ok(new SuccessDataApiResult(result, Url.Link("", new { Controller = "Articles", Action = "GetArticleByCommentWithoutUserId" })));
51+
}
52+
[HttpGet]
53+
[ProducesResponseType(200)]
54+
[Route("[action]")]
55+
public async Task<IActionResult> GetArticleByCommentWithUserId(int commentWithUserId)
56+
{
57+
var result = await _articleService.GetArticleByCommentWithUserIdAsync(commentWithUserId);
58+
return Ok(new SuccessDataApiResult(result, Url.Link("", new { Controller = "Articles", Action = "GetArticleByCommentWithUserId" })));
59+
}
60+
[HttpGet]
61+
[ProducesResponseType(200)]
62+
[Route("[action]")]
4763
public async Task<IActionResult> GetArticleByUserId(Guid userId)
4864
{
4965
var article = await _articleService.GetArticleByUserId(userId);

‎src/v2/CmnSoftwareBackend.API/c:\temp\cmn-internal-nlog.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6417,3 +6417,11 @@ ClientConnectionId:00000000-0000-0000-0000-000000000000
64176417
2021年09月29日 17:57:09.2386 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
64186418
2021年09月29日 17:57:09.3245 Info Configuration initialized.
64196419
2021年09月29日 17:57:09.3254 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False
6420+
2021年09月29日 18:28:32.8768 Info Message Template Auto Format enabled
6421+
2021年09月29日 18:28:32.8979 Info Loading assembly: NLog.Web.AspNetCore
6422+
2021年09月29日 18:28:32.9334 Info Adding target FileTarget(Name=allfile)
6423+
2021年09月29日 18:28:32.9346 Info Adding target FileTarget(Name=ownFile-web)
6424+
2021年09月29日 18:28:32.9440 Info Adding target DatabaseTarget(Name=database)
6425+
2021年09月29日 18:28:33.0378 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
6426+
2021年09月29日 18:28:33.1284 Info Configuration initialized.
6427+
2021年09月29日 18:28:33.1291 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False

‎src/v2/CmnSoftwareBackend.Services/Concrete/ArticleManager.cs‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,23 @@ public async Task<IDataResult> GetArticleByArticlePictureId(int articlePictureId
9595
return new DataResult(ResultStatus.Success, query);
9696
}
9797

98-
public Task<IDataResult> GetArticleByCommentWithoutUserIdAsync(int commentWithoutUserId)
98+
public asyncTask<IDataResult> GetArticleByCommentWithoutUserIdAsync(int commentWithoutUserId)
9999
{
100-
throw new NotImplementedException();
100+
IQueryable<Article> query = DbContext.Set<Article>();
101+
query = query.AsNoTracking().Where(a => a.CommentWithoutUsers.Any(ab => ab.Id == commentWithoutUserId));
102+
if (!await DbContext.CommentWithoutUsers.AnyAsync(a => a.Id == commentWithoutUserId))
103+
throw new NotFoundArgumentException(Messages.General.ValidationError(), new Error("Böyle bir mesaj bulunamadı", "commentWithoutUserId"));
104+
105+
return new DataResult(ResultStatus.Success, query);
101106
}
102107

103-
public Task<IDataResult> GetArticleByCommentWithUserIdAsync(int commentWithUserId)
108+
public asyncTask<IDataResult> GetArticleByCommentWithUserIdAsync(int commentWithUserId)
104109
{
105-
throw new NotImplementedException();
110+
IQueryable<Article> query = DbContext.Set<Article>();
111+
var comment = query.AsNoTracking().Where(a => a.CommentWithUsers.Any(a=>a.Id == commentWithUserId));
112+
if (comment is null)
113+
throw new NotFoundArgumentException(Messages.General.ValidationError(), new Error("Bu kullanıcı Id'sine ait bir yorum bulunamadı","commentWithUserId"));
114+
return new DataResult(ResultStatus.Success, query);
106115
}
107116

108117
public async Task<IDataResult> GetArticleByUserId(Guid userId)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /