public ActionResult CreateAccount([FromForm(Name = "account-code")] string accountCode, [FromForm(Name = "first-name")] string firstName, [FromForm(Name = "last-name")] string lastName) { // If our form specifies an account code, we can use that; otherwise, // create an account code with a uniq id accountCode = accountCode ?? Guid.NewGuid().ToString(); var accountReq = new AccountCreate() { Code = accountCode, FirstName = firstName, LastName = lastName }; try { Account account = _client.CreateAccount(accountReq); _logger.LogInformation($"Created account {account.Code}"); } catch (Recurly.Errors.ApiError e) { return(HandleError(e)); } return(Redirect(SuccessURL)); }
public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <create> <GLACCOUNT> <ACCOUNTNO>1010</ACCOUNTNO> <TITLE>hello world</TITLE> <ACCOUNTTYPE>balancesheet</ACCOUNTTYPE> <NORMALBALANCE>debit</NORMALBALANCE> <CLOSINGTYPE>non-closing account</CLOSINGTYPE> </GLACCOUNT> </create> </function>"; AccountCreate record = new AccountCreate("unittest") { AccountNo = "1010", Title = "hello world", AccountType = "balancesheet", NormalBalance = "debit", ClosingType = "non-closing account" }; this.CompareXml(expected, record); }
public async Task <AccountResponse> CreateAccountAsync(AccountCreate accountModel) { var account = _billingPaymentProvider.CreateAccount(accountModel); var accountResponse = _mapper.Map <AccountResponse>(account); await _messageSession.Send(account); return(accountResponse); }
public IHttpActionResult Post(AccountCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var acctService = new AccountService(Guid.Parse(User.Identity.GetUserId())); return(Ok(acctService.CreateAccount(model))); }
public ActionResult Create(AccountCreate account) { if (ModelState.IsValid) { var registerResult = _identityProvider.RegisterUser(account.AccountName, account.Password, account.Email); account.CreationMessage = registerResult; if (!registerResult.Equals(AccountCreate.OkMessage)) { ModelState.AddModelError("CreationMessage", account.CreationMessage); } } return(View(account)); }
public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <create> <GLACCOUNT> <ACCOUNTNO>1010</ACCOUNTNO> <TITLE>hello world</TITLE> <ACCOUNTTYPE>balancesheet</ACCOUNTTYPE> <NORMALBALANCE>debit</NORMALBALANCE> <CLOSINGTYPE>non-closing account</CLOSINGTYPE> </GLACCOUNT> </create> </function>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); AccountCreate record = new AccountCreate("unittest"); record.AccountNo = "1010"; record.Title = "hello world"; record.AccountType = "balancesheet"; record.NormalBalance = "debit"; record.ClosingType = "non-closing account"; record.WriteXml(ref xml); xml.Flush(); stream.Position = 0; StreamReader reader = new StreamReader(stream); Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd()) .WithDifferenceEvaluator(DifferenceEvaluators.Default) .Build(); Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString()); }
public ActionResult CreateUser(AccountCreate acc) { SqlCommand cmd = new SqlCommand(); connection.Open(); cmd = new SqlCommand("SP_CREATE_FORM", connection); cmd.Parameters.Add(new SqlParameter("@FName", acc.FName)); cmd.Parameters.Add(new SqlParameter("@LName", acc.LName)); cmd.Parameters.Add(new SqlParameter("@email", acc.Email)); cmd.Parameters.Add(new SqlParameter("@Gender", acc.gender)); cmd.Parameters.Add(new SqlParameter("@City", acc.City)); cmd.Parameters.Add(new SqlParameter("@Country", acc.Country)); cmd.Parameters.Add(new SqlParameter("@Password", acc.Password)); cmd.CommandType = CommandType.StoredProcedure; { cmd.ExecuteNonQuery(); } //return RedirectToAction("Home"); return(View("Login")); }
public IActionResult Validation(AccountCreate createAccount) { if (ModelState.IsValid) { string[] EmailParts = createAccount.Email.Split(new char[] { ' ' }); for (int i = 0; i < createAccount.Email.Length; i++) { if (createAccount.Email[i] == '@' && createAccount.Password.Length >= 8) { return(View("AccountCreate")); } } } else { return(View("Error")); } return(View("AccountFail")); }
public bool CreateAccount(AccountCreate model) { string key = "sKzvYk#1Pn33!YN"; string userInput = model.AcctPassword; string ciphertext = Rijndael256.Rijndael.Encrypt(userInput, key, Rijndael256.KeySize.Aes256); var entity = new Account() { OwnerId = _userId, AcctName = model.AcctName, AcctPassword = ciphertext, AddedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Accounts.Add(entity); return(ctx.SaveChanges() == 1); } }
static void Main(string[] args) { var client = new Recurly.Client("e9922993342845dbbc583c145b2ab811"); try { var accountReq = new AccountCreate() { Code = "76a5f681-5754-4760-932d-ba6d17b50147", FirstName = "Frodo", LastName = "Baggins", Company = "76a5f681-5754-4760-932d-ba6d17b50147", Address = new Address() { City = "New Orleans", Region = "LA", Country = "US", PostalCode = "70115", Street1 = "900 Camp St." } }; Account account = client.CreateAccount(accountReq); Console.WriteLine($"Created account {account.Code}"); } catch (Recurly.Errors.Validation ex) { // If the request was not valid, you may want to tell your user // why. You can find the invalid params and reasons in ex.Error.Params Console.WriteLine($"Failed validation: {ex.Error.Message}"); } catch (Recurly.Errors.ApiError ex) { // Use ApiError to catch a generic error from the API Console.WriteLine($"Unexpected Recurly Error: {ex.Error.Message}"); } Console.WriteLine("Press enter to close..."); Console.ReadLine(); }
public async Task CreateAccountAsync_SuccessfullCreate_SentsMessage() { var account = new Account { Code = "testCode", FirstName = "testName", LastName = "testlastName", Invoices = new List <InvoiceResponse>(), Subscriptions = new List <SubscriptionResponse>() }; var request = new AccountCreate { Code = "testCode", FirstName = "testName", LastName = "testlastName" }; _mockBillingPaymentProvider .Setup(m => m.CreateAccount(It.IsAny <AccountCreate>())) .Returns(account); var result = await _billingPaymentMediator .CreateAccountAsync(request); var message = (Account)_testableMessageSession.SentMessages[0].Message; Assert.NotNull(result); Assert.Equal(account.Code, result.Code); Assert.Single(_testableMessageSession.SentMessages); Assert.NotNull(message); Assert.Equal(request.Code, message.Code); Assert.Equal(request.FirstName, message.FirstName); Assert.Equal(account.Code, message.Code); }
public ActionResult <AccountRead> CreateAccount(AccountCreate accountCreate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var AccAmt1 = accountCreate.Salary - accountCreate.Expenses; if (AccAmt1 < 1000) { return(StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status204NoContent, "Not Created")); } var account = _mapper.Map <Account>(accountCreate); _reprositry.CreateAccount(account); _reprositry.SaveChanges(); var accountRead = _mapper.Map <AccountRead>(account); return(Created("Account Creaated", account)); }
public ActionResult Create(AccountCreate model) { if (!ModelState.IsValid) { return(View(model)); } var svc = CreateAccountService(); if (svc.CreateAccount(model)) { TempData["SaveResult"] = "Your Account and Password have been safely stored."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Account/Password could not be saved."); return(View(model)); }
public bool CreateAccount(AccountCreate model) { var account = new Account() { AccountBalance = model.AccountBalance, AccountType = model.AccountType }; if (model.AccountBalance < 0) { return(false); } using (var ctx = new ApplicationDbContext()) { ctx .Accounts .Add(account); if (ctx.SaveChanges() != 1) { return(false); } var relationship = new AccountRelationship() { AccountId = account.AccountId, UserId = _userId }; ctx .AccountRelationships .Add(relationship); return(ctx.SaveChanges() == 1); } }
public IActionResult Create([FromBody] AccountCreate acc) { try { var existing = Context.Account.Find(acc.Username); if (existing != null) { return(BadRequest("This username is already taken by another person")); } PasswordHasher <Account> hasher = new PasswordHasher <Account>(); Account newAcc = new Account { Username = acc.Username, Role = "User", Status = "Ready to chat", Name = acc.Name }; // Hash account password string hashed = hasher.HashPassword(newAcc, acc.Password); newAcc.Password = hashed; Context.Account.Add(newAcc); Context.SaveChanges(); return(Ok()); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
internal static void InvokeAccountCreate(AccountRequestCreate info) { AccountCreate?.Invoke(info); }
/// <summary> /// Create Creates the entity with the given properties. /// </summary> /// <exception cref="PostFinanceCheckout.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="entity">The account object with the properties which should be created.</param> /// <returns>ApiResponse of Account</returns> public ApiResponse <Account> CreateWithHttpInfo(AccountCreate entity) { // verify the required parameter 'entity' is set if (entity == null) { throw new ApiException(400, "Missing required parameter 'entity' when calling AccountService->Create"); } var localVarPath = "/account/create"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json;charset=utf-8" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json;charset=utf-8" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (entity != null && entity.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(entity); // http body (model) parameter } else { localVarPostBody = entity; // byte array } this.Configuration.ApiClient.ResetTimeout(); // make the HTTP request IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("Create", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Account>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (Account)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Account)))); }
/// <summary> /// Create Creates the entity with the given properties. /// </summary> /// <exception cref="PostFinanceCheckout.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="entity">The account object with the properties which should be created.</param> /// <returns>Account</returns> public Account Create(AccountCreate entity) { ApiResponse <Account> localVarResponse = CreateWithHttpInfo(entity); return(localVarResponse.Data); }
public bool CreateAccount(AccountCreate model) { CreateAccountCallCount++; return(CreateAccountReturnValue); }
public async Task <IActionResult> CreateAccount(AccountCreate accountModel) { return(Created(Request?.Path.Value, await _billingPaymentMediator.CreateAccountAsync(accountModel))); }
public Account CreateAccount(AccountCreate accountModel) { var accountCreated = _mapper.Map <Account>(_recurlyAdapter.CreateAccount(accountModel)); return(accountCreated); }