public Response <UserProfileDTO> UserRegistration(UserRegistrationDTO dto) { var response = new Response <UserProfileDTO>(); try { User user = new User(); user.Name = dto.Name; user.UserName = dto.UserName; user.Email = dto.Email; user.Password = Helper.Encrypt(dto.Password); user.Phone_Number = dto.PhoneNumber; user.RoleId = 3; user.DateCreated = DateTime.UtcNow.ToString(); if (_userRepository.ListQuery(a => a.DateDeleted == null && !string.IsNullOrEmpty(a.Email) && !string.IsNullOrEmpty(user.Email) && a.Email.ToLower() == user.Email.ToLower()).Any()) { response.AddValidationError("", "Email is already exist!"); return(response); } if (_userRepository.ListQuery(a => a.DateDeleted == null && !string.IsNullOrEmpty(a.UserName) && !string.IsNullOrEmpty(user.UserName) && a.UserName.ToLower() == user.UserName.ToLower()).Any()) { response.AddValidationError("", "UserName is already exist!"); return(response); } var customerCreateOptions = new CustomerCreateOptions(); customerCreateOptions.Email = user.Email; customerCreateOptions.Name = user.Name; customerCreateOptions.Address = new AddressOptions { City = dto.Address.City, State = dto.Address.State, Country = dto.Address.Country, PostalCode = dto.Address.PostalCode, Line1 = dto.Address.Line1, Line2 = dto.Address.Line2 }; var addressRes = _addressSerevice.Create(dto.Address); if (addressRes.HasError) { response.AddValidationError("", addressRes.ErrorMessage); return(response); } user.AddressId = addressRes.Data.Id; var customer = _baseServices.CreateStripCustomerAccount(customerCreateOptions); user.Stripe_CustomerId = customer.Id; _userRepository.Insert(user); var token = generateJwtToken(user); _userSessionService.Create(new UserSession { AccessToken = token, UserId = user.Id }); var userResponse = _userRepository.GetbyidwithInclude(a => a.Id == user.Id && a.DateDeleted == null, "Roles,Address"); UserProfileDTO registrationResponse = new UserProfileDTO(); registrationResponse.Id = userResponse.Id; registrationResponse.Name = userResponse.Name; registrationResponse.JwtToken = token; registrationResponse.Role = userResponse.Roles?.Name; registrationResponse.RoleId = userResponse.RoleId; registrationResponse.Customer_id = userResponse.Stripe_CustomerId; registrationResponse.UserName = userResponse.UserName; registrationResponse.Email = userResponse.Email; registrationResponse.Birthdate = userResponse.Birthdate; registrationResponse.Phone_Number = userResponse.Phone_Number; response.Data = registrationResponse; response.Success = true; } catch (Exception ex) { HandleException(response, ex); } return(response); }