public async Task <RoleDomainModel> GetByIdAsync(int id)
        {
            var role = await _rolesRepository.GetByIdAsync(id);

            if (role == null)
            {
                return(null);
            }

            RoleDomainModel roleModel = new RoleDomainModel
            {
                Id    = role.Id,
                Name  = role.Name,
                Users = role.Users.Select(user => new UserDomainModel
                {
                    Id        = user.Id,
                    FirstName = user.FirstName,
                    IsAdmin   = user.IsAdmin,
                    LastName  = user.LastName,
                    Points    = user.Points,
                    RoleId    = user.RoleId,
                    UserName  = user.UserName
                }).ToList()
            };

            return(roleModel);
        }
 public async Task <IActionResult> Get(int id)
 {
     return(Ok(await _rolesRepository.GetByIdAsync(id)));
 }
Exemple #3
0
        public async Task <Role> GetByIdAsync(string roleId)
        {
            var role = await _rolesRepository.GetByIdAsync(roleId);

            return(role);
        }