-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dominikus1993/webapp
add web app
- Loading branch information
Showing
50 changed files
with
1,934 additions
and
21 deletions.
There are no files selected for viewing
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
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
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
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
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
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,12 @@ | ||
using DevNews.Core.Model; | ||
|
||
namespace DevNews.Core.Dto | ||
{ | ||
public record ArticleDto(string Title, string? Content, string Link) | ||
{ | ||
public ArticleDto(Article article) : this(article.Title, article.Content, article.Link) | ||
{ | ||
|
||
} | ||
} | ||
} |
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
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,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using DevNews.Core.Dto; | ||
using DevNews.Core.Model; | ||
using DevNews.Core.Repository; | ||
|
||
namespace DevNews.Core.UseCases | ||
{ | ||
public record GetArticlesQuery(int Page, int PageSize); | ||
|
||
public class GetArticles | ||
{ | ||
private readonly IArticlesRepository _articlesRepository; | ||
|
||
public GetArticles(IArticlesRepository articlesRepository) | ||
{ | ||
_articlesRepository = articlesRepository; | ||
} | ||
|
||
public async Task<List<ArticleDto>> Execute(GetArticlesQuery query) | ||
{ | ||
if (query.Page < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(query.Page)); | ||
} | ||
|
||
if (query.PageSize <= 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(query.PageSize)); | ||
} | ||
|
||
return await _articlesRepository.Get(query.Page, query.PageSize).Select(article => new ArticleDto(article)).ToListAsync(); | ||
} | ||
} | ||
} |
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,32 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using DevNews.Core.Repository; | ||
|
||
namespace DevNews.Core.UseCases | ||
{ | ||
public class GetArticlesPagesQuantity | ||
{ | ||
private IArticlesRepository _articlesRepository; | ||
|
||
public GetArticlesPagesQuantity(IArticlesRepository articlesRepository) | ||
{ | ||
_articlesRepository = articlesRepository; | ||
} | ||
|
||
public async Task<long> Execute(int pageSize) | ||
{ | ||
if (pageSize <= 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(pageSize), "Page Size should be greater or equal 1"); | ||
} | ||
|
||
var count = await _articlesRepository.Count(); | ||
if (count == 0) | ||
{ | ||
return 0; | ||
} | ||
|
||
return (long) Math.Ceiling((double) count / (double) pageSize); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/DevNews.Infrastructure.Persistence/Config/PersistenceConfiguration.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
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
Oops, something went wrong.