コード例 #1
0
ファイル: UserController.cs プロジェクト: Reborn73/Tamrin
        public virtual async Task <IActionResult> RegisterUser(RegisterUserDto userDto, CancellationToken cancellationToken)
        {
            var user = userDto.ToEntity(_mapper);

            //var user = new User
            //{
            //    RoleId = 5,
            //    UserName = userDto.UserName.Trim(),
            //    Email = userDto.Email.ToLower().Trim(),
            //    GenderType = userDto.GenderType,
            //    FirstName = "تست نام",
            //    LastName = "تست فامیلی",
            //    AvatarName = "avatar.jpg",
            //    ActivationCode = Guid.NewGuid().ToString().Replace("-", ""),
            //    IsDeleted = false,
            //    CreateDateTime = DateTime.Now,
            //    AccessFailedCount = 0,
            //    EmailConfirmed = false,
            //    LockoutEnabled = false
            //};

            await _userRepository.AddAsync(user, userDto.Password, cancellationToken);

            return(Ok());
        }
コード例 #2
0
        public async Task <UserDto> RegisterAsync(RegisterUserDto dto)
        {
            var existedUser = await Repository.SingleAsync(s => s.UserName == dto.UserName);

            if (existedUser != null)
            {
                throw new BadRequestException("User is ready existed.");
            }

            var entity = dto.ToEntity();

            var oauthUser = await _proxyService.CreateAccountAsync(dto);

            var user = await CreateAsync(entity);

            return(user.ToDto());
        }