Base solution for your next web application
Open Closed

GetRoleByIdAsync(input.Id.Value); where is file?? #2786


User avatar
0
peterlee created

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)
  • User Avatar
    0
    ismcagdas created
    Support Team

    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);
            }
           ............
        }
    }
    
  • User Avatar
    0
    peterlee created

    okay... :D

    I've found that it works right.

    Note that..

    GetAsync, GetAllListAsync .... etc.

    In which document can I find it? :roll:

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can find it here <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Repositories">http://aspnetboilerplate.com/Pages/Docu ... positories</a>.