コード例 #1
0
        public JsonResult RegionalData(int regionID)
        {
            var requests = _regionalRequestService.FindBy(t => t.RegionID == regionID);
            var requisitions = _reliefRequisitionService.FindBy(t => t.RegionID == regionID);
            var totalRequests = requests.Count();

            var draft = (from r in requests
                         where r.Status == 1
                         select r).Count();

            var approved = (from r in requests
                            where r.Status == 2
                            select r).Count();

            var closed = (from r in requests
                          where r.Status == 3
                          select r).Count();

            var federalApp = (from r in requests
                              where r.Status >= 4
                              select r).Count();

            var reqApp = (from r in requisitions
                          where r.Status == 2
                          select r).Count();

            var reqDraft = (from r in requisitions
                            where r.Status == 1
                            select r).Count();

            var reqHub = (from r in requisitions
                          where r.Status >= 3
                          select r).Count();

            var d = new DashboardData()
                {
                    ApprovedRequests = (decimal)approved*100/totalRequests,
                    PendingRequests = (decimal)(draft * 100) / totalRequests,
                    HubAssignedRequests = (decimal)(closed * 100) / totalRequests,
                    FederalApproved = (decimal)(federalApp * 100) / totalRequests,

                    ApprovedRequisitions = ((decimal)(reqApp * 100) / requisitions.Count()),
                    HubAssignedRequisitions = ((decimal)(reqHub * 100) / requisitions.Count()),
                    PendingRequisitions = ((decimal)(reqDraft * 100) / requisitions.Count()),

                    Above18 = 45,
                    Bet5And8 = 26,
                    Below5 = 29,
                    Female = 24152,
                    Male = 21451,
                    IncomingCommodity = 25131,
                    IncomingDispatches = 2142
                };

            return Json(d, JsonRequestBehavior.AllowGet);
        }
コード例 #2
0
        public JsonResult RegionalData(int regionID)
        {
            var requests = _regionalRequestService.FindBy(t => t.RegionID == regionID);
            var requisitions = _reliefRequisitionService.FindBy(t => t.RegionID == regionID);
            var totalRequests = requests.Count();
            var currentPlan = _hrdService.FindBy(t => t.Status == 3).FirstOrDefault().PlanID;
            var utilizations = _utilization.FindBy(t => t.PlanID == currentPlan);

            var sum18 = 0;
            var sum518 = 0;
            var sum5 = 0;
            var female = 0;
            var male = 0;

            if(utilizations!=null){
            foreach (var i in utilizations) {
                sum18 = +(i.FemaleAbove18Years+i.MaleAbove18Years);
                sum5 = +(i.FemaleLessThan5Years + i.MaleLessThan5Years);
                sum518 = +(i.FemaleBetween5And18Years + i.MaleBetween5And18Years);
                female = +(i.FemaleAbove18Years + i.FemaleBetween5And18Years + i.FemaleLessThan5Years);
                male = +(i.MaleAbove18Years + i.MaleBetween5And18Years + i.MaleLessThan5Years);
            }}

            var draft = (from r in requests
                         where r.Status == 1
                         select r).Count();

            var approved = (from r in requests
                            where r.Status == 2
                            select r).Count();

            var closed = (from r in requests
                          where r.Status == 3
                          select r).Count();

            var federalApp = (from r in requests
                              where r.Status >= 4
                              select r).Count();

            var reqApp = (from r in requisitions
                          where r.Status == 2
                          select r).Count();

            var reqDraft = (from r in requisitions
                            where r.Status == 1
                            select r).Count();

            var reqHub = (from r in requisitions
                          where r.Status >= 3
                          select r).Count();

            var d = new DashboardData();

            if (totalRequests != 0)
            {
                d.ApprovedRequests = (decimal)approved;
                d.PendingRequests = (decimal)(draft);
                d.HubAssignedRequests = (decimal)(closed);
                d.FederalApproved = (decimal)(federalApp);

            }
            if (requisitions.Count() != 0)
            {
                d.ApprovedRequisitions = ((decimal)(reqApp));
                d.HubAssignedRequisitions = ((decimal)(reqHub));
                d.PendingRequisitions = ((decimal)(reqDraft));
            }

            d.Above18 = sum18;
            d.Bet5And8 = sum518;
            d.Below5 = sum5;
            d.Female = female;
            d.Male = male;

            d.IncomingCommodity = 25131;
            d.IncomingDispatches = 2142;

            return Json(d, JsonRequestBehavior.AllowGet);
        }