public async Task<AppUser> CreateUser(AppUser user, RegisterUserDto dto) { try { var result = await _userManager.CreateAsync(user, dto.Password); if (result.Succeeded) { await _userManager.AddToRoleAsync(user, "Member"); await _context.SaveChangesAsync(); return user; } return null; } catch (Exception ex) { _logger.LogError("Error at AuthRepository at CreateUser, ex:" + ex.StackTrace, false); } return null; }
[HttpPost] [Route("createuser")] public async Task<IActionResult> CreateUserAcc([FromBody] RegisterUserDto userDto) { try { var identity = _mapper.Map<AppUser>(userDto); var result= await _repository.CreateUser(identity, userDto); if (result!=null) return Ok(result); else return BadRequest("Account alredy exists."); } catch (Exception) { } return BadRequest(); }
services.AddMvc(options=>....).AddJsonOptions(opt=> opt.SerializerSettings.ReferenceLoopHandling=Newtonsoft.Json.ReferenceLoopHandling.Ignore);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)