public HttpResponseMessage Post(CreateAccount model) { if (!ModelState.IsValid) { return Request.CreateErrorResponse( HttpStatusCode.BadRequest, ModelState); } var account = new Account() .Merge(model, excludedProperties: new[] { "Balance" }); account.UserId = UserId; if (model.Balance > 0) { var transaction = account.Deposit(model.Balance); transaction.PostedAt = model.CreatedAt; transaction.Notes = "Initial balance."; DataContext.Transactions.Add(transaction); } DataContext.Accounts.Add(account); DataContext.SaveChanges(); return Request.CreateResponse( HttpStatusCode.Created, account.AsModel()); }
public void Create_And_Update_Multiple_PropertyAccounts() { Guid acc1 = Guid.NewGuid(); Guid acc2 = Guid.NewGuid(); var probe = CreateTestProbe("probe1"); var probe2 = CreateTestProbe("probe2"); var accountRef = PrepareTest(acc1,probe, "1"); var accountRef2 = PrepareTest(acc2,probe2, "2"); var command = new CreateAccount(acc1, "123456", "TestAccount", AccountType.Individual); accountRef.Tell(command); probe.ExpectMsg<AccountCreated>(new AccountCreated(acc1, "123456", "TestAccount", AccountType.Individual, 1)); var command2 = new CreateAccount(acc2, "923456", "TestAccount2", AccountType.Individual); accountRef2.Tell(command2); probe2.ExpectMsg<AccountCreated>(new AccountCreated(acc2, "923456", "TestAccount2", AccountType.Individual, 1)); var commandUpdate = new UpdateAccountMailingAddress(acc1, new Domain.Address("123 4TH ST", null, "Oklahoma City", "OK", "73120")); accountRef.Tell(commandUpdate); probe.ExpectMsg<AccountMailingAddressUpdated>( new AccountMailingAddressUpdated(acc1, new Domain.Address("123 4TH ST", null, "Oklahoma City", "OK", "73120"), 2)); var commandUpdate2 = new UpdateAccountMailingAddress(acc2, new Domain.Address("123 4TH ST", null, "Oklahoma City", "TX", "73120")); accountRef2.Tell(commandUpdate2); probe2.ExpectMsg<AccountMailingAddressUpdated>( new AccountMailingAddressUpdated(acc2, new Domain.Address("123 4TH ST", null, "Oklahoma City", "TX", "73120"), 2)); }
public void Create_Account() { var probe = CreateTestProbe("probe"); var accountRef = PrepareTest(accountId,probe, "1"); var command = new CreateAccount(accountId, "123456", "TestAccount", AccountType.Individual); accountRef.Tell(command); probe.ExpectMsg<AccountCreated>(new AccountCreated(accountId, "123456", "TestAccount", AccountType.Individual, 1)); }
public void CreateAccountToXmlStringTest() { CreateAccount account = new CreateAccount(merchantID, email, firstName, lastName, companyName, country, vatID); String expected = CreateExpected(); String actual = account.ToXmlString(); Assert.AreEqual(expected, actual); }
public virtual MailMessage CreateMessage(CreateAccount account) { var message = new MailMessage(); message.To.Add(account.EmailAddress); message.Subject = "Welcome!"; message.Body = "Thank you for signing up!"; return message; }
public FubuContinuation post_register(CreateAccount input) { var message = CreateMessage(input); _gateway.Send(message); return FubuContinuation.RedirectTo(new WelcomeMessage { Name = input.Name }); }
public void command_handler_should_handle_command_via_router() { // arrange var cmd = new CreateAccount(m_id); // act m_sender.SendOne(cmd); // assert }
public void command_sender_should_send_command() { // arrange var cmd = new CreateAccount(Identifier); // act Sender.SendOne(cmd); // assert }
public void CreateAccountConstructorTest() { CreateAccount account = new CreateAccount(merchantID, email, firstName, lastName, companyName, country, vatID); Assert.AreEqual(merchantID, account.MerchantID, "MerchantID"); Assert.AreEqual(email, account.Email, "Email"); Assert.AreEqual(companyName, account.CompanyName, "CompanyName"); Assert.AreEqual(country, account.Country, "Country"); Assert.AreEqual(firstName, account.FirstName, "FirstName"); Assert.AreEqual(lastName, account.LastName, "LastName"); Assert.AreEqual(vatID, account.VATID, "VATID"); }
public void command_handler_should_handle_multiple_commands_via_router() { // arrange var c1 = new CreateAccount(m_id); var c2 = new CreateAccount(m_id); var c3 = new CreateAccount(m_id); // act m_sender.SendBatch(new object[] { c1, c2, c3}); // assert }
public void command_handler_should_handle_command() { // arrange var cmd = new CreateAccount(m_id); var handler = new CommandHandler(); handler.WireToLambda<CreateAccount>(new CreateAccountHandler().Handle); // act handler.Handle(cmd); // assert }
public void command_sender_should_send_multiple_commands() { // arrange var cmd1 = new CreateAccount(Identifier); var cmd2 = new CreateAccount(Identifier); var cmd3 = new CreateAccount(Identifier); var batch = new object[] { cmd1, cmd2, cmd3 }; // act Sender.SendBatch(batch); // assert }
public async Task CreateAccount_ReturnsCreatedAtRouteResult() { // Arrange var request = new CreateAccount { EmailAddress = "*****@*****.**", Password = "******" }; // Act var result = await controller.Register(request); // Assert Assert.IsType <CreatedAtRouteResult>(result); }
public async Task Null_Request_Throws() { // Arrange var handler = new CreateAccountHandler(_mockAccountService.Object, _mockDateTimeProviderObject); // Act CreateAccount invalidRequest = null; var exception = await Record.ExceptionAsync(() => handler.Handle(invalidRequest)); // Assert _mockAccountService.Verify(s => s.AddAsync(It.IsAny <Guid>(), It.IsAny <Account>(), It.IsAny <CancellationToken>()), Times.Never); Assert.NotNull(exception); Assert.IsType <NullReferenceException>(exception); }
public void CreateUserAccount_AlreadyExists(string name) { RunInitSql(name, "ConnectionStringAccounts"); CreateAccount request = PrepareRequest <CreateAccount>(name); CreateAccountResponse response = Post <CreateAccount, CreateAccountResponse>("CreateAccount", request); RunFinalizeSql(name, "ConnectionStringAccounts"); Assert.AreEqual(response.Success, false, "User with duplicate name was successfully created"); Assert.IsNotEmpty(response.Errors, "Error was not returned"); Assert.AreEqual(response.Errors[0].Code, Interfaces.EErrorCodes.UserAccountExists, "Incorrect error code returned"); Assert.IsTrue(string.IsNullOrEmpty(response.Payload.AccountKey), "AccountKey is not empty"); }
public async Task CreateAccount(CreateAccount cmd) { using (var conn = new MySqlConnection(_connStr)) { await conn.OpenAsync(); using (MySqlTransaction transaction = conn.BeginTransaction()) { var salt = Crypt.GenerateSalt(); await conn.ExecuteAsync(insAcct, new { name = cmd.Name, email = cmd.Email, password = Crypt.HashPassword(cmd.Password, salt), salt, subscribe_newsletter = cmd.SubscribedToNewsletter }); var accountId = await GetLastInsertId <string>(conn); await InsertLog(conn, accountId, EventType.AccountCreated, data : $"name '{cmd.Name}' and email '{cmd.Email}'"); await InsertLog(conn, accountId, EventType.PasswordCreated); await conn.ExecuteAsync(insAddress, new { account_id = accountId, name = cmd.Name, is_default = true, street = cmd.Street, city = cmd.City, region = cmd.Region, postal_code = cmd.PostalCode, country = cmd.Country }); var addrId = await GetLastInsertId <string>(conn); await InsertLog( conn, accountId, EventType.AddressCreated, refId : addrId, refType : RefType.Address, data : $"{cmd.Street}, {cmd.City} - {cmd.Region}, {cmd.Country}"); await transaction.CommitAsync(); } } }
public HtmlDocument get_register(CreateAccount account) { var document = new FubuHtmlDocument<CreateAccount>(_services, _request); var form = document.FormFor<CreateAccount>() .Append(document.Edit(x => x.Name)) .Append(document.Edit(x => x.EmailAddress)) .Append(document.Edit(x => x.Password)) .Append(document.Edit(x => x.Subscriptions)) .Append(new HtmlTag("input").Attr("type", "submit").Attr("value", "Create Account").Id(Submit)); document.Add("h1").Text("Create New Account"); document.Add(form); return document; }
public async Task IAccountService_Throws() { // Arrange _mockAccountService.Setup(s => s.AddAsync(It.IsAny <Guid>(), It.IsAny <Account>(), It.IsAny <CancellationToken>())) .ThrowsAsync(new Exception()); var handler = new CreateAccountHandler(_mockAccountService.Object, _mockDateTimeProviderObject); // Act var request = new CreateAccount(userId: 1, AccountType.Credit); var exception = await Record.ExceptionAsync(() => handler.Handle(request)); // Assert Assert.NotNull(exception); Assert.IsType <Exception>(exception); }
/// <summary> /// Parses new account info and attempts to insert the new account into the authentication database /// It also publishes an "AccountCreated" event /// </summary> /// <returns>A response message</returns> private ServiceBusResponse attemptNewAccountCreation(CreateAccountRequest request) { CreateAccount command = request.createCommand; ServiceBusResponse dbResponse = AuthenticationDatabase.getInstance().insertNewUserAccount(command); if (dbResponse.result == true) { authenticated = true; username = command.username; password = command.password; initializeRequestingEndpoint(); eventPublishingEndpoint.Publish(new AccountCreated(command)); } return(dbResponse); }
/// <summary> /// Attempts to insert a new user account into the database /// </summary> /// <param name="accountInfo">Contains information about the </param> /// <returns>A message indicating the result of the attempt</returns> public ServiceBusResponse insertNewUserAccount(CreateAccount accountInfo) { bool result = false; string message = ""; if (openConnection() == true) { string query = "INSERT INTO user(username, password, address, phonenumber, email, type) " + "VALUES(@Username,@Password,@Address,@Number,@Email,@Type);"; try { MySqlCommand command = new MySqlCommand(query, connection); command.Parameters.AddWithValue("@Username", accountInfo.username); command.Parameters.AddWithValue("@Password", accountInfo.password); command.Parameters.AddWithValue("@Address", accountInfo.address); command.Parameters.AddWithValue("@Number", accountInfo.phonenumber); command.Parameters.AddWithValue("@Email", accountInfo.email); command.Parameters.AddWithValue("@Type", accountInfo.type.ToString()); command.ExecuteNonQuery(); result = true; } catch (MySqlException e) { Messages.Debug.consoleMsg("Unable to complete insert new user into database." + " Error :" + e.Number + e.Message); Messages.Debug.consoleMsg("The query was:" + query); message = e.Message; } catch (Exception e) { Messages.Debug.consoleMsg("Unable to Unable to complete insert new user into database." + " Error:" + e.Message); message = e.Message; } finally { closeConnection(); } } else { message = "Unable to connect to database"; } return(new ServiceBusResponse(result, message)); }
public async Task WithdrwalFromAccountLessThanBalance() { ClearDbData(); CreateAccount ca = new CreateAccount(_account, _bankDBContext); await ca.ExecuteCommand(); //Deposit 250 double amount = 250.0; Deposit depoist = new Deposit(_account, amount, "GBP", "Added GBP funds", _bankDBContext); await depoist.ExecuteCommand(); double amountToWithdraw = 200.0; Withdraw withdraw = new Withdraw(_account, amountToWithdraw, "Funds withdrwan", _bankDBContext); await withdraw.ExecuteCommand(); Assert.IsTrue(withdraw.IsCommandCompleted && _account.AccountBalance == 50); }
public async Task GivenValidDataOperationShouldBeCreated() { var command = new CreateAccount { Name = "InvalidAccountName", Value = 1000m }; var payload = Payload(command); var response = await Client.PostAsync("account", payload); response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.Created); response.Headers.Location.ToString().ShouldBeEquivalentTo($"account/{command.Name}"); var user = await GetOperationAsync(command.Name); user.AccountName.ShouldBeEquivalentTo(command.Name); }
private void DoCreateAccount(CreateAccount req) { var db = new BillingwareDataContext(); db.Accounts.Add(new Account { AccountNumber = req.AccountNumber, Balance = decimal.Zero, Extra = req.Extra, Alias = req.Alias, CreatedAt = DateTime.Now }); db.SaveChanges(); Sender.Tell(new AccountCreated(new CommonStatusResponse(message: "Successful")), Self); }
public async Task CannotCreateAccountWithSameId() { var cmd = new CreateAccount() { AccountId = _accountId, Name = "J S" }; var ev = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Name = "Jake Sanders" }; await _runner.Run( def => def.Given(ev).When(cmd).Throws(new SystemException("The account with specified ID already exists.")) ); }
public OperationResult Register(CreateAccount command) { var operationResult = new OperationResult(); if (_accountRepository.Exists(a => a.Username == command.Username || a.Mobile == command.Mobile)) { return(operationResult.Failed(QueryValidationMessage.DuplicateRecord)); } var profilePhoto = _fileUploader.FileUpload(command.ProfilePhoto, "ProfilePhotos"); var hashedPassword = _passwordHasher.Hash(command.Password); var account = new Account(command.Fullname, command.Username, hashedPassword, command.Mobile, command.RoleId, profilePhoto); _accountRepository.Create(account); _accountRepository.SaveChanges(); return(operationResult.Succeeded()); }
public async Task CannotCreateAccountWithSameId() { var created = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Jane Doe" }; var cmd = new CreateAccount { AccountId = _accountId, AccountHolderName = "John Doe" }; await _runner.Run( def => def.Given(created).When(cmd).Throws(new ValidationException("An account with this ID already exists")) ); }
public async Task AccountService_AddAccountAsync_SpecificAccount(CreateAccount command, string expectedLogin) { // Arrange PrepareDbContextWithOneAvatar(); int accountsCountBefore = DbContext.Accounts.Count(); AccountService accountService = new AccountService(DbContext); // Act await accountService.AddAccountAsync(command); var accountsCountAfter = DbContext.Accounts.Count(); var account = DbContext.Accounts.SingleOrDefault(x => x.Login == expectedLogin); // Assert Assert.NotNull(account); Assert.Equal(accountsCountBefore + 1, accountsCountAfter); Assert.Equal(expectedLogin, account.Login); }
public async Task <IActionResult> NewAccountView(CreateAccount createAccount) { string ids = userId; TempData["Id"] = ids; Account accounts = await accountHelper.GetById(accountId); ViewBag.accountType = accounts.AccountType.ToString(); Account account = mapper.Map <Account>(createAccount); if (ModelState.IsValid) { var all = await accountHelper.CreateAccountAsync(account); return(RedirectToAction("ListAccounts")); } return(View()); }
static void Main(string[] args) { using (var commandreceiver = new ResponseSocket("@tcp://*:5555")) { while (true) { var msg = commandreceiver.ReceiveFrameBytes(); using (var stream = new MemoryStream(msg)) { CreateAccount command = Serializer.Deserialize <CreateAccount>(stream); //Serializer.Deserialize<string>(stream); Console.WriteLine("id = " + command.AccountId + " holder name = " + command.HolderName); commandreceiver.SendFrame(new AccountCreated(new Guid(), "test").ToString()); //return } } } }
public async Task CanCreateAccount() { var cmd = new CreateAccount { AccountId = _accountId, AccountHolderName = "John Doe" }; var ev = new AccountCreated(cmd) { AccountId = cmd.AccountId, AccountHolderName = cmd.AccountHolderName }; await _runner.Run( def => def.Given().When(cmd).Then(ev) ); }
public void CreateAccount() { //Test request string expected = File.ReadAllText(Path.Combine(_requestsTestDataPath, "CreateAccount.xml")); var request = new CreateAccount { SessionId = "sid", DomainStr = "testing.com", AccountProperties = new TPropertyValueList { Items = new List<TPropertyValue> { new TPropertyValue { APIProperty = new TAPIProperty{ PropName = "u_name"}, PropertyVal = new TPropertyString{ Val = "testing"}, PropertyRight = TPermission.ReadWrite }, new TPropertyValue { APIProperty = new TAPIProperty{ PropName = "u_alias"}, PropertyVal = new TPropertyString{ Val = "tester"}, PropertyRight = TPermission.ReadWrite }, new TPropertyValue { APIProperty = new TAPIProperty{ PropName = "u_type"}, PropertyVal = new TPropertyString{ Val = AccountType.User.ToString("d")}, PropertyRight = TPermission.ReadWrite } } } }; var requestXml = request.ToXml().InnerXmlFormatted(); Assert.AreEqual(expected, requestXml); //Test response XmlDocument doc = new XmlDocument(); doc.LoadXml(File.ReadAllText(Path.Combine(_responsesTestDataPath, "CreateAccount.xml"))); var response = request.FromHttpRequestResult(new HttpRequestResult { Response = doc.InnerXml }); Assert.AreEqual("result", response.Type); Assert.True(response.Success); }
private void InitiateAccount(CreateAccount command) { Monitor(); if (_accountState.AccountNumber != null) { _log.Warning( $"[InitiateAccount]: You are trying to create {command.AccountNumber}, but has already been created. No action taken."); return; } /** * we want to use behaviours here to make sure we don't allow the account to be created * once it has been created -- Become AccountBoarded perhaps? */ var events = new List <IDomainEvent> { new AccountCreated ( accountNumber: command.AccountNumber, openingBalance: command.BoardingModel.OpeningBalance, inventory: command.BoardingModel.Inventory, userName: command.BoardingModel.UserName, lastPaymentDate: command.BoardingModel.LastPaymentDate, lastPaymentAmount: command.BoardingModel.LastPaymentAmount ) }; if (command.BoardingModel.OpeningBalance != 0.0) { events.Add(new AccountCurrentBalanceUpdated(command.AccountNumber, command.BoardingModel.OpeningBalance)); } foreach (var @event in events) { Persist(@event, s => { _accountState = _accountState.ApplyEvent(@event); ApplySnapShotStrategy(); }); } }
public ActionResult CreateAccountPost(string usernameData, string passwordData, string addressData, string cityData, string provinceData, string emailData, string phoneData) { //Get form data from HTML web page CreateAccount accountInfo = new CreateAccount(); ServiceBusResponse SBR; ServiceBusConnection SBC = ConnectionManager.getConnectionObject(Globals.getUser()); accountInfo.username = usernameData; accountInfo.password = passwordData; accountInfo.address = addressData; accountInfo.city = cityData; accountInfo.province = provinceData; accountInfo.email = emailData; accountInfo.phonenumber = phoneData; accountInfo.type = (AccountType)System.Enum.Parse(typeof(AccountType), Request.Form["accountType"]); //Send account info to bus CreateAccountRequest CAR = new CreateAccountRequest(accountInfo); if (SBC == null) { SBR = ConnectionManager.sendNewAccountInfo(CAR); } else { SBR = SBC.sendNewAccountInfo(CAR); } //Check if account created successfull string message = "Account created successfully."; if (SBR.result == true) { Response.Write("<script>alert('" + message + "')</script>"); return(View("Index")); } else { message = "Failed to create account."; Response.Write("<script>alert('" + message + "')</script>"); return(View("CreateAccount")); } }
/// <summary> /// Attempts to insert a new user account into the database /// </summary> /// <param name="accountInfo">Contains information about the </param> /// <returns>A message indicating the result of the attempt</returns> public ServiceBusResponse insertNewUserAccount(CreateAccount accountInfo) { bool result = false; string message = ""; if (openConnection() == true) { string query = @"INSERT INTO user(username, password, address, city, province, phonenumber, email, type) " + @"VALUES('" + accountInfo.username + @"', '" + accountInfo.password + @"', '" + accountInfo.address + @"', '" + accountInfo.city + @"', '" + accountInfo.province + @"', '" + accountInfo.phonenumber + @"', '" + accountInfo.email + @"', '" + accountInfo.type.ToString() + @"');"; try { MySqlCommand command = new MySqlCommand(query, connection); command.ExecuteNonQuery(); result = true; } catch (MySqlException e) { Messages.Debug.consoleMsg("Unable to complete insert new user into database." + " Error :" + e.Number + e.Message); Messages.Debug.consoleMsg("The query was:" + query); message = e.Message; } catch (Exception e) { Messages.Debug.consoleMsg("Unable to Unable to complete insert new user into database." + " Error:" + e.Message); message = e.Message; } finally { closeConnection(); } } else { message = "Unable to connect to database"; } return(new ServiceBusResponse(result, message)); }
public async Task <ActionResult <LoginResponse> > RegisterUserAsync([FromBody] CreateAccount createAccount) { if (createAccount.Password.Length < 10) { return(BadRequest("Wachtwoord te kort")); } //var inviteCode = await _dbContext.InviteCodes.FirstOrDefaultAsync(c => c.Code == createAccount.InviteCode && c.IsUsed == false); //if (inviteCode == null) //{ // return BadRequest("Ongeldige invite code"); //} var userSameEmail = await _dbContext.Users.AnyAsync(u => u.Email.ToLower() == createAccount.Email.ToLower()); if (userSameEmail) { return(BadRequest("Mailadres wordt al gebruikt")); } var user = new User { Email = createAccount.Email.ToLower(), Guid = Guid.NewGuid() }; //if (inviteCode.DoesNotExpire == false) //{ // inviteCode.IsUsed = true; // inviteCode.User = user; //} var map = new Map { MapGuid = Guid.NewGuid(), Name = "Kaart", Default = true }; map.User = user; user.Password = passwordHasher.HashPassword(user, createAccount.Password); _dbContext.Users.Add(user); _dbContext.Maps.Add(map); await _dbContext.SaveChangesAsync(); return(await LogUserIn(new LoginRequest { Email = createAccount.Email, Password = createAccount.Password })); }
public async Task CanCreateAccount() { var cmd = new CreateAccount { AccountId = AccountId, AccountHolderName = "NNN" }; var ev = new AccountCreated(cmd) { AccountId = cmd.AccountId, AccountHolderName = cmd.AccountHolderName, OverdraftLimit = 0 }; await Runner.Run( def => def.Given().When(cmd).Then(ev) ); }
private static Response CreateAccountResponse(CreateAccount createAccount) { Acknowledge ack = new Acknowledge() { Status = "FAIL", Reason = "Username not available." }; Response resp = new Response() { Content = ack, Type = ResponseType.Acknowledge, Status = "FAIL" }; if (!IsUsernameAvailable(createAccount.Username)) { return(resp); } DatabaseManager database = new DatabaseManager(); string query = String.Format("INSERT INTO user_login(username, password) VALUES ('{0}', '{1}')", RefineContent(createAccount.Username), RefineContent(createAccount.Password)); (MySqlDataReader reader, var Connection) = database.RunQuery(query); if (reader != null && reader.RecordsAffected > 0) { query = String.Format("INSERT INTO account_data (username, fullname, acctype, type) VALUES ('{0}', '{1}', '{2}', '{3}')", createAccount.Username, createAccount.FullName, createAccount.Type.ToString(), (int)createAccount.Type); (reader, Connection) = database.RunQuery(query); if (reader != null && reader.RecordsAffected > 0) { ack.Reason = ""; resp.Status = "OK"; ack.Status = "OK"; } else { ack.Reason = "Account Creation Error."; } } else { ack.Reason = "Account Creation Error."; } Connection.Close(); return(resp); }
public string Create(CreateAccount createAccount) { if (createAccountGateway.IsUsernameExists(createAccount.Username)) { return("Username already exists"); } else { int rowAffect = createAccountGateway.Create(createAccount); if (rowAffect > 0) { return("Create successful"); } else { return("Create failed"); } } }
private void PrepareCommand(IMassTransitCommand command) { switch (command.Command.ToLower()) { case "createaccount": { var createAccount = new CreateAccount(command.Command, command.Commander, command.CommandId, command.Payload); Self.Tell(createAccount); } break; case "addhostelclaim": { var createAccount = new AddHostelClaim(command.Command, command.Commander, command.CommandId, command.Payload); Self.Tell(createAccount); } break; } }
public static void ClearAll() { SearchResumeBank.SearchManifest = null; SearchResumeBank.SearchBuilder = null; SearchJobPostings.SearchManifest = null; SearchJobPostings.SearchBuilder = null; PlaceAnOrder.ShoppingCart = null; RenewMembership.Membership = null; CustomizePage.Clear(); RenewMembership.Clear(); CreateAccount.Clear(); RegisterForEvent.Clear(); GroupRegistration.Clear(); EnterCompetition.Clear(); PostAJob.Clear(); PlaceAnOrder.Clear(); ViewChapterMembers.Clear(); ViewSectionMembers.Clear(); ViewOrganizationalLayerMembers.Clear(); SearchDirectory.Clear(); SearchJobPostings.Clear(); SearchEventRegistrations.Clear(); SearchResumeBank.Clear(); AddContact.Clear(); CustomizePage.Clear(); // just wipe all keys // throw new NotSupportedException(); /* * List<string> keys = new List<string>(); * foreach (string key in HttpContext.Current.Session.Keys) * if (key.StartsWith("MemberSuite:")) * keys.Add(key); * * foreach( var key in keys ) * HttpContext.Current.Session[key] = null; * */ }
public async Task <IActionResult> Create([FromBody] CreateAccount dto) { if (dto == null) { return(BadRequest()); } try { dto.UserId = IdentityHelper.GetUserId(User); } catch (UnauthorizedAccessException) { return(Unauthorized()); } int id = await _accountService.CreateAsync(dto); return(StatusCode(201, id)); }
public void SetActiveNav(ActiveNav activeNav) { switch (activeNav) { case ActiveNav.LogIn: LogIn.AddCssClass("active"); CreateAccount.RemoveCssClass("active"); break; case ActiveNav.CreateAccount: CreateAccount.AddCssClass("active"); LogIn.RemoveCssClass("active"); break; default: LogIn.RemoveCssClass("active"); CreateAccount.RemoveCssClass("active"); break; } }
public void AddAsync_Should_AddUser_When_CorrectDataProvided(CreateAccount command, byte[] expectedPasswordHash, byte[] expectedSalt) { // Arrange var passwordManager = new Mock <IPasswordManager>(); passwordManager.Setup(p => p.CalculatePasswordHash(It.IsAny <string>(), out expectedPasswordHash, out expectedSalt)); IUserService userService = new Infrastructure.Services.UserService(fixture.Context, passwordManager.Object); // Act userService.AddAsync(command); var user = fixture.Context.Users.SingleOrDefault(x => x.Id == 1); // Assert Assert.Equal(command.Name, user.Name); Assert.Equal(command.Surname, user.Surname); Assert.Equal(command.Login, user.Login); Assert.Equal(command.Email, user.Email); Assert.Equal(expectedPasswordHash, user.PasswordHash); Assert.Equal(expectedSalt, user.Salt); }
public Account CreateAccount(CreateAccount createAccount) { throw new NotImplementedException(); }
public void Update_Account_Mailing_Address() { var probe = CreateTestProbe("probe"); var accountRef = PrepareTest(accountId, probe, "1"); var commandCreate = new CreateAccount(accountId, "123456", "TestAccount", AccountType.Individual); accountRef.Tell(commandCreate); probe.ExpectMsg<AccountCreated>(new AccountCreated(accountId, "123456", "TestAccount", AccountType.Individual, 1)); var commandUpdate = new UpdateAccountMailingAddress(accountId, new Domain.Address("123 4TH ST", null, "Oklahoma City", "OK", "73120")); accountRef.Tell(commandUpdate); probe.ExpectMsg<AccountMailingAddressUpdated>(new AccountMailingAddressUpdated(accountId, new Domain.Address("123 4TH ST", null, "Oklahoma City", "OK", "73120"), 2)); }
public void Handle(CreateAccount msg) { if (Created) throw new DomainException(string.Format("Account {0:n} already exists.", msg.AggregateId)); Events.Publish(new AccountCreated(msg.AggregateId, msg.TaxNumber, msg.EntityName, msg.Type, Version + 1, ContextHelper.CreateFromCommand(msg))); }