Ejemplo n.º 1
0
        public async Task ExecuteAsync(RoleDetailsDto roleDetailsDto)
        {
            var role = _mapper.Map <ApplicationRole>(roleDetailsDto);

            NormalizeRoleCode(role);
            try
            {
                var resultOfRoleCreated = await _roleManager.CreateAsync(role);

                if (resultOfRoleCreated.Succeeded == false)
                {
                    throw new ValidationException(string.Join(", ", resultOfRoleCreated.Errors.Select(x => x.Description)));
                }

                await _roleClaimsUpdater.UpdateAsync(role, roleDetailsDto.Permissions);

                await _roleRouteStagesUpdater.UpdateAsync(role.Id, roleDetailsDto.RoleStages);
            }
            catch (Exception e)
            {
                throw new DatabaseException(e.InnerException?.Message ?? e.Message);
            }
        }
Ejemplo n.º 2
0
 private async Task SaveRoleRouteStagesAsync(int roleId, int[] roleRouteStages)
 {
     await _roleRouteStagesUpdater.UpdateAsync(roleId, roleRouteStages);
 }