public IActionResult RequestWallet() { int userId = int.Parse(_userService.GetUserId(User)); var registrant = _registrantService.GetRegistrantByUserId(userId, includeWallets: true); if (registrant.Wallets.Count >= Constants.maxWalletsPerUser) { TempData["Message"] = "You are at your max wallet count (" + Constants.maxWalletsPerUser + ")"; return(RedirectToAction("UserWallets")); } var newWallet = new WalletServiceModel { Number = new Random().Next(100, 999999999), RegistrantId = registrant.Id, IsVerified = false, CreatedById = userId, WalletStatusId = (int)StatusEnum.Status.Okay }; _walletService.CreateWallet(newWallet); TempData["Message"] = "A new wallet has been requested for creation!"; return(RedirectToAction("UserWallets")); }
public void UpdateWallet(WalletServiceModel wallet) { _unitOfWork.AddRepository <WalletEntityModel>(); var walletEntity = _mapper.Map <WalletEntityModel>(wallet); _dateService.SetDateEditedNow(ref walletEntity); _unitOfWork.GetRepository <WalletEntityModel>().Update(walletEntity); _unitOfWork.Save(); }
public int CreateWallet(WalletServiceModel wallet) { _unitOfWork.AddRepository <WalletEntityModel>(); var walletEntity = _mapper.Map <WalletEntityModel>(wallet); walletEntity.RegistrantId = wallet.RegistrantId; _dateService.SetDateCreatedNow(ref walletEntity); _unitOfWork.GetRepository <WalletEntityModel>().AddItem(walletEntity); _unitOfWork.Save(); return(walletEntity.Id); }