public CalculatedInflation InflationHelper(string inflation, int i, string pcName)
        {
            //NumberFormatInfo nfi = new CultureInfo("en-us", false).NumberFormat;
            CalculatedInflation calculatedInflation = new CalculatedInflation();

            calculatedInflation.InflationID   = 1000;
            calculatedInflation.InflationName = pcName;
            calculatedInflation.FiscalYear    = DateTime.Now.Year - i;

            calculatedInflation.InflationRate = inflation;

            return(calculatedInflation);
        }
Exemple #2
0
        public async Task OnGetAsync(int?pageIndex)
        {
            //This page will have pagination, but not sort, and not filter

            IQueryable <ProductCategory> productCategoryIQ = from pc in _context.ProductCategory
                                                             .Include(p => p.Product)
                                                             .ThenInclude(o => o.Offering)
                                                             .ThenInclude(ao => ao.ArchivedOffering)
                                                             select pc;

            calculatedInflations = new List <CalculatedInflation>();

            foreach (var pc in productCategoryIQ)
            {
                List <ArchivedOffering> archivesInCategory = pc.Product.SelectMany(o => o.Offering.SelectMany(ao => ao
                                                                                                              .ArchivedOffering.Where(aoVal => aoVal.Price.HasValue).Where(aoDate => aoDate.Date != null))).ToList();

                if (archivesInCategory.Count != 0)
                {
                    DateTime oldestDate = archivesInCategory.Min(aoDate => aoDate.Date);
                    int      length     = DateTime.Now.Year - oldestDate.Year + 1;
                    for (int i = 0; i < length; i++)
                    {
                        CalculatedInflation calculatedInflation = MakeCalculatedInflation(archivesInCategory, pc.Name, i);
                        calculatedInflations.Add(calculatedInflation);
                    }
                }
            }
            calculatedInflations = calculatedInflations.OrderBy(c => c.InflationName)
                                   .ThenByDescending(date => date.FiscalYear).ToList();

            int pageSize = 12;

            CalculatedInflation = PaginatedList <CalculatedInflation> .CreateNonAsync(calculatedInflations, pageIndex ?? 1, pageSize);


            //***********************Authorization***********************************************************************

            Product productForAuth = new Product();
            var     isAuthorized   = await AuthorizationService.AuthorizeAsync(User, productForAuth, Operations.Read);

            if (!isAuthorized.Succeeded)
            {
                new ChallengeResult();
            }
            //**********************************************************************************************************
        }