public async Task <BaseResponseModel> Register(SignUpAC model) { if (_iAccountRepository == null) { _iAccountRepository = new AccountRepository(); } var isExistUser = UserManager.FindByEmail(model.Email); if (isExistUser == null) { if (await _iAccountRepository.Signup(model) == true) { return(StatusBuilder.ResponseSuccessStatus(null, StringConstant.SignUpSuccessfull)); } else { return(StatusBuilder.ResponseFailStatus(null, StringConstant.SignUpFail)); } } else { return(StatusBuilder.ResponseFailStatus(null, "Email " + StringConstant.AlreadyExists)); } //if (!result.Succeeded) //{ // return GetErrorResult(result); //} //else //{ // await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); //} //return Ok(); }
public async Task <bool> Signup(SignUpAC signupAC) { using (IDbConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { try { connection.Open(); var id = Guid.NewGuid(); var password = PasswordHashUtill.HashPassword(signupAC.Password); var securityStamp = Guid.NewGuid(); var insertQuery = "INSERT INTO AspNetUsers values ('" + id + "','" + signupAC.Email + "',0,'" + password + "','" + securityStamp + "',null,0,0,null,1,0,'" + signupAC.Email + "');"; await connection.ExecuteScalarAsync(insertQuery); var newUserQuery = "select MAX(Id) from AspNetUsers"; var newUserId = await connection.ExecuteScalarAsync <string>(newUserQuery); var userRoleQuery = "Insert into AspNetUserRoles values('" + newUserId + "',1)"; await connection.ExecuteScalarAsync(userRoleQuery); return(true); } catch (Exception ex) { throw ex; } } }