public async Task <ActionResult <CreateAccountResponse> > CreateVoucher([FromHeader] string client, [FromRoute] string cpf, [FromBody] CreateAccountRequest request) { CreateAccountResponse response = new CreateAccountResponse(); string responseCode = $"CREATE_VOUCHER_{client}_{cpf}"; try { var factory = WalletFactory.Instance.GetCreateAccount(_configuration); var account = await factory.Create(client, cpf, request.AccountID, request.LocationID, request.InitialValue, request.ExpiresOn, 1, request.ExtensionAttributes); var dto = new NewAccountDTO { AccountID = account.Item1, TransactionID = account.Item2 }; response.StatusCode = "200"; response.Data = dto; return(Ok(response)); } catch (Exception ex) { response.StatusCode = "500"; response.Messages.Add(ResponseMessage.Create(ex, responseCode)); return(StatusCode(500, response)); } }
public static void AddAccount(NewAccountDTO newAccountDTO) { var httpWebRequest = (HttpWebRequest)WebRequest.Create(url + "/admin/users"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; httpWebRequest.Headers.Add("Authorization", "Bearer " + userToken); using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = newAccountDTO.ToJSON(); streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); } using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { Console.WriteLine(reader.ReadToEndAsync()); } }
private void ConfirmButton_Click(object sender, RoutedEventArgs e) { NewAccountDTO newAccountDTO = new NewAccountDTO(); newAccountDTO.Email = EmailTextBox.Text; newAccountDTO.Name = NameTextBox.Text; newAccountDTO.Lastname = LastnameTextBox.Text; newAccountDTO.City = CityTextBox.Text; newAccountDTO.Phone = PhoneTextBox.Text; newAccountDTO.Pid = PIDTextBox.Text; try { Client.AddAccount(newAccountDTO); } catch (Exception ex) { MessageBox.Show("Couldn't add agent"); Console.WriteLine(ex.ToString()); } parent.AgentAdded(); this.Close(); }
public IActionResult Post([FromBody] NewAccountDTO credentials) { return(Ok(credentials)); }