I am implementing the edit page by loading the item selected on the item list page. (Like a user modification page ...)
So, I refer to the User, Role page, which is a similar form.
Both functions use Manager function. (Var user = await UserManager.GetUserByIdAsync (input.Id.Value);)
By the way, I can not learn by referring to GetUserByIdAsync.
Public async Task <GetArticleForEditOutput> GetArticleForEdit (NullableIdDto input) {
If (input.Id.HasValue) { Var article = await ???????? (input.Id.Value); } }
Above ?? What should I do with the part?
3 Answer(s)
-
0
Hi,
I assume you have an Article entity and I assume it's Id field is integer. So, inject a generic repository to your AppService and use it to get article entity.
public class ArticleAppService : YourAppServiceBase, IPersonAppService { private readonly IRepository<Article> _articleRepository; public ArticleAppService(IRepository<Article> articleRepository) { _articleRepository = articleRepository; } Public async Task <GetArticleForEditOutput> GetArticleForEdit (NullableIdDto input) { ............ If (input.Id.HasValue) { Var article = await _articleRepository.GetAsync(input.Id.Value); } ............ } }
-
0
okay... :D
I've found that it works right.
Note that..
GetAsync, GetAllListAsync .... etc.
In which document can I find it? :roll:
-
0
Hi,
You can find it here <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Repositories">http://aspnetboilerplate.com/Pages/Docu ... positories</a>.