Exemplo n.º 1
0
        public JsonResult GetDataDetails([System.Web.Http.FromUri] string seedcode, [System.Web.Http.FromUri] string centretype, [System.Web.Http.FromUri] string dataname, [System.Web.Http.FromUri] string sYear)
        {
            try
            {
                ACCDataStore.Entity.Users temp    = Session["SessionUser"] as ACCDataStore.Entity.Users;
                object             oResult        = null;
                List <DataHubData> listSchoolData = new List <DataHubData>();

                var listSchool = GetListSchoolname();
                listSchool.Add(new DatahubCentre("1002", "Aberdeen City", "1"));
                var listdatasetdate       = GetListDataSetDate();
                var listNeighbourhoodName = GetListNeighbourhoodsname(rpGeneric2nd);
                listNeighbourhoodName.Add(new DatahubCentre("1002", "Aberdeen City", "1"));
                DatahubCentre selectedcentre = null;

                var selecteddatacatagory = new { Code = "Positive Destination", Name = "Positive Destination" };

                var layers = new[] { new { Code = "S01", Name = "Neighbourhood Zones" }, new { Code = "S02", Name = "School Locations" } }.ToList();
                var datacatagories = new[] { new { Code = "Positive Destination", Name = "Positive Destination" }, new { Code = "Non-Positive Destination", Name = "Non-Positive Destination" }, new { Code = "Unknown Destination", Name = "Unknown Destination" } }.ToList();

                if (centretype.Equals("32"))
                {
                    List <DatahubCentre> ListNeighbourSelected = seedcode != null?listNeighbourhoodName.Where(x => x.seedcode.Equals(seedcode)).ToList() : null;

                    selectedcentre       = listNeighbourhoodName.Where(x => x.seedcode.Equals(seedcode)).FirstOrDefault();
                    selecteddatacatagory = datacatagories.Where(x => x.Code.Equals(dataname)).FirstOrDefault();

                    if (ListNeighbourSelected != null && ListNeighbourSelected.Count > 0)
                    {
                        listSchoolData = GetDataHubNeighbourhoodDatabyStatuses(ListNeighbourSelected, sYear);
                    }
                }
                else
                {
                    List <DatahubCentre> ListSchoolSelected = seedcode != null?listSchool.Where(x => x.seedcode.Equals(seedcode)).ToList() : null;

                    selectedcentre       = listSchool.Where(x => x.seedcode.Equals(seedcode)).FirstOrDefault();
                    selecteddatacatagory = datacatagories.Where(x => x.Code.Equals(dataname)).FirstOrDefault();

                    if (ListSchoolSelected != null && ListSchoolSelected.Count > 0)
                    {
                        listSchoolData = GetDataHubSchoolDatabyStatuses(ListSchoolSelected, sYear);
                    }
                }

                oResult = new
                {
                    selectedcentre       = selectedcentre,
                    datasets             = listdatasetdate.Select(x => x.GetJson()),
                    selectedDataset      = listdatasetdate.Where(x => x.code.Equals(sYear)).Select(x => x.GetJson()).First(),
                    selecteddatacatagory = selecteddatacatagory,
                    listSchoolData       = listSchoolData
                };



                return(Json(oResult, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(ThrowJsonError(ex));
            }
        }
Exemplo n.º 2
0
        public JsonResult GetData([System.Web.Http.FromUri] string layertype, string datacatagory, string seedcode, string dataset)
        {
            try
            {
                object             oResult        = null;
                List <DataHubData> listSchoolData = new List <DataHubData>();

                var           listSchool            = GetListSchoolname();
                var           listdatasetdate       = GetListDataSetDate();
                var           listNeighbourhoodName = GetListNeighbourhoodsname(rpGeneric2nd);
                DatahubCentre selectedcentre        = null;
                var           selecteddatacatagory  = new { Code = "Participating Destination", Name = "Participating Destination" };

                var layers = new [] { new { Code = "S01", Name = "Neighbourhood Zones" }, new { Code = "S02", Name = "School Locations" } }.ToList();
                var datacatagories = new[] { new { Code = "Participating Destination", Name = "Participating Destination" }, new { Code = "Non-Participating Destination", Name = "Non-Participating Destination" }, new { Code = "Unknown Destination", Name = "Unknown Destination" } }.ToList();

                if (layertype.Equals("S01"))
                {
                    List <DatahubCentre> ListNeighbourSelected = seedcode != null?listNeighbourhoodName.Where(x => x.seedcode.Equals(seedcode)).ToList() : null;

                    selectedcentre       = listNeighbourhoodName.Where(x => x.seedcode.Equals(seedcode)).FirstOrDefault();
                    selecteddatacatagory = datacatagories.Where(x => x.Code.Equals(datacatagory)).FirstOrDefault();

                    if (ListNeighbourSelected != null && ListNeighbourSelected.Count > 0)
                    {
                        listSchoolData = GetDataHubNeighbourhoodDatabyStatuses(ListNeighbourSelected, dataset);
                    }
                }
                else
                {
                    List <DatahubCentre> ListSchoolSelected = seedcode != null?listSchool.Where(x => x.seedcode.Equals(seedcode)).ToList() : null;

                    selectedcentre       = listSchool.Where(x => x.seedcode.Equals(seedcode)).FirstOrDefault();
                    selecteddatacatagory = datacatagories.Where(x => x.Code.Equals(datacatagory)).FirstOrDefault();

                    if (ListSchoolSelected != null && ListSchoolSelected.Count > 0)
                    {
                        listSchoolData = GetDataHubSchoolDatabyStatuses(ListSchoolSelected, dataset);
                    }
                }

                //Load datahub summary for creating heatmap
                List <SummaryDHdata> heatmapdata = GetHeatMapdata(dataset);

                oResult = new
                {
                    selectedcentre       = selectedcentre,
                    layers               = layers,
                    selectedLayer        = layers.Where(x => x.Code.Contains(layertype)).FirstOrDefault(),
                    datasets             = listdatasetdate.Select(x => x.GetJson()),
                    selectedDataset      = listdatasetdate.Where(x => x.code.Equals(dataset)).Select(x => x.GetJson()).First(),
                    datacatagories       = datacatagories,
                    selecteddatacatagory = selecteddatacatagory,
                    heatmapdata          = heatmapdata,
                    ChartData            = GetChartData(listSchoolData)
                };



                return(Json(oResult, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(ThrowJsonError(ex));
            }
        }
Exemplo n.º 3
0
        public JsonResult GetListPupils([System.Web.Http.FromUri] string seedcode, [System.Web.Http.FromUri] string centretype, [System.Web.Http.FromUri] string dataname, [System.Web.Http.FromUri] string sYear)
        {
            try
            {
                Users temp = Session["SessionUser"] as Users;
                List <PupilsDataHubObj> templistpupils = new List <PupilsDataHubObj>();
                List <PupilsDataHubObj> listpupils     = new List <PupilsDataHubObj>();
                DatahubCentre           centreName     = new DatahubCentre();

                if (centretype.Equals("1"))
                {
                    //get list all pupils data by school
                    if (seedcode.Equals("1002"))
                    {
                        templistpupils = Getlistpupil(rpGeneric2nd, sYear);
                        centreName     = new DatahubCentre("1002", "Aberdeen City", "1");
                    }
                    else
                    {
                        templistpupils = Getlistpupil(rpGeneric2nd, sYear).Where(x => (x.SEED_Code != null && x.SEED_Code.Equals(seedcode))).ToList();;
                        centreName     = GetListSchoolname().Where(x => x.seedcode.Equals(seedcode)).First();
                    }
                }
                else if (centretype.Equals("2"))
                {
                    //get list pupils data by neighbourhood
                    if (seedcode.Equals("1002"))
                    {
                        templistpupils = Getlistpupil(rpGeneric2nd, sYear);
                        centreName     = new DatahubCentre("1002", "Aberdeen City", "2");
                    }
                    else
                    {
                        templistpupils = GetDatahubdatabyNeighbourhoods(rpGeneric2nd, seedcode, sYear);
                        centreName     = GetListNeighbourhoodsname(rpGeneric2nd).Where(x => x.seedcode.Equals(seedcode)).First();
                    }
                }


                switch (dataname.ToLower())
                {
                case "allclients":
                    listpupils = (from a in templistpupils where !a.SDS_Client_Ref.Equals("n/a") select a).ToList();
                    break;

                case "male":
                    listpupils = (from a in templistpupils where a.Gender.ToLower().Equals("male") select a).ToList();
                    break;

                case "female":
                    listpupils = (from a in templistpupils where a.Gender.ToLower().Equals("female") select a).ToList();
                    break;

                case "pupils16":
                    listpupils = (from a in templistpupils where a.Age == 16 select a).ToList();
                    break;

                case "pupils17":
                    listpupils = (from a in templistpupils where a.Age == 17 select a).ToList();
                    break;

                case "pupils18":
                    listpupils = (from a in templistpupils where a.Age == 18 select a).ToList();
                    break;

                case "pupils19":
                    listpupils = (from a in templistpupils where a.Age == 19 select a).ToList();
                    break;

                case "movedoutwithscotland":
                    listpupils = (from a in templistpupils where a.status_code.ToLower().Equals("000") select a).ToList();
                    break;

                default:
                    listpupils = (from a in templistpupils where a.status_code.ToLower().Equals(dataname.ToLower()) select a).ToList();
                    break;
                }

                var listdatasetdate = GetListDataSetDate();

                object oResult = null;

                oResult = new
                {
                    ListPupils = listpupils.Select(x => new
                    {
                        Forename     = x.Forename,
                        Surname      = x.Surname,
                        Age          = x.Age,
                        Gender       = x.Gender,
                        CSS_Address  = x.CSS_Address,
                        CSS_Postcode = x.CSS_Postcode,
                        Telephone    = x.Telephone_Number,
                    }).OrderBy(x => x.Age).ThenBy(x => x.Forename),
                    DatasetSelected = listdatasetdate.Where(x => x.code.Equals(sYear)).Select(x => x.GetJson()).First(),
                    DataTitle       = dataname,
                    CentreName      = centreName
                };

                return(Json(oResult, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(ThrowJsonError(ex));
            }
        }