public async Task <DataProviderModel <CreateUserAccountModel> > CreateUserAccount(int accountNumber, PaymentType paymentType) { var guid = Guid.NewGuid().ToString(); var q1 = new Query(guid, "InsertUserAccount"); q1.Parameters.Add(new QueryParameter("in", "CptyService_Id", ((int)paymentType).ToString(), SqlDbType.Int)); q1.Parameters.Add(new QueryParameter("in", "AccountNumber", accountNumber.ToString(), SqlDbType.NVarChar)); var queries = new List <Query> { q1 }; var result = await _sessionQueryExecutor.Execute(queries).ConfigureAwait(false); var createAccountModel = new CreateUserAccountModel(); var createUserAccountQuery = result.Queries.FirstOrDefault(q => q.Name == "InsertUserAccount"); var accountIdParametr = createUserAccountQuery?.Parameters.FirstOrDefault(p => p.Direction == "out" && p.Code == "Account_Id"); if (accountIdParametr != null) { createAccountModel.AccountId = int.Parse(accountIdParametr.Value); } return(new DataProviderModel <CreateUserAccountModel>(result.ResultMessage, createAccountModel)); }
public async Task <IActionResult> Create([FromBody] CreateUserAccountModel account) { var cancellationTokenSource = new CancellationTokenSource(); var result = await _createCommand.Execute(account, cancellationTokenSource.Token); return(Ok()); }
public ActionResult Index(string signin, CreateUserAccountModel model) { if (ModelState.IsValid) { using (var userRepository = new UserRepository()) { // create a user in our user store, including claims // create a new account var newUser = new User(); newUser.Subject = Guid.NewGuid().ToString(); newUser.IsActive = true; newUser.UserName = model.UserName; newUser.Password = model.Password; // create claims from the model newUser.UserClaims.Add(new UserClaim() { Id = Guid.NewGuid().ToString(), Subject = newUser.Subject, ClaimType = Constants.ClaimTypes.Email, ClaimValue = model.Email }); newUser.UserClaims.Add(new UserClaim() { Id = Guid.NewGuid().ToString(), Subject = newUser.Subject, ClaimType = Constants.ClaimTypes.GivenName, ClaimValue = model.FirstName }); newUser.UserClaims.Add(new UserClaim() { Id = Guid.NewGuid().ToString(), Subject = newUser.Subject, ClaimType = Constants.ClaimTypes.FamilyName, ClaimValue = model.LastName }); newUser.UserClaims.Add(new UserClaim() { Id = Guid.NewGuid().ToString(), Subject = newUser.Subject, ClaimType = "role", ClaimValue = model.Role }); // add the user userRepository.AddUser(newUser); // redirect to the login page, passing in // the signin parameter return(Redirect("~/identity/" + Constants.RoutePaths.Login + "?signin=" + signin)); } } return(View()); }
public int Create(CreateUserAccountModel domainModel) { // Create repositories var userAccountRepository = new UserAccountRepository(); // Create the UserAccount var userAccountId = userAccountRepository.Insert(domainModel); return(userAccountId); }
private void CreateAccount(CreateUserAccountModel model) { if (!ModelState.IsValid) { return; } var newUser = new User { Subject = Guid.NewGuid().ToString(), IsActive = true, UserName = model.UserName, Password = model.Password }; newUser.UserClaims.Add(new UserClaim() { Id = Guid.NewGuid().ToString(), Subject = newUser.Subject, ClaimType = Constants.ClaimTypes.GivenName, ClaimValue = model.FirstName }); newUser.UserClaims.Add(new UserClaim() { Id = Guid.NewGuid().ToString(), Subject = newUser.Subject, ClaimType = Constants.ClaimTypes.FamilyName, ClaimValue = model.LastName }); newUser.UserClaims.Add(new UserClaim() { Id = Guid.NewGuid().ToString(), Subject = newUser.Subject, ClaimType = Constants.ClaimTypes.Email, ClaimValue = model.Email }); newUser.UserClaims.Add(new UserClaim() { Id = Guid.NewGuid().ToString(), Subject = newUser.Subject, ClaimType = "role", ClaimValue = model.Role }); Save(newUser); }
public int Insert(CreateUserAccountModel domainModel) { // Build up the parameters var parameters = new List <SqlParameter>() { CreateParameter("@Firstname", SqlDbType.VarChar, domainModel.Firstname), CreateParameter("@Lastname", SqlDbType.VarChar, domainModel.Lastname), CreateParameter("@Username", SqlDbType.VarChar, domainModel.Username), CreateParameter("@CachedData", SqlDbType.VarBinary, domainModel.CachedData), CreateParameter("@UpdateDate", SqlDbType.DateTime, domainModel.UpdateDate), }; // Run command return(InsertData("Sp_Insert_UserAccount", parameters)); }
public ActionResult Index(string signin, CreateUserAccountModel model) { if (ModelState.IsValid) { // create a user var password = HashHelper.Sha512(model.UserName + model.Password); var user = new ApplicationUser { UserName = model.UserName, IsActive = true, Password = password, Email = model.Email }; var createdUser = UserManager.Create(user, model.Password); if (createdUser.Succeeded) { var userRetrieved = UserManager.Users .FirstOrDefault(u => u.UserName == model.UserName && u.Password == password); if (userRetrieved != null) { UserManager.AddClaim(userRetrieved.Id, new Claim(IdentityServer3.Core.Constants.ClaimTypes.GivenName, model.FirstName)); UserManager.AddClaim(userRetrieved.Id, new Claim(IdentityServer3.Core.Constants.ClaimTypes.FamilyName, model.LastName)); UserManager.AddClaim(userRetrieved.Id, new Claim("role", model.Role)); UserManager.AddClaim(userRetrieved.Id, new Claim("address", model.Address)); UserManager.AddClaim(userRetrieved.Id, new Claim("email", model.Email)); } } // redirect to the login page, passing in // the signin parameter return(Redirect("~/identity/" + IdentityServer3.Core.Constants.RoutePaths.Login + "?signin=" + signin)); } return(View()); }
public ActionResult Index(string signin, CreateUserAccountModel model) { CreateAccount(model); return(Redirect($"~/core/{Constants.RoutePaths.Login}?signin={signin}")); }