public void Create(CreateAccountRequest createAccountRequest, string encryptedPassword) { using (var context = new PRToolsEntities()) { string roleName = createAccountRequest.Role.ToString(); Role roleEntity = context.Roles.SingleOrDefault(x => x.RoleName == roleName); var accountEntity = new Account { FirstName = createAccountRequest.FirstName, LastName = createAccountRequest.LastName, Username = createAccountRequest.Username, Password = encryptedPassword, Email = createAccountRequest.EmailAddress, Role = roleEntity, MustChangePassword = true, }; context.Accounts.AddObject(accountEntity); context.SaveChanges(); } }
/// <summary> /// Create a new Account object. /// </summary> /// <param name="accountId">Initial value of the AccountId property.</param> /// <param name="roleId">Initial value of the RoleId property.</param> /// <param name="username">Initial value of the Username property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="mustChangePassword">Initial value of the MustChangePassword property.</param> public static Account CreateAccount(global::System.Int32 accountId, global::System.Int32 roleId, global::System.String username, global::System.String password, global::System.String firstName, global::System.String lastName, global::System.String email, global::System.Boolean mustChangePassword) { Account account = new Account(); account.AccountId = accountId; account.RoleId = roleId; account.Username = username; account.Password = password; account.FirstName = firstName; account.LastName = lastName; account.Email = email; account.MustChangePassword = mustChangePassword; return account; }
/// <summary> /// Deprecated Method for adding a new object to the Accounts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAccounts(Account account) { base.AddObject("Accounts", account); }