예제 #1
0
        public RegistrationQM Execute(RegistrationCM registrationCM)
        {
            RegistrationQM registrationQM = new RegistrationQM();

            using (var sqlCommand = CreateCommand())
            {
                sqlCommand.Connection  = Connection;
                sqlCommand.CommandText = "[dbo].[uspInsertUserAccountInfo]";
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.Add(this.AddParameter("@UserId", SsDbType.UniqueIdentifier, ParameterDirection.Input, registrationCM.UserId));
                sqlCommand.Parameters.Add(this.AddParameter("@FirstName", SsDbType.NVarChar, ParameterDirection.Input, registrationCM.FirstName));
                sqlCommand.Parameters.Add(this.AddParameter("@LastName", SsDbType.NVarChar, ParameterDirection.Input, registrationCM.LastName));
                sqlCommand.Parameters.Add(this.AddParameter("@Email", SsDbType.NVarChar, ParameterDirection.Input, registrationCM.Email));
                sqlCommand.Parameters.Add(this.AddParameter("@PhoneNumber", SsDbType.NVarChar, ParameterDirection.Input, registrationCM.PhoneNumber));
                sqlCommand.Parameters.Add(this.AddParameter("@CreatedBy", SsDbType.UniqueIdentifier, ParameterDirection.Input, DBNull.Value));
                sqlCommand.Parameters.Add(this.AddParameter("@CreatedDateTime", SsDbType.DateTime, ParameterDirection.Input, DBNull.Value));
                sqlCommand.Parameters.Add(this.AddParameter("@UpdatedBy", SsDbType.UniqueIdentifier, ParameterDirection.Input, DBNull.Value));
                sqlCommand.Parameters.Add(this.AddParameter("@UpdatedDateTime", SsDbType.DateTime, ParameterDirection.Input, DBNull.Value));
                sqlCommand.Parameters.Add(this.AddParameter("@LoginName", SsDbType.NVarChar, ParameterDirection.Input, registrationCM.LoginName));
                sqlCommand.Parameters.Add(this.AddParameter("@UserPassword", SsDbType.NVarChar, ParameterDirection.Input, registrationCM.UserPassword));
                sqlCommand.Parameters.Add(this.AddParameter("@PasswordSalt", SsDbType.NVarChar, ParameterDirection.Input, registrationCM.PasswordSalt));
                sqlCommand.Parameters.Add(this.AddParameter("@RoleId", SsDbType.Int, ParameterDirection.Input, registrationCM.RoleId));
                sqlCommand.Parameters.Add(this.AddParameter("@RegisteredUserId", SsDbType.UniqueIdentifier, ParameterDirection.Output));

                var reader = sqlCommand.ExecuteNonQuery();
                registrationQM.RegisteredUserId = (Guid)sqlCommand.Parameters["@RegisteredUserId"].Value;
            }
            return(registrationQM);
        }
예제 #2
0
        public RegistrationQM UserRegistration(RegistrationCM registrationCM)
        {
            RegistrationQM registrationQM;

            using (var connection = new DbConnectionProvider().CreateConnection())
            {
                connection.Open();

                var registrationInsertCommand = new RegistrationInsertCommand {
                    Connection = connection
                };
                registrationQM = registrationInsertCommand.Execute(registrationCM);
            }
            return(registrationQM);
        }
예제 #3
0
        public async Task <IActionResult> Post([FromBody] RegistrationCM model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userInDB = _userManager.FindByNameAsync(model.Email).Result;

            if (userInDB != null)
            {
                return(BadRequest("Email is existed!"));
            }

            var user = new User()
            {
                Email       = model.Email,
                UserName    = model.Email,
                FullName    = model.FullName,
                CreateDate  = DateTime.Now,
                DateOfBirth = model.DateOfBirth,
                IsDeleted   = false,
            };

            Random random = new Random();

            user.EmailConfirmCode = random.Next(100001, 999999).ToString();

            var result = await _userManager.CreateAsync(user, model.Password);

            _emailService.SendMail(user.Email, "Activation Code to Verify Email Address", "Thank you for creating an account with Gigshub"
                                   + "\n\nAccount name : "
                                   + user.UserName
                                   + "\n\nYour account will work but you must verify it by enter this code in our app"
                                   + "\n\nYour Activation Code is : "
                                   + user.EmailConfirmCode
                                   + "\n\nThanks & Regards\nDynamicWorkFlow Team");

            return(new OkObjectResult("Account created, please check your email!"));
        }
        public RegistrationResponseDto RegisterUser(RegistrationRequestDto registrationRequestDto)
        {
            RegistrationResponseDto registrationResponseDto = new RegistrationResponseDto();
            var keyNew   = Helper.GeneratePassword(25);
            var password = Helper.EncodePassword(registrationRequestDto.UserPassword, keyNew);
            var cModel   = new RegistrationCM
            {
                UserId       = Guid.NewGuid(),
                LoginName    = registrationRequestDto.LoginName,
                UserPassword = password,
                Email        = registrationRequestDto.Email,
                PhoneNumber  = registrationRequestDto.PhoneNumber,
                PasswordSalt = keyNew,
                IsActive     = true,
                FirstName    = registrationRequestDto.FirstName,
                LastName     = registrationRequestDto.LastName,
                RoleId       = registrationRequestDto.RoleId
            };

            var response = authenticationRepository.UserRegistration(cModel);

            registrationResponseDto.RegisteredUserId = response.RegisteredUserId;
            return(registrationResponseDto);
        }