示例#1
0
        public IActionResult Summary(float corpTribute = 20)
        {
            ViewData["corpTribute"] = corpTribute / 100;

            // Use LINQ to get list of Corps.
            IQueryable <string> corpQuery = from m in _context.MiningJob
                                            orderby m.Corp
                                            select m.Corp;
            List <string> corps = corpQuery.Distinct().ToList();

            //Create a list of summarys, one for each Corp
            List <CorpSummary> summaryList = new List <CorpSummary>();

            foreach (string c in corps)
            {
                //get a List of all Pilot summarys for that Corp
                List <PilotSummary> pilotSummarys = getPilotSummarys(c);

                //calculate value and volume and create corp joblist
                int              oreValueSum  = 0;
                float            oreVolumeSum = 0;
                List <MiningJob> joblist      = new List <MiningJob>();
                foreach (PilotSummary pj in pilotSummarys)
                {
                    oreValueSum  = oreValueSum + pj.Value;
                    oreVolumeSum = oreVolumeSum + pj.Volume;
                    joblist.AddRange(pj.Jobs);
                }

                //create summary and add it to the list
                CorpSummary summary = new CorpSummary(c, joblist, pilotSummarys);
                summary.Value  = oreValueSum;
                summary.Volume = oreVolumeSum;

                summaryList.Add(summary);
            }

            return(View(summaryList));
        }
示例#2
0
        // GET: /<controller>/
        // Obsolete
        public IActionResult CorpSummary()
        {
            // Use LINQ to get list of Corps.
            IQueryable <string> corpQuery = from m in _context.MiningJob
                                            orderby m.Corp
                                            select m.Corp;
            List <string> corps = corpQuery.Distinct().ToList();

            //Create a list of summarys, one for each Corp
            List <CorpSummary> summaryList = new List <CorpSummary>();

            foreach (string c in corps)
            {
                //filter for corp's jobs
                var jobs = from m in _context.MiningJob
                           select m;

                jobs = jobs.Where(x => x.Corp == c);
                List <MiningJob> joblist = jobs.ToList();

                //calculate value and volume
                int   oreValueSum  = 0;
                float oreVolumeSum = 0;
                foreach (MiningJob j in joblist)
                {
                    oreValueSum  = oreValueSum + j.EstimatedValue;
                    oreVolumeSum = oreVolumeSum + j.Volumen;
                }

                //create summary and add it to the list
                CorpSummary summary = new CorpSummary(c, joblist, null);
                summary.Value  = oreValueSum;
                summary.Volume = oreVolumeSum;

                summaryList.Add(summary);
            }

            return(View(summaryList));
        }