コード例 #1
0
        public async Task <AppUserDTO> CreateAsync(CreateAppUserDTO dto)
        {
            var item = _mapper.Map <AppUser>(dto);

            item.Salt     = SecurityHelper.GetNewSalt();
            item.Password = SecurityHelper.EncryptPassword(dto.Password, item.Salt);

            var createdUser = await _repository.CreateItemAsync(item);

            return(_mapper.Map <AppUserDTO>(createdUser));
        }
コード例 #2
0
        public async Task OnGetAsync()
        {
            CurrentUserRoles = new List <PairSelector>();
            var roles = (await _IdentityRoleAppService.GetAllListAsync())
                        .Items.Where(x => x.IsPublic).Select(x => x.Name).ToList();

            foreach (var role in roles)
            {
                CurrentUserRoles.Add(new PairSelector {
                    Key = role, Value = false
                });
            }
            UserAccount = new CreateAppUserDTO
            {
                Password = await _SettingProvider.GetOrNullAsync(PageSettingProvider.USER_CREATOR_DEFAULT_PASSWORD_FOR_NEW_USER) ?? ""
            };
        }
コード例 #3
0
        public async Task <ActionResult <AppUserDTO> > PostAsync([FromBody] CreateAppUserDTO dto)
        {
            var item = await _userService.CreateAsync(dto);

            return(Ok(item));
        }
コード例 #4
0
ファイル: UsersController.cs プロジェクト: cpayen/Note.04
        public async Task <ActionResult <AppUserDTO> > PostAsync([FromBody] CreateAppUserDTO dto)
        {
            var item = await _appUsers.CreateAsync(dto.UserName, dto.FirstName, dto.LastName, dto.Email, dto.Password, dto.Roles);

            return(Ok(Mappers.GetAppUserDTO(item)));
        }