示例#1
0
        public async Task <string> Create(ApplicationUserWriteDto model)
        {
            var user   = _mapper.Map <ApplicationUser>(model);
            var result = await _userManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                throw new BadRequestException(result.Errors.Any() ? result.Errors.ElementAt(0) : null);
            }

            await _userManager.AddToRoleAsync(user.Id, model.RoleName);

            return(user.Id);
        }
示例#2
0
        public async Task <IHttpActionResult> Post([FromBody] ApplicationUserWriteDto model)
        {
            var id = await _accountsFcd.Create(model);

            return(Ok());
        }