예제 #1
0
        private void InitializeChart()
        {
            //filter by currency
            OperationDtoFilter  filter       = GetChartFilter();
            List <OperationDto> filteredList = _operationRepo.Filter(filter);

            //filter by category
            List <OperationTypeDto> categories = _operationTypeRepo.All();

            List <ChartItem> values = new List <ChartItem>();

            foreach (OperationTypeDto category in categories)
            {
                ChartItem chartItem = new ChartItem()
                {
                    Name  = category.Name,
                    Value = filteredList
                            .Where(d => d.IdOperationType == category.Id)
                            .Sum(d => d.Ammount)
                };
                values.Add(chartItem);
            }

            pieSeries.ItemsSource = values;
        }
예제 #2
0
        private void InitializeData()
        {
            // Initialize Accounts
            List <AccountDto> accountDtos = _accountRepo.All();

            foreach (AccountDto accountDto in accountDtos)
            {
                ComboItem comboItem = new ComboItem()
                {
                    Name = $"{accountDto.Name} {accountDto.Currency.Name}",
                    Id   = accountDto.Id
                };
                cbAccount.Items.Add(comboItem);
            }

            //Initialize Categories
            List <OperationTypeDto> operationTypeDtos = _operationTypeRepo.All();

            foreach (OperationTypeDto operationTypeDto in operationTypeDtos)
            {
                ComboItem comboItem = new ComboItem()
                {
                    Name = operationTypeDto.Name,
                    Id   = operationTypeDto.Id
                };
                cbCategory.Items.Add(comboItem);
            }
        }
        public async Task <ActionResult> Index()
        {
            List <OperationTypeDto> all = await _operationTypeRepo.All();

            List <OperationTypeViewModel> vm =
                Mapper.Map <List <OperationTypeDto>, List <OperationTypeViewModel> >(all);

            return(View(vm));
        }
예제 #4
0
        private void InitializeCombos()
        {
            List <CurrencyDto> currencyDtos = _currencyRepo.All();

            InitializeCurrencies(currencyDtos);

            List <AccountDto> accountDtos = _accountRepo.All();

            InitializeAccounts(accountDtos);

            List <OperationTypeDto> operationTypeDtos = _operationTypeRepo.All();

            InitializeCategories(operationTypeDtos);
        }
        private async Task AddAccountsAndCategories(OperationViewModel vm)
        {
            List <AccountDto> accountDtos = await _accountRepo.All();

            vm.Accounts = accountDtos.Select(d => new SelectListItem()
            {
                Text  = d.Name + ' ' + d.Currency.Name,
                Value = d.Id.ToString(),
            }).ToList();

            List <OperationTypeDto> operationTypeDtos = await _operationTypeRepo.All();

            vm.Categories = operationTypeDtos.Select(d => new SelectListItem()
            {
                Text  = d.Name,
                Value = d.Id.ToString()
            }).ToList();
        }