public async Task <IActionResult> Register(UserForRegisterDto userForRegisterDto) { var userToCreate = new Data.Models.User { UserName = userForRegisterDto.UserName, Name = userForRegisterDto.Name, PhoneNumber = userForRegisterDto.PhoneNumber, Address = "", City = "", Gender = true, DateOfBirth = DateTime.Now, IsActive = true, Status = true, }; var photoToCreate = new Photo { UserId = userToCreate.Id, Url = string.Format("{0}://{1}{2}/{3}", Request.Scheme, Request.Host.Value ?? "", Request.PathBase.Value ?? "", "wwwroot/Files/Pic/profilepic.png"), //"https://res.cloudinary.com/keyone2693/image/upload/v1561717720/768px-Circle-icons-profile.svg.png", Description = "Profile Pic", Alt = "Profile Pic", IsMain = true, PublicId = "0" }; var result = await _userManager.CreateAsync(userToCreate, userForRegisterDto.Password); if (result.Succeeded) { await _authService.AddUserPhotos(photoToCreate); var userForReturn = _mapper.Map <UserForDetailedDto>(userToCreate); _logger.LogInformation($"{userForRegisterDto.Name} - {userForRegisterDto.UserName} ثبت نام کرده است"); return(CreatedAtRoute("GetUser", new { controller = "Users", id = userToCreate.Id }, userForReturn)); } else if (result.Errors.Any()) { _logger.LogWarning(result.Errors.First().Description); return(BadRequest(new returnMessage() { status = false, title = "خطا", message = result.Errors.First().Description })); } else { return(BadRequest(new returnMessage() { status = false, title = "خطا", message = "خطای نامشخص" })); } }