コード例 #1
0
        public ActionResult GetTransactionsBySearchNameFilters(string bankAccountId, string name, string fromDate, string toDate,
                                                               int?selectedItemsForPage, int?selectedFilterId, int page = 1)
        {
            if (!String.IsNullOrEmpty(bankAccountId) && !String.IsNullOrEmpty(name))
            {
                var bankAccount       = _readBankAccount.GetBankAccountById(bankAccountId);
                var binder            = new ToTransactionListViewModel();
                var currencyLogic     = new CurrencyLogic();
                var filterLogic       = new FiltersLogic();
                var filterName        = "";
                var filterValue       = "";
                var fromDateConverted = filterLogic.GetDateTimeByDateStringWithDots(fromDate);
                var toDateConverted   = filterLogic.GetEndDateTimeDateStringWithDots(toDate);
                filterLogic.GetFilterNameFilterValueById(selectedFilterId, out filterName, out filterValue);
                var itemsForPage = filterLogic.GetItemsForPageById(selectedItemsForPage);


                var transactions          = _readTransaction.GetSearchTransactionsByFilters(bankAccountId, fromDateConverted, toDateConverted, filterName, filterValue, name);
                var viewModelTransactions = binder.GetTransactions(transactions,
                                                                   currencyLogic.GetCurrencyIconById(bankAccount.Currency)).ToPagedList(page, itemsForPage);

                return(PartialView("TransactionList", viewModelTransactions));
            }
            else
            {
                return(new JsonResult
                {
                    Data = "Wystąpił błąd podczas operacji.",
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
コード例 #2
0
        public TransactionCreateViewModel GetViewModel(Model.BankAccount bankAccount, CurrencyLogic currencyLogic)
        {
            var viewModel = new TransactionCreateViewModel
            {
                AccountBalance = bankAccount.Balance,
                Currency       = currencyLogic.GetCurrencyIconById(bankAccount.Currency),
                BankAccountId  = bankAccount.Id,
                UserId         = bankAccount.User.Id
            };

            return(viewModel);
        }
コード例 #3
0
        public BankAccountDeleteViewModel GetViewModel(Model.BankAccount bankAccount, CurrencyLogic currencyLogic)
        {
            var viewModel = new BankAccountDeleteViewModel
            {
                Id       = bankAccount.Id,
                Name     = bankAccount.Name,
                Balance  = bankAccount.Balance,
                Currency = currencyLogic.GetCurrencyIconById(bankAccount.Currency),
                Created  = bankAccount.Created,
                UserId   = bankAccount.User.Id
            };

            return(viewModel);
        }
コード例 #4
0
        public BankAccountDetailsViewModel GetViewModel(Model.BankAccount bankAccount, CurrencyLogic currencyLogic)
        {
            var viewModel = new BankAccountDetailsViewModel()
            {
                Id       = bankAccount.Id,
                Name     = bankAccount.Name,
                Balance  = bankAccount.Balance,
                Currency = currencyLogic.GetCurrencyIconById(bankAccount.Currency),
                User     = bankAccount.User,
                SelectedItemsForPageId = 1
            };

            return(viewModel);
        }
コード例 #5
0
        public TransactionDeleteViewModel GetTransaction(Model.Transaction transaction, CurrencyLogic currencyLogic)
        {
            var viewModel = new TransactionDeleteViewModel
            {
                Id             = transaction.Id,
                Name           = transaction.Name,
                Amount         = transaction.Amount,
                AccountBalance = transaction.AccountBalance,
                SetDate        = transaction.SetDate,
                Currency       = currencyLogic.GetCurrencyIconById(transaction.BankAccount.Currency),
                BankAccountId  = transaction.BankAccount.Id,
                UserId         = transaction.BankAccount.User.Id
            };

            return(viewModel);
        }
コード例 #6
0
        public TransactionEditViewModel GetViewModel(Model.Transaction transaction, CurrencyLogic currencyLogic)
        {
            var viewModel = new TransactionEditViewModel()
            {
                Id             = transaction.Id,
                Name           = transaction.Name,
                Balance        = transaction.Amount,
                AccountBalance = transaction.AccountBalance,
                SetDate        = transaction.SetDate,
                Description    = transaction.Description,
                Currency       = currencyLogic.GetCurrencyIconById(transaction.BankAccount.Currency),
                BankAccountId  = transaction.BankAccount.Id,
                UserId         = transaction.BankAccount.User.Id
            };

            return(viewModel);
        }
コード例 #7
0
        public IList <BankAccountListViewModel> GetListViewModel(IEnumerable <Model.BankAccount> bankAccounts, CurrencyLogic currencyLogic)
        {
            IList <BankAccountListViewModel> listAccountViewModel = new List <BankAccountListViewModel>();

            foreach (var bankAccount in bankAccounts)
            {
                listAccountViewModel.Add(new BankAccountListViewModel()
                {
                    Id       = bankAccount.Id,
                    Name     = bankAccount.Name,
                    Balance  = bankAccount.Balance,
                    Currency = currencyLogic.GetCurrencyIconById(bankAccount.Currency),
                    UserId   = bankAccount.User.Id
                });
            }

            return(listAccountViewModel);
        }
コード例 #8
0
        public ActionResult LoadTransactionBySearchName(string name, string bankAccountId)
        {
            if (Request.IsAjaxRequest() && !String.IsNullOrEmpty(bankAccountId) && !String.IsNullOrEmpty(name))
            {
                var currencyLogic = new CurrencyLogic();
                var binder        = new ToTransactionListViewModel();

                var bankAccount = _readBankAccount.GetBankAccountById(bankAccountId);
                var transaction = _readTransaction.GetTransactionByName(name, bankAccountId);

                var viewModelTransaction =
                    binder.GetTransactions(transaction, currencyLogic.GetCurrencyIconById(bankAccount.Currency)).ToPagedList(1, 1);

                return(PartialView("TransactionList", viewModelTransaction));
            }

            return(new JsonResult()
            {
                Data = "Wystąpił błąd podczas operacji wczytywania transakcji po nazwie.",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
コード例 #9
0
        public ActionResult GetTransactionsByBankAccountId(string bankAccountId, int page = 1, int selectedItemsForPage = 1)
        {
            if (!String.IsNullOrEmpty(bankAccountId))
            {
                var bankAccount           = _readBankAccount.GetBankAccountById(bankAccountId);
                var binder                = new ToTransactionListViewModel();
                var currencyLogic         = new CurrencyLogic();
                var filterLogic           = new FiltersLogic();
                var itemsForPage          = filterLogic.GetItemsForPageById(selectedItemsForPage);
                var viewModelTransactions = binder.GetTransactions(bankAccount.Transactions,
                                                                   currencyLogic.GetCurrencyIconById(bankAccount.Currency)).ToPagedList(page, itemsForPage);

                return(PartialView("TransactionList", viewModelTransactions));
            }
            else
            {
                return(new JsonResult
                {
                    Data = "Wystąpił błąd podczas operacji.",
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }