예제 #1
0
        public CurriculumViewModel1 GetCurriculumsBySchoolYear(string schoolyear)
        {
            CurriculumViewModel1 vm = new CurriculumViewModel1 {
                SchoolYear = schoolyear
            };
            var    lll                = new List <CurriculumsByCampus>();
            string spStmt             = string.Format("call registration_get_curriculum_by_schoolyear_semester('{0}', 'fullyear')", schoolyear);
            List <CurriculumDTO> data = db.Database.SqlQuery <CurriculumDTO>(spStmt).ToList();

            foreach (string campus in new string[] { "HCC", "CCBC" })
            {
                CurriculumsByCampus cbc = new CurriculumsByCampus {
                    Campus = campus
                };

                var clst = new List <CurriculumByType>();

                foreach (int cat in new int[] { 0, 1, 2, 3, 4 })
                {
                    var cbt = new CurriculumByType {
                        id = cat
                    };

                    var typedCur = from d in data
                                   where d.campus == campus && d.coursetype == cat
                                   select new CurriculumsByCampusNType
                    {
                        AgeLimit        = d.minimumage,
                        BookFee         = d.unitPrice,
                        BookNameChinese = d.bookchinese,
                        BookNameEnglish = d.bookenglish,
                        Capacity        = d.capacity,
                        ChineseName     = d.classnamechinese,
                        ClassTime       = d.classtime,
                        EnglishName     = d.classnameenglish,
                        RegistrationFee = d.registrationFee,
                        Room            = d.classroomid,
                        TeacherChinese  = d.chineseName,
                        TeacherEnglish  = string.Format("{0} {1}", d.firstName, d.lastName),
                        TeacherEmail    = d.email,
                        Tuition         = d.tuition,
                    };
                    var lst = new List <CurriculumsByCampusNType>();
                    lst.AddRange(typedCur.ToList());
                    cbt.typedCurriculums = lst;

                    clst.Add(cbt);
                }
                cbc.ListCurriculumsByType = clst;
                lll.Add(cbc);
            }
            vm.ListCampus = lll;

            return(vm);
        }
예제 #2
0
        public JsonResult GetCurriculum(string schoolyear)
        {
            int yearStart = DateTime.Today.Month > 5 ? DateTime.Today.Year : DateTime.Today.AddYears(-1).Year;
            int yearEnd   = DateTime.Today.Month > 5 ? DateTime.Today.AddYears(1).Year : DateTime.Today.Year;

            if (!IsValidSchoolYear(schoolyear))
            {
                schoolyear = string.Format("{0}-{1}", yearStart, yearEnd);
            }

            string cacheKey          = "Curriculum-" + schoolyear;
            CurriculumViewModel1 vm1 = WebCache.Get(cacheKey) as CurriculumViewModel1;

            if (vm1 == null)
            {
                CurriculumViewModel1 vm = curRepo.GetCurriculumsBySchoolYear(schoolyear);
                WebCache.Set(cacheKey, vm);
                vm1 = vm;
            }
            return(Json(vm1));
        }