public IndexSchoolProfilesController(IGenericRepository2nd rpGeneric2nd)
 {
     this.rpGeneric2nd = rpGeneric2nd; //connect to accdatastore database in MySQL
     this.vmIndexPrimarySchoolProfilesModel   = new IndexPrimarySchoolProfilesViewModel();
     this.vmIndexSecondarySchoolProfilesModel = new IndexSecondarySchoolProfilesViewModel();
     this.vmIndexSpecialSchoolProfilesModel   = new IndexSecondarySchoolProfilesViewModel();
 }
        public ActionResult GetPrimaryListpupils(string datatitle, string Indexrow, string Indexcol)
        {
            PupilsListViewModel vmPupilsListViewModel = new PupilsListViewModel();

            //pull data from session that has been stored in GetPrimaryProfileData function
            vmIndexPrimarySchoolProfilesModel = Session["vmIndexPrimarySchoolProfilesModel"] as IndexPrimarySchoolProfilesViewModel;
            List <DataSeries> listAllPupils     = new List <DataSeries>();
            List <StudentObj> listtempPupilData = new List <StudentObj>();
            DataTable         dataTable         = new DataTable();
            string            colName           = "";
            string            catagory          = "";
            string            code  = "";
            string            title = "";

            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            switch (datatitle)
            {
            case "englishlevel":
                listAllPupils = vmIndexPrimarySchoolProfilesModel.listDataSeriesEnglishLevel;
                dataTable     = vmIndexPrimarySchoolProfilesModel.dataTableEnglishLevel;
                //colName = dataTable.Rows[Convert.ToInt16(Indexrow)][0].ToString();
                colName    = dataTable.Columns[Convert.ToInt16(Indexcol)].ToString();
                dictionary = vmIndexPrimarySchoolProfilesModel.DicEnglishLevel;
                code       = dictionary.FirstOrDefault(x => x.Value.Contains(colName)).Key; //get englishlevelcode
                catagory   = dictionary.FirstOrDefault(x => x.Value.Contains(colName)).Value;
                //query to get pupils list by code from DataSeries
                listtempPupilData = listAllPupils.ElementAt(Convert.ToInt16(Indexrow)).listdataitems.Where(x => x.itemcode.Equals(code)).FirstOrDefault().liststudents;
                title             = "Level of English";
                break;

            case "ethnicity":
                listAllPupils = vmIndexPrimarySchoolProfilesModel.listDataSeriesEthnicBackground;
                dataTable     = vmIndexPrimarySchoolProfilesModel.dataTableEthnicBackground;
                colName       = dataTable.Columns[Convert.ToInt16(Indexcol)].ToString();
                dictionary    = vmIndexPrimarySchoolProfilesModel.DicEthnicBG;
                code          = dictionary.FirstOrDefault(x => x.Value.Contains(colName)).Key; //get englishlevelcode
                catagory      = dictionary.FirstOrDefault(x => x.Value.Contains(colName)).Value;
                //query to get pupils list by code from DataSeries
                listtempPupilData = listAllPupils.ElementAt(Convert.ToInt16(Indexrow)).listdataitems.Where(x => x.itemcode.Equals(code)).FirstOrDefault().liststudents;
                title             = "Ethnicity";
                break;

            case "nationality":
                listAllPupils = vmIndexPrimarySchoolProfilesModel.listDataSeriesNationality;
                dataTable     = vmIndexPrimarySchoolProfilesModel.dataTableNationality;
                colName       = dataTable.Columns[Convert.ToInt16(Indexcol)].ToString();
                dictionary    = vmIndexPrimarySchoolProfilesModel.DicNationalIdentity;
                code          = dictionary.FirstOrDefault(x => x.Value.Contains(colName)).Key; //get englishlevelcode
                catagory      = dictionary.FirstOrDefault(x => x.Value.Contains(colName)).Value;
                //query to get pupils list by code from DataSeries
                listtempPupilData = listAllPupils.ElementAt(Convert.ToInt16(Indexrow)).listdataitems.Where(x => x.itemcode.Equals(code)).FirstOrDefault().liststudents;
                title             = "Nationality";
                break;

            case "stage":
                listAllPupils = vmIndexPrimarySchoolProfilesModel.listDataSeriesStage;
                dataTable     = vmIndexPrimarySchoolProfilesModel.dataTableStage;
                colName       = dataTable.Columns[Convert.ToInt16(Indexcol)].ToString();
                dictionary    = vmIndexPrimarySchoolProfilesModel.DicStage;
                code          = dictionary.FirstOrDefault(x => x.Value.Contains(colName)).Key; //get englishlevelcode
                catagory      = dictionary.FirstOrDefault(x => x.Value.Contains(colName)).Value;
                //query to get pupils list by code from DataSeries
                listtempPupilData = listAllPupils.ElementAt(Convert.ToInt16(Indexrow)).listdataitems.Where(x => x.itemcode.Equals(code)).FirstOrDefault().liststudents;
                title             = "Satge";
                break;
            }
            vmPupilsListViewModel.listPupils = listtempPupilData;
            vmPupilsListViewModel.school     = listAllPupils.ElementAt(Convert.ToInt16(Indexrow)).school;
            vmPupilsListViewModel.catagory   = catagory;
            vmPupilsListViewModel.datatile   = title;
            return(View("Pupilslist", vmPupilsListViewModel));
        }