Ejemplo n.º 1
0
        public ActionResult Index()
        {
            List<BankAccountEntity> bankAccounts;
            using (var dataContext = new CQRSDataContext())
            {
                bankAccounts = dataContext.BankAccountEntities.ToList();
            }

            var model = new HomeIndexViewModel {BankAccounts = bankAccounts};

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(AccountViewModel model)
        {
            using (var dataContext = new CQRSDataContext())
            {
                var account = dataContext.BankAccountEntities.Single(x => x.BankAccountId == model.BankAccountId);
                account.AccountNumber = model.AccountNumber;
                account.EmailAddress = model.EmailAddress;
                dataContext.SubmitChanges();
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 3
0
        public ActionResult Edit(Guid id)
        {
            var model = new AccountViewModel();
            using (var dataContext = new CQRSDataContext())
            {
                var account = dataContext.BankAccountEntities.Single(x => x.BankAccountId == id);

                model.BankAccountId = account.BankAccountId;
                model.AccountNumber = account.AccountNumber;
                model.EmailAddress = account.EmailAddress;
            }

            return View(model);
        }
 public ActionResult Edit(int id)
 {
     using (var dataContext = new CQRSDataContext())
     {
         var transaction = dataContext.TransactionEntities.Single(x => x.TransactionId == id);
         var model = new TransactionViewModel
                         {
                             BankAccountId = transaction.BankAccountId,
                             Amount = transaction.Amount,
                             Description = transaction.Description,
                             TransactionDate = transaction.TransactionDate,
                             TransactionId = transaction.TransactionId
                         };
         return View(model);
     }
 }
Ejemplo n.º 5
0
        public ActionResult Add(AccountViewModel model)
        {
            var account = new BankAccountEntity
                              {
                                  BankAccountId = Guid.NewGuid(),
                                  AccountNumber = model.AccountNumber,
                                  EmailAddress =  model.EmailAddress
                              };

            using (var dataContext = new CQRSDataContext())
            {
                dataContext.BankAccountEntities.InsertOnSubmit(account);
                dataContext.SubmitChanges();
            }

            return RedirectToAction("Index");
        }
        public ActionResult Edit(TransactionViewModel model)
        {
            using (var dataContext = new CQRSDataContext())
            {
                var transaction = dataContext.TransactionEntities.Single(x => x.TransactionId == model.TransactionId);
                transaction.Amount = model.Amount;
                transaction.Description = model.Description;
                transaction.TransactionDate = model.TransactionDate;
                dataContext.SubmitChanges();
            }

            return RedirectToAction("Index", new { id = model.BankAccountId });
        }
        public ActionResult Index(Guid id)
        {
            using (var dataContext = new CQRSDataContext())
            {
                var account = dataContext.BankAccountEntities.Single(x => x.BankAccountId == id);

                var model = new TransactionsIndexViewModel
                                {
                                    Account = account,
                                    Transactions = account.TransactionEntities.OrderBy(x => x.TransactionDate).ToList()
                                };

                return View(model);
            }
        }