public async Task <IActionResult> RegisterBitcoin([Bind("Name, BitCoinAddress")] BitCoinViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; EFPBitcoinRepository _repository = new EFPBitcoinRepository(_context); if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } DateTime time = DateTime.Now; BitCoinAddress x = new BitCoinAddress { Name = model.Name, Address = model.BitCoinAddress, UserId = user.Id, Active = true, Primary = false, RegDate = time }; await _repository.AddAddressAsync(x); return(RedirectToAction("Bitcoin")); } return(View(model)); }
public async Task <IActionResult> BitCoin() { var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var ourList = _bitCoinRepository.GetAddressByUserId(user.Id); BitCoinAddress f = await _bitCoinRepository.GetPrimaryAddressAsync(user.Id); var model = new BitCoinViewModel { StatusMessage = StatusMessage, /*BitCoinAddress = f.Address, Name = f.Name,*/ AllBitcoinAddresses = ourList }; return(View(model)); }