コード例 #1
0
        public JsonResult RefreshData(DateTime start, DateTime end)
        {
            //this would be where I get data from the accommodation services or an SP (may be quicker)
            //here just randomise an object
            StackedViewModel chartData = GenerateRandomChartData();

            RefreshedDataModel model = new RefreshedDataModel()
            {
                XStackLabels = chartData.Stacks.FirstOrDefault().LstData.Select(x => x.SingleBar).ToList(),
                YValues      = chartData.Stacks.Select(x => x.LstData.Select(w => w.Quantity)).ToList(),
                XLabels      = chartData.Stacks.Select(x => x.StackedBar).ToList()
            };

            return(Json(model));
        }
コード例 #2
0
        private StackedViewModel GenerateRandomChartData()
        {
            Random rnd       = new Random();
            var    viewModel = new StackedViewModel();
            var    model     = new List <SingleBarViewModel>();

            viewModel.StartDate = DateTime.Now;
            viewModel.EndDate   = DateTime.Now.AddDays(25);

            string[] buildings = new[] { "Walnut", "Beech", "Maple", "Oak", "Acacia", "Jacaranda" };
            var      roomSts   = new List <string>()
            {
                "Active", "Provisional", "Void"
            };

            for (var i = 0; i < 6; i++)
            {
                viewModel.Stacks.Add(new Stack
                {
                    StackedBar = buildings[i],
                    LstData    = new List <SingleBarViewModel>
                    {
                        new SingleBarViewModel
                        {
                            SingleBar = "Active",
                            Quantity  = rnd.Next(10) // _service.CalculateActives(building[i])
                        },
                        new SingleBarViewModel
                        {
                            SingleBar = "Provisional",
                            Quantity  = rnd.Next(10) // _service.CalculateProvisionals(building[i])
                        },
                        new SingleBarViewModel
                        {
                            SingleBar = "Void",
                            Quantity  = rnd.Next(10) //_service.calculateVoids(building[i])
                        }
                    }
                });
            }
            ;

            return(viewModel);
        }
コード例 #3
0
        public ActionResult Chem6WeekChart()
        {
            int             PId    = 0;
            ChemicalPricing Objdal = new DAL.ChemicalPricing();


            List <SA_Chem6PriceWeekly> obj = null;
            string compare = string.Empty;

            string currentYear  = DateTime.Now.Year.ToString();
            string currentMonth = DateTime.Now.ToMonthName().ToUpper();
            string currentWeek  = ((Convert.ToInt32(DateTime.Now.Day) / 7) + 1).ToString();

            //               Convert.ToInt32(DateTime.Now.Day / 7).ToString();


            obj = Objdal.GetChem6WeekWise(currentYear, currentMonth, currentWeek);
            List <string> Year        = obj.Select(p => p.day).Distinct().ToList();
            List <string> Discription = obj.Select(p => p.Discription).Distinct().ToList();

            var lstModel = new List <StackedViewModel>();

            for (int i = 0; i < Year.Count; i++)
            {
                List <SA_Chem6PriceWeekly> Chartdata = obj.Where(Chart => Chart.day == Year[i]).ToList();
                PId = Chartdata.FirstOrDefault().Product.Value;
                //sales of product sales by quarter
                StackedViewModel Report = new StackedViewModel();
                Report.StackedDimensionOne = Year[i];

                List <SimpleReportViewModel> Data         = new List <SimpleReportViewModel>();
                List <SimpleReportViewModel> QuantityList = new List <ViewModel.SimpleReportViewModel>();


                foreach (var item in obj.Select(p => p.ProductVariant).Distinct().ToList())
                {
                    SimpleReportViewModel Quantity = new SimpleReportViewModel()
                    {
                        DimensionOne = item,// item.Month,
                        Quantity     = Chartdata.Where(x => x.ProductVariant == item).Sum(x => x.count.Value),
                        // MDimensionOne = Chartdata.FirstOrDefault(w=>w.ProductVariant== item).day
                    };
                    QuantityList.Add(Quantity);
                }


                //foreach (var item in Chartdata)
                //{
                //    SimpleReportViewModel Quantity = new SimpleReportViewModel()
                //    {
                //        DimensionOne = item.ProductVariant,
                //        Quantity = item.count.HasValue? item.count.Value:0,
                //        MDimensionOne = item.day
                //};
                //    QuantityList.Add(Quantity);
                //}
                Report.LstData = QuantityList;

                lstModel.Add(Report);

                lstModel[0].ProductName = ObjProduct.GetProductByid(PId).ProductName;
            }



            if (lstModel.Count() > 0)
            {
                return(PartialView("~/Views/PartialView/YearlyChartChemical6.cshtml", lstModel));
            }
            else
            {
                return(PartialView("~/Views/PartialView/YearlyChemical.cshtml", lstModel));
            }
        }
コード例 #4
0
        public ActionResult Chem1WeekChart(string year = "2019")
        {
            ChemAnalystContext _context = new ChemAnalystContext();
            int custid = 0;

            if (year == "")
            {
                year = DateTime.Now.Year.ToString();
            }
            ViewBag.CYear = year;
            ChemicalPricing Objdal = new DAL.ChemicalPricing();
            //ViewBag.QYears = Objdal.GetYear("W");

            List <SA_ChemPriceWeekly> obj = null;



            //var id= _context.SA_Product.OrderBy(x => new { x.Category, x.id }).FirstOrDefault().id;
            var catId = _context.SA_Category.OrderBy(x => x.id).FirstOrDefault().id;


            var product = _context.SA_Product.Where(w => w.Category == catId).OrderBy(x => x.id).FirstOrDefault().id.ToString();

            obj = Objdal.SA_Chem1PriceWeekly(product, year);



            List <string> Day         = obj.Select(p => p.Week).Distinct().ToList();
            List <string> Discription = obj.Select(p => p.Discription).Distinct().ToList();


            var lstModel = new List <StackedViewModel>();


            for (int i = 0; i < Day.Count; i++)
            {
                List <SA_ChemPriceWeekly> Chartdata = obj.Where(Chart => Chart.Week == Day[i]).ToList();;
                //obj.Where(Chart => Chart.year == DateTime.Now.Year.ToString() && Chart.day == Day[i]).ToList();
                //sales of product sales by quarter
                StackedViewModel Report = new StackedViewModel();
                Report.StackedDimensionOne = Day[i];
                Report.Discription         = Discription;
                Report.category            = Objdal.GetctegotyBYproduct(obj[0].Product);
                Report.Product             = (obj[0].Product).ToString();
                Report.Year = year;


                List <SimpleReportViewModel> Data         = new List <SimpleReportViewModel>();
                List <SimpleReportViewModel> QuantityList = new List <ViewModel.SimpleReportViewModel>();


                foreach (var item in obj.Select(p => p.ProductVariant).Distinct().ToList())
                {
                    SimpleReportViewModel Quantity = new SimpleReportViewModel()
                    {
                        DimensionOne = item,// item.Month,
                        Quantity     = Chartdata.Where(x => x.ProductVariant == item).Sum(x => x.count)
                    };
                    QuantityList.Add(Quantity);
                }


                Report.LstData = QuantityList;
                if (product == null)
                {
                    Report.ChartType = "line";
                    Report.range     = "Week";
                }
                else
                {
                    Report.Product   = product;
                    Report.ChartType = "bar";
                    Report.range     = "Weekly";
                }
                lstModel.Add(Report);
            }

            ViewBag.Category = Objdal.GetctegotyBYproduct(int.Parse(product));

            lstModel[0].ProductName = ObjProduct.GetProductByid(Convert.ToInt32(product)).ProductName;
            if (lstModel.Count() > 0)
            {
                return(PartialView("~/Views/PartialView/YearlyChartChemical1.cshtml", lstModel));
            }
            else
            {
                return(PartialView("~/Views/PartialView/YearlyChemical.cshtml", lstModel));
            }
        }