Ejemplo n.º 1
0
 private IEnumerable <string> GetAllCategories(ITransactionsService transactionsService)
 {
     return(transactionsService.GetAll(x => !string.IsNullOrEmpty(x.Category))
            .Select(x => x.Category)
            .OrderBy(x => x)
            .Distinct());
 }
Ejemplo n.º 2
0
        public IActionResult Get()
        {
            var accounts = _accountService.GetAll().ToList();

            if (accounts.Count == 0)
            {
                return(Ok(new List <Models.Account>()));
            }

            foreach (var account in accounts)
            {
                var transactions = _transactionsService.GetAll(account.AccountId).ToList();
                account.Transactions = transactions;
            }

            return(Ok(accounts));
        }
Ejemplo n.º 3
0
        public IEnumerable <Transaction> GetTransactionsFiltered(ITransactionsService transactionsService)
        {
            var transactions = transactionsService
                               .GetAll(x => ApplyDateFilter(x) &&
                                       ApplyCategoriesFilter(x) &&
                                       ApplySearchFilter(x) &&
                                       !x.Ignored);
            var allCats = GetAllCategories(transactionsService);

            this.Categories = this.Categories.Union(allCats.Select(x => new SelectListItem()
            {
                Text = x, Value = x
            })).ToList();
            return(transactions);
        }
Ejemplo n.º 4
0
        public IActionResult Index()
        {
            var all = _transactionsService.GetAll()
                      .Where(x => x.Product.ExciseCode == "E420")
                      .Select(x => new TransactionsViewModel
            {
                Flowmeter         = x.DeviceId,
                TransactionNumber = x.Sequence,
                EndDate           = x.StopTime.ToString(),
                Receipt           = x.Product.Name,
                DensityAt15       = x.Density15.ToString(),
                Mass          = x.Mass.ToString(),
                VolumeAt15    = x.StdVolume.ToString(),
                FlowDirection = x.Direction.Direction.ToString()
            });

            var byDate = all.Where(x => x.FlowDirection == "OUTPUT")
                         .Select(x => new
            {
                Date     = x.EndDate.Substring(0, 10),
                Volume15 = decimal.Parse(x.VolumeAt15),
                Mass     = decimal.Parse(x.Mass),
            })
                         .GroupBy(x => x.Date)
                         .Select(g => new TransactionsByDateViewModel
            {
                Date     = g.Key,
                Volume15 = g.Sum(x => x.Volume15).ToString(),
                Mass     = g.Sum(x => x.Mass).ToString()
            });

            var modelsContainer = new List <object>();

            modelsContainer.Add(all);
            modelsContainer.Add(byDate);

            return(this.View(modelsContainer));
        }
        public async Task <IEnumerable <TransactionModel> > GetAll(int month, int year)
        {
            var transactions = await _transactionService.GetAll(month, year);

            return(_mapper.Map <IEnumerable <TransactionModel> >(transactions));
        }
Ejemplo n.º 6
0
        public IActionResult GetAll()
        {
            var transactions = _transactionsService.GetAll();

            return(Ok(transactions));
        }