Exemplo n.º 1
0
        public async Task <List <ProductViewModel> > ReadAllAsync()
        {
            var products = await productRepository.ReadAllAsync();

            var euroRate = await mnbService.GetEuroRate();

            List <ProductViewModel> productViews = new List <ProductViewModel>();

            foreach (var product in products)
            {
                var viewModel = new ProductViewModel
                {
                    Id          = product.Id,
                    ProductCode = product.ProductCode,
                    Name        = product.Name,
                    Price       = product.Price.ToString("C0", CultureInfo.CreateSpecificCulture("hu-HU")),
                    Description = product.Description,
                    Quantity    = product.Quantity,
                    Weight      = product.Weight,
                    EuroPrice   = (product.Price / euroRate).ToString("C2", CultureInfo.CreateSpecificCulture("de-DE"))
                };
                productViews.Add(viewModel);
            }
            return(productViews);
        }
Exemplo n.º 2
0
        public async Task <StatsViewModel> MakeStatistics()
        {
            double totalWeight = await TotalWeightCounter();

            long totalValue = await TotalValueCounter();

            var maxQuantity = await MostItemsFinder();

            var heaviestProduct = await HeaviestItemFinder();

            var euroRate = await mnbstatService.GetEuroRate();

            StatsViewModel stats = new StatsViewModel
            {
                TotalWeight     = totalWeight,
                TotalValue      = totalValue.ToString("C0", CultureInfo.CreateSpecificCulture("hu-HU")),
                EuroValue       = (totalValue / euroRate).ToString("C2", CultureInfo.CreateSpecificCulture("de-DE")),
                MaxQuantity     = maxQuantity,
                HeaviestProduct = heaviestProduct
            };

            return(stats);
        }