public IActionResult GoToTransferPage(string selection)
        {
            TransferViewModel model = new TransferViewModel();
            List <string>     customersFirstNameList = new List <string>();
            List <string>     customersLastNameList  = new List <string>();
            var allCustomers = _context.customers.ToList();

            foreach (var customersData in  allCustomers)
            {
                customersFirstNameList.Add(customersData.FirstName);
                customersLastNameList.Add(customersData.LastName);
            }
            ViewBag.CustomersFirstName = customersFirstNameList;
            ViewBag.CustomersLastName  = customersLastNameList;

            // var user = await _userManager.GetUserAsync(User);
            if (selection == "Transfer")
            {
                return(View("Transfer", model));
            }
            if (selection == "Loan")
            {
                return(View("Loan"));
            }
            if (selection == "Deposit")
            {
                return(View("Deposit"));
            }
            if (selection == "Withdrawal")
            {
                return(View("Withdrawal"));
            }
            return(null);
        }
Example #2
0
        //Sendtransfer sends money to other user
        public static bool SendTransfer(TransferViewModel transfer)
        {
            bool flag = false;

            using (NmoorEntity db = new NmoorEntity())
            {
                var getToken      = db.User.Where(u => u.token.Equals(transfer.Token)).FirstOrDefault();
                var getSenderUser = db.User.Where(u => u.username.Equals(transfer.SenderUsername)).FirstOrDefault();
                if (getToken != null)
                {
                    var amount = transfer.Amount + 1.99m;
                    if (amount <= getSenderUser.balance)
                    {
                        flag = true;
                        getSenderUser.balance -= amount;

                        Invoice invoice = new Invoice();
                        invoice.senderUsername   = transfer.SenderUsername;
                        invoice.receiverUsername = transfer.Token;
                        invoice.amount           = amount;
                        invoice.status           = "Pending";
                        invoice.date             = DateTime.Now;
                        invoice.time             = TimeSpan.FromSeconds(60);

                        db.Invoice.Add(invoice);

                        db.SaveChanges();
                    }
                }
            }
            return(flag);
        }
Example #3
0
        public ActionResult IRAWithdrawExclude()
        {
            TransferViewModel TVM         = db.TransferViewModels.Find(1);
            Account           destination = new Account();

            destination.ProductNumber = TVM.DestinationID;
            destination.ProductType   = ProductType.IRA;
            IRA ira = GetIRA(destination.ProductNumber);

            ira.IRABalance -= TVM.Amount;
            ira.IRABalance -= 30;
            db.SaveChanges();
            destination.ProductName = ira.IRAName;
            Int32 NextTransNum = db.Transactions.ToList().Count() + 1;

            if (TVM.Comment == null || TVM.Comment == "")
            {
                TVM.Comment = "No comment entered.";
            }
            Transaction trans = new Transaction {
                Description = "Withdrawal of $" + TVM.Amount + " from " + destination.ProductName + ".", TransactionType = TransactionType.withdrawal, Amount = TVM.Amount, Date = TVM.Date, TransactionNumber = NextTransNum, Comment = TVM.Comment
            };
            Int32       NextTransNum2 = NextTransNum + 1;
            Transaction fee           = new Transaction {
                Description = "Fee of $30 incurred during withdrawal from " + destination.ProductName + ".", TransactionType = TransactionType.fee, Amount = 30, Date = TVM.Date, TransactionNumber = NextTransNum2, Comment = TVM.Comment
            };

            db.Transactions.Add(trans);
            db.Transactions.Add(fee);
            db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
        public async Task ThrowExceptionOnConcurrencyConflictOnTransfer()
        {
            await BeginTestSql(async (service, db) =>
            {
                var senderId       = (await db.Users.FirstOrDefaultAsync()).Id;
                var receiverId     = (await db.Users.LastOrDefaultAsync()).Id;
                var chromeSender   = await db.Users.FirstOrDefaultAsync(p => p.Id == senderId);
                var chromeReceiver = await db.Users.FirstOrDefaultAsync(p => p.Id == receiverId);
                var edgeSender     = await db.Users.FirstOrDefaultAsync(p => p.Id == senderId);
                var edgeReceiver   = await db.Users.FirstOrDefaultAsync(p => p.Id == receiverId);
                TransferViewModel modelOnChrome = new TransferViewModel()
                {
                    TransferToAccount   = chromeReceiver.AccountNumber,
                    Amount              = 50m,
                    RowVersion          = chromeSender.RowVersion,
                    RecepientRowVersion = chromeReceiver.RowVersion
                };
                TransferViewModel modelOnEdge = new TransferViewModel()
                {
                    TransferToAccount   = edgeReceiver.AccountNumber,
                    Amount              = 250m,
                    RowVersion          = edgeSender.RowVersion,
                    RecepientRowVersion = edgeReceiver.RowVersion
                };

                // The first user will try to transfer money
                await service.TransferFunds(modelOnChrome, chromeSender);
                // The second user will also try but will throw a Concurrency exception.
                Exception result = await Assert.ThrowsAsync <Exception>(() => service.TransferFunds(modelOnEdge, edgeSender));

                Assert.IsType <DbUpdateConcurrencyException>(result.InnerException);
            });
        }
Example #5
0
        public IActionResult Transfer(TransferViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var isSuccess = _bankService.Transfer(vm.FromAccountId, vm.ToAccountId, vm.Amount);
                if (isSuccess)
                {
                    var fromAccount = _bankService.GetAccountById(vm.FromAccountId);
                    var toAccount   = _bankService.GetAccountById(vm.ToAccountId);

                    return(View(nameof(Index), new TransferViewModel
                    {
                        FromAccountId = vm.FromAccountId,
                        ToAccountId = vm.ToAccountId,
                        Amount = vm.Amount,
                        FromActualSumString = fromAccount.ActualSum.ToString("C"),
                        ToActualSumString = toAccount.ActualSum.ToString("C")
                    }));
                }
                else
                {
                    ModelState.AddModelError("FromAccountId", "Det finns inte tillräckligt med pengar på ditt konto.");
                }
            }
            return(View(nameof(Index), vm));
        }
        public async Task <IActionResult> transfer(TransferViewModel model)
        {
            TransactionStatusViewModel transactionStatus = new TransactionStatusViewModel();

            try
            {
                var response = await _transactionProvider.Transfer(model);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var jsoncontent = await response.Content.ReadAsStringAsync();

                    transactionStatus = JsonConvert.DeserializeObject <TransactionStatusViewModel>(jsoncontent);
                    return(View("TransactionStatus", transactionStatus));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    ModelState.AddModelError("", "Having server issue while adding record");
                    return(View(model));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    ViewBag.Message = "Internal Server Error! Please try again later";
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Exceptions Occured as " + ex.Message);
            }
            ModelState.AddModelError("", "Having some unexpected error while processing transaction");
            return(View(model));
        }
        public async Task SendAndReceiveExpectedAmountOnTransfer()
        {
            await BeginTestSqlite(async (service, db) =>
            {
                var sender                  = await db.Users.FirstOrDefaultAsync();
                var receiver                = await db.Users.LastOrDefaultAsync();
                decimal amountToTransfer    = 450;
                decimal senderOrigBalance   = sender.Balance;
                decimal receiverOrigBalance = receiver.Balance;
                decimal senderExpBalance    = senderOrigBalance - amountToTransfer;
                decimal receiverExpBalance  = receiverOrigBalance + amountToTransfer;
                TransferViewModel model     = new TransferViewModel()
                {
                    TransferToAccount   = receiver.AccountNumber,
                    Amount              = amountToTransfer,
                    RowVersion          = sender.RowVersion,
                    RecepientRowVersion = receiver.RowVersion
                };

                await service.TransferFunds(model, sender);
                var sendResult    = await db.Users.FirstOrDefaultAsync(p => p.Id == sender.Id);
                var receiveResult = await db.Users.FirstOrDefaultAsync(p => p.Id == receiver.Id);

                Assert.Equal(senderExpBalance, sendResult.Balance);
                Assert.Equal(receiverExpBalance, receiveResult.Balance);
            });
        }
        public async Task RecordReceiverTransactionHistoryOnTransfer()
        {
            await BeginTestSqlite(async (service, db) =>
            {
                var sender                  = await db.Users.FirstOrDefaultAsync();
                var receiver                = await db.Users.LastOrDefaultAsync();
                decimal amountToTransfer    = 450;
                decimal senderOrigBalance   = sender.Balance;
                decimal receiverOrigBalance = receiver.Balance;
                decimal senderExpBalance    = senderOrigBalance - amountToTransfer;
                decimal receiverExpBalance  = receiverOrigBalance + amountToTransfer;
                TransferViewModel model     = new TransferViewModel()
                {
                    TransferToAccount   = receiver.AccountNumber,
                    Amount              = amountToTransfer,
                    RowVersion          = sender.RowVersion,
                    RecepientRowVersion = receiver.RowVersion
                };

                await service.TransferFunds(model, sender);
                var sendResult    = await db.Transactions.FirstOrDefaultAsync(p => p.UserId == sender.Id);
                var receiveResult = await db.Transactions.FirstOrDefaultAsync(p => p.UserId == receiver.Id);

                Assert.Equal(receiverOrigBalance, receiveResult.BalanceBefore);
                Assert.Equal(receiverExpBalance, receiveResult.BalanceAfter);
                Assert.Equal(amountToTransfer, receiveResult.Amount);
                Assert.Equal(TransactionType.Receive, receiveResult.TransactionType);
            });
        }
        /*  TRANSFER  */
        // Skapar upp Vy-modellen
        public IActionResult MakeTransfer(int accountId)
        {
            TransferViewModel model = new TransferViewModel();

            model.FromAccount = accountId;
            return(View(model));
        }
        public async Task <IActionResult> Create(int Id)
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            var content = await _cashAccountRepository.GetNames(
                "https://localhost:44382/CashAccount/GetNames?id=" + Id.ToString(), accessToken);

            var transferView = new TransferViewModel();

            if (content == null)
            {
                return(RedirectToAction("Index", "Balance"));
            }
            else
            {
                transferView.Accounts =
                    from NameOfAccount in content
                    select new SelectListItem
                {
                    Text = NameOfAccount.Name, Value = NameOfAccount.Name.ToString()
                };

                transferView.CashAccountFrom_Id = Id;
                transferView.CashAccountTo_Id   = content.FirstOrDefault
                                                      (e => e.Name == transferView.Name).Id;

                return(View(transferView));
            }
        }
Example #11
0
        public void ShouldValidateViewModelOnSubmit(string sourceAcc, string descAcc, decimal amount, string expectedError)
        {
            // arrange
            var accounts = new List <IAccount>
            {
                Mock.Of <IAccount>(x => x.AccountNumber == "11111" && x.Balance == 3000),
                Mock.Of <IAccount>(x => x.AccountNumber == "22222" && x.Balance == 2000)
            };

            _currentCustomer.Setup(x => x.Accounts).Returns(accounts);
            var viewModel = new TransferViewModel
            {
                SourceAccount = sourceAcc,
                DestAccount   = descAcc,
                Amount        = amount
            };

            // act
            var result = _controller.TransferToMyAccount(viewModel).Result;

            // assert
            var json   = result.ShouldBeOfType <JsonResult>();
            var errors = json.Data.ShouldBeOfType <ErrorViewModel>();

            errors.Details.ShouldContain(x => x.Value == expectedError);
        }
Example #12
0
        public TransferViewModel Transfer(TransferViewModel model)
        {
            model.Message = null;
            var accountList = GetListOfAccounts();
            var fromAccount = accountList.FirstOrDefault(a => a.AccountNumber == model.FromAccountNumber);
            var toAccount   = accountList.FirstOrDefault(a => a.AccountNumber == model.ToAccountNumber);

            if (model.TransferAmount < 1)
            {
                model.Message = "Transfer amount must be digits and above 0";
                return(model);
            }

            if (fromAccount != null && toAccount != null)
            {
                if (TryToMakeTransfer(fromAccount, toAccount, model.TransferAmount))
                {
                    model.FromAccount = fromAccount;
                    model.ToAccount   = toAccount;
                    model.Message     = "Transfer completed";
                }
                else
                {
                    model.Message = "Not enough money Sender account";
                }
            }
            else
            {
                model.Message = "Sender or Recieving account number is incorrect";
            }

            return(model);
        }
Example #13
0
        public void ShouldTransferToOtherAccount(string sourceAcc, string descAcc, decimal amount)
        {
            // arrange
            var sourceAccount      = Mock.Of <IAccount>(x => x.AccountNumber == sourceAcc && x.Balance == 3000);
            var destinationAccount = Mock.Of <IAccount>(x => x.AccountNumber == descAcc && x.Balance == 2000);

            _currentCustomer.Setup(x => x.Accounts).Returns(new List <IAccount> {
                sourceAccount
            });
            _accountService.Setup(x => x.FindAccount(descAcc)).Returns(destinationAccount);
            var viewModel = new TransferViewModel
            {
                SourceAccount = sourceAcc,
                DestAccount   = descAcc,
                Amount        = amount
            };

            // act
            var result = _controller.TransferToOtherAccount(viewModel).Result;

            // assert
            _accountService.Verify(
                x => x.TransferMoney(
                    sourceAccount, destinationAccount, amount,
                    AmountConversionMode.SourceToTarget,
                    $"Extenal transfer from account {sourceAcc} to account {descAcc}."));
            var json = result.ShouldBeOfType <JsonResult>();

            json.Data.ShouldBeOfType <SuccessViewModel>()
            .Message.ShouldBe("The operation has successfully completed");
        }
Example #14
0
        public void ShouldTransferToMyAccount(string sourceAcc, string descAcc, decimal amount)
        {
            // arrange
            var accounts = new List <IAccount>
            {
                Mock.Of <IAccount>(x => x.AccountNumber == sourceAcc && x.Balance == 3000),
                Mock.Of <IAccount>(x => x.AccountNumber == descAcc && x.Balance == 2000)
            };

            _currentCustomer.Setup(x => x.Accounts).Returns(accounts);
            var viewModel = new TransferViewModel
            {
                SourceAccount = sourceAcc,
                DestAccount   = descAcc,
                Amount        = amount
            };

            // act
            var result = _controller.TransferToMyAccount(viewModel).Result;

            // assert
            _accountService.Verify(
                x => x.TransferMoney(
                    accounts[0], accounts[1], amount,
                    AmountConversionMode.SourceToTarget,
                    $"Internal transfer between your accounts from {sourceAcc} to {descAcc}."));
            var json = result.ShouldBeOfType <JsonResult>();

            json.Data.ShouldBeOfType <SuccessViewModel>()
            .Message.ShouldBe("The operation has successfully completed");
        }
        /// <summary>
        /// Permite tranferir del balance del usuario logueado al balance de otro usuario
        /// </summary>
        /// <param name="fromUser"></param>
        /// <param name="transfer"></param>
        /// <returns></returns>
        public async Task <bool> TransferBalance(string fromUser, TransferViewModel transfer)
        {
            try
            {
                var userRepository = new UserRepository();
                var userFrom       = await userRepository.GetUserByName(fromUser);

                if (userFrom.Balance < transfer.balance)
                {
                    throw new Exception("Su fondos son insuficientes para tranferir");
                }
                else
                {
                    var userTo = await userRepository.GetUserByName(transfer.userNameToTransfer);

                    if (userTo == null)
                    {
                        return(false);
                    }

                    userFrom.Balance = userFrom.Balance - transfer.balance;
                    await userRepository.Updateuser(userFrom);

                    userTo.Balance = userTo.Balance + transfer.balance;
                    await userRepository.Updateuser(userTo);
                }
                return(true);
            }
            catch (Exception e) { throw e; }
        }
        public TransferWindow(MainViewModel main)
        {
            InitializeComponent();
            DataContext = vm = new TransferViewModel(main);

            MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
        }
        public ActionResult ReceiveTransfer(TransferViewModel transferViewModel)
        {
            if (Session["strUserId"] == null || Session["strUserRole"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                LoadSession();

                if (transferViewModel.TransferViewModelList != null)
                {
                    transferViewModel.TransferViewModelList.RemoveAll(x => !x.IsChecked);
                    if (transferViewModel.TransferViewModelList.Any())
                    {
                        transferViewModel.StoreId   = Convert.ToInt32(strStoreId);
                        transferViewModel.RecieveBy = strUserName;
                        string msg = TransferService.ReceiveTransfer(transferViewModel);
                        TempData["OperationMessage"] = msg;
                        ModelState.Clear();
                    }
                }


                ViewBag.Pending = TransferService.GetPending(strStoreId);
                transferViewModel.TransferViewModelList = TransferService.TransferPendingInformation(strStoreId);
                return(View(transferViewModel));
            }
        }
Example #18
0
        public async Task <IActionResult> Transfer(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var toUser = await _userService.GetAccountById(id.Value);

            if (toUser == null)
            {
                return(NotFound());
            }

            var loginUserId = int.Parse(this.User.FindFirst("UserId").Value);
            var fromUser    = await _userService.GetAccountById(loginUserId);

            if (fromUser == null)
            {
                return(NotFound());
            }

            var viewModel = new TransferViewModel
            {
                FromUser = fromUser,
                ToUser   = toUser,
            };

            return(View(viewModel));
        }
        public async Task <ActionResult> _TransformRecords()
        {
            var userId = User.Identity.GetUserId();
            var trm    = new MangerRepository().GetTransferRecords(userId);
            List <TransferViewModel> tfvmlist = new List <TransferViewModel>();

            foreach (var t in trm)
            {
                TransferViewModel tfvm = new TransferViewModel();
                tfvm.transferRecords = t;
                var transfer_out = await UserManager.FindByIdAsync(t.UserId);

                var transfer_in = await UserManager.FindByIdAsync(t.Transfer);

                tfvm.transferRecords = t;
                if (userId == t.UserId)
                {
                    tfvm.Transfer_records = "轉給 " + transfer_in.UserName;
                    tfvm.type             = -1;
                }
                else if (userId == t.Transfer)
                {
                    tfvm.Transfer_records = transfer_out.UserName + " 轉進";
                    tfvm.type             = 1;
                }


                tfvmlist.Add(tfvm);
            }
            //ViewBag.Safety = new MangerRepository().GetValid(useriId);
            return(View(tfvmlist.OrderByDescending(x => x.transferRecords.createDate)));
        }
Example #20
0
        public async Task <ViewResult> Transfer(int id)
        {
            TransferViewModel transferViewModel = new TransferViewModel();

            transferViewModel.Account = _Iaccount.GetAccountById(id);
            return(View(transferViewModel));
        }
Example #21
0
        public async Task Transfer_Given_TransferingToSameAccount_Then_ReturnBadRequestObjectResult()
        {
            // Arrange
            //var mockService = new Mock<IAccountAppService>();
            var controller = new AccountController(null);
            //controller.ModelState.AddModelError("TransferViewModelInvalid", "Informe um modelo válido");

            var transferViewModel = new TransferViewModel()
            {
                SourceAccount = new SourceAccountViewModel()
                {
                    AccountNumber = 1
                },
                TargetAccount = new TargetAccountViewModel()
                {
                    AccountNumber = 1
                }
            };

            //Act
            var result = await controller.Transfer(transferViewModel);

            // Assert
            var badRequestResult = Assert.IsType <BadRequestObjectResult>(result);

            Assert.Equal("Não é permitido transferir para mesma conta", badRequestResult.Value);
        }
Example #22
0
        public async Task Transfer_Given_InvalidSourceAccount_Then_ReturnNotFound()
        {
            // Arrange
            var mockService = new Mock <IAccountAppService>();

            var invalidTransferViewModel = new TransferViewModel()
            {
                SourceAccount = new SourceAccountViewModel()
                {
                    AccountNumber = 0, Agency = 0
                },
                TargetAccount = new TargetAccountViewModel()
                {
                    AccountNumber = 123, Agency = 123
                },
            };

            var sourceAccount = invalidTransferViewModel.SourceAccount;

            mockService.Setup(service => service.GetByAccountNumberAndAgencyAsync(
                                  sourceAccount.AccountNumber,
                                  sourceAccount.Agency
                                  )).ReturnsAsync((Account)null);

            var controller = new AccountController(mockService.Object);

            // Act
            var result = await controller.Transfer(invalidTransferViewModel);

            //Assert
            Assert.IsType <NotFoundObjectResult>(result);
        }
Example #23
0
        public async Task <IActionResult> SubmitTransfer(TransferViewModel transfer)
        {
            if (ModelState.IsValid)
            {
                _context.ProvidingAgencies.Add(transfer.ProvidingAgency);
                _context.RequestingAgencies.Add(transfer.RequestingAgency);
                _context.Bonds.Add(transfer.Bond);
                _context.Indemnitors.Add(transfer.Indemnitor);
                _context.Defendants.Add(transfer.Defendant);
                _context.Jails.Add(transfer.Jail);

                //Save changes for EF tracking
                await _context.SaveChangesAsync();

                _context.Transfers.Add(new Transfer
                {
                    AdditionalInformation = transfer.AdditionalInformation,
                    BondId             = transfer.Bond.Id,
                    DefendantId        = transfer.Defendant.Id,
                    IndemnitorId       = transfer.Indemnitor.Id,
                    RequestingAgencyId = transfer.RequestingAgency.Id,
                    ProvidingAgencyId  = transfer.ProvidingAgency.Id,
                    JailId             = transfer.Jail.Id
                });

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Success)));
            }
            else
            {
                return(View());
            }
        }
        public IActionResult MakeAMoneyTransfer(TransferViewModel model)
        {
            if (!IsModelValid(model))
            {
                return(View(nameof(MakeAMoneyTransfer), model));
            }

            var origin = _bankrepo.GetAccountById(model.OriginAccountId);

            var destination = _bankrepo.GetAccountById(model.DestinationAccountId);

            string message = null;
            var    status  = _bankrepo.MoneyTransfer(origin, destination, model.TransferAmount, out message);

            model.Message = message;
            model.IsError = true;

            if (status)
            {
                model.IsError              = false;
                model.OriginNewAmount      = origin.Amount;
                model.DestinationNewAmount = destination.Amount;
            }

            return(View(nameof(MakeAMoneyTransfer), model));
        }
Example #25
0
        public ActionResult Transfer(TransferViewModel transfer)
        {
            var sourceCheckingAccount = db.CheckingAccountModels.Find(transfer.CheckingAccountId);

            if (sourceCheckingAccount.Balance < transfer.Amount)
            {
                ModelState.AddModelError("Amount", "You have insufficient funds");
            }
            var destinationCheckingAccount =
                db.CheckingAccountModels.Where(c => c.AccountNumber == transfer.DestinationCheckingAccountNumber).FirstOrDefault();

            if (destinationCheckingAccount == null)
            {
                ModelState.AddModelError("DestinationCheckingAccountNumber", "Invalid destination account number");
            }
            if (ModelState.IsValid)
            {
                db.Transactions.Add(new Transaction {
                    CheckingAccountId = transfer.CheckingAccountId, Amount = -transfer.Amount
                });
                db.Transactions.Add(new Transaction {
                    CheckingAccountId = destinationCheckingAccount.Id, Amount = transfer.Amount
                });
                db.SaveChanges();

                var service = new CheckingAccountService(db);
                service.UpdateBalance(transfer.CheckingAccountId);
                service.UpdateBalance(destinationCheckingAccount.Id);
                return(PartialView("_TransferSuccess", transfer));
            }
            return(PartialView("_TransferForm"));
        }
 public static void TransferMoney(TransferViewModel vm)
 {
     IoCServiceLocator.CommandBus.Send(
         new ChangeBalanceCommand(
             vm.AggregateId,
             vm.Version,
             vm.Amount));
 }
Example #27
0
        private TransferViewModel CreateTransferViewModelWithAccountSelectList()
        {
            var transferVm       = new TransferViewModel();
            var bankAccountsList = _bankAccountRepository.GetWhere(b => b.Id > 0).ToList();

            transferVm.SelectListOfBankAccounts = new SelectList(bankAccountsList, "Id", "AccountName");
            return(transferVm);
        }
Example #28
0
 public PostingViewModelBase(TransactionViewModel transactionDetails, TransferViewModel transferDetails)
 {
     TransactionDetails = transactionDetails;
     TransferDetails    = transferDetails;
     Init();
     eventAggregator.Subscribe(this);
     Translator.CultureChanged += (sender, args) => NotifyOfPropertyChange(() => SearchStatus);
 }
Example #29
0
        public ActionResult Transfer(int account)
        {
            var model = new TransferViewModel {
                From = account
            };

            return(View(model));
        }
Example #30
0
 public IActionResult Index(TransferViewModel model)
 {
     if (model == null)
     {
         model = new TransferViewModel();
     }
     return(View(model));
 }
 public virtual ActionResult Save(TransferViewModel transfer)
 {
     try
     {
         if (ModelState.IsValid)
         {
             PublishAndCommit(new SendMoneyTransferCommand(transfer.AccountId, transfer.Amount, transfer.TargetAccountNumber));
             return RedirectToAction(MVC.Account.Details.Show(transfer.AccountId));
         }
     }
     catch (Exception ex)
     {
         ReportError(ex.Message);
     }
     transfer.TargetAccounts = GetPossibleTargetAccounts(transfer.AccountId);
     return View(Views.Show, transfer);
 }
Example #32
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            // Specify the local database connection string.
            string DBConnectionString = "Data Source=isostore:/Transfer.sdf";

            // Create the database if it does not exist.
            using (TransferDataContext<AbstractTransfer> db = new TransferDataContext<AbstractTransfer>(DBConnectionString))
            {
                if (db.DatabaseExists() == false)
                {
                    // Create the local database.
                    db.CreateDatabase();

                    AbstractTransfer MilkyWay = new DownloadTransfer { TransferUrl = @"http://www.cfa.harvard.edu/image_archive/2009/1/hires.jpg", Path = "/space", Filename = "milky_way_highres.jpg" };

                    // Prepopulate with a page
                    db.Transfers.InsertOnSubmit(MilkyWay);

                    // Save pages to the database.
                    db.SubmitChanges();
                }
            }

            // Create the ViewModel object.
            _TransferViewModel = new TransferViewModel<AbstractTransfer>(DBConnectionString);

            // Query the local database and load observable collections.
            _TransferViewModel.LoadCollectionsFromDatabase();

            // Transfer manager
            _TransferManager = new TransferManager.TransferManager(_TransferViewModel);

            // Create the database if it does not yet exist.
            using (LibraryDataContext db = new LibraryDataContext("isostore:/Library.sdf"))
            {
                if (db.DatabaseExists() == false)
                {
                    // Create the database.
                    db.CreateDatabase();
                }
            }

            // Create the LibraryViewModel object.
            _LibraryViewModel = new LibraryViewModel("isostore:/Library.sdf");

            // Query the local database and load observable collections.
            _LibraryViewModel.LoadCollectionsFromDatabase();
        }
 public virtual ActionResult Show(Guid id)
 {
     var transfer = new TransferViewModel { AccountId = id, TargetAccounts = GetPossibleTargetAccounts(id) };
     return View(transfer);
 }