public async Task <IActionResult> Register(UserForRegisterDto userForRegister) { userForRegister.UserName = userForRegister.UserName.ToLower(); if (await _userManager.FindByNameAsync(userForRegister.UserName) != null) { return(Conflict(new ReturnMessage() { Status = false, Title = Resource.ErrorMessages.Error, Message = Resource.ErrorMessages.ExistUserMessage, Code = "409" })); } var userToCreate = new Data.Models.User() { UserName = userForRegister.UserName, Address = "", City = "", DateOfBirth = DateTime.Now, Gender = true, IsActive = true, Status = true, Name = userForRegister.Name, PhoneNumber = userForRegister.PhoneNumber }; var photoToCreate = new Photo() { UserId = userToCreate.Id, Description = "Profile Pic", Alt = "Profile Pic", IsMain = true, Url = string.Format($"{Request.Scheme}://{Request.Host.Value ?? ""}{Request.PathBase.Value ?? "" }/wwwroot/Files/Images/ProfilePic.png"), PublicId = "0", }; var result = await _userManager.CreateAsync(userToCreate, userForRegister.Password); if (result.Succeeded) { await _authService.AddUserPhoto(photoToCreate); var userForReturn = _mapper.Map <UserDetailDto>(userToCreate); return(CreatedAtRoute("GetUser", new { controller = "User", id = userToCreate.Id }, userForReturn)); } else { _logger.LogWarning($"user : {userForRegister.Name} Email: {userForRegister.UserName} {Resource.ErrorMessages.DbErrorRegister} "); return(BadRequest(new ReturnMessage() { Code = "400", Message = Resource.ErrorMessages.NoRegister, Status = false, Title = Resource.ErrorMessages.Error })); } }