public async Task <IActionResult> Create([Bind("Id,Address,Key,Ipv4,Algos,ReceiverAddress")] AlgorandIPv4.Models.Transaction transaction) { if (ModelState.IsValid) { var key = transaction.Key; var receiver = transaction.ReceiverAddress; var amount = transaction.Algos; var senderAddr = transaction.Address; FundMethod(key, receiver, amount, senderAddr); IPAddress remoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress; string result = ""; if (remoteIpAddress != null) { // If we got an IPV6 address, then we need to ask the network for the IPV4 address // This usually only happens when the browser is on the same machine as the server. if (remoteIpAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) { remoteIpAddress = System.Net.Dns.GetHostEntry(remoteIpAddress).AddressList .First(x => x.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork); } result = remoteIpAddress.ToString(); } transaction.Ipv4 = result; _context.Add(transaction); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(transaction)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Address,Key,Ipv4,Algos,ReceiverAddress")] AlgorandIPv4.Models.Transaction transaction) { if (id != transaction.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(transaction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TransactionExists(transaction.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(transaction)); }