示例#1
0
        /// <summary>
        /// The main page of the TeachingPeriod controller
        /// Shows a list of all TeachingPeriods in the system
        /// </summary>
        /// <returns></returns>
        public ActionResult Index( )
        {
            // Make sure the user is logged in and that they have permission
            if (!IsUserLoggedIn)
            {
                return(RedirectToLogin());
            }
            if (!UserHasPermission(PermissionName.TeachingPeriod))
            {
                return(RedirectToPermissionDenied());
            }

            //Set the page message
            ViewBag.Message = "Teaching Period List";

            //db.GetTeachingPeriods( );

            // Get all teaching periods from the database
            var teachingPeriodModels = TeachingPeriodProcessor.SelectTeachingPeriods( );

            // Change the format of the year list
            List <TeachingPeriod> teachingPeriods = new List <TeachingPeriod>( );

            foreach (var t in teachingPeriodModels)
            {
                teachingPeriods.Add(new TeachingPeriod(t));
            }

            //Return the view, with the list of TeachingPeriods
            return(View(teachingPeriods));
        }
        public List <TeachingPeriod> GetTeachingPeriods( )
        {
            var teachingPeriodData = TeachingPeriodProcessor.SelectTeachingPeriods( );

            TeachingPeriods = new List <TeachingPeriod>( );
            foreach (var row in teachingPeriodData)
            {
                var teachingPeriod = new TeachingPeriod( )
                {
                    TeachingPeriodId = row.TeachingPeriodId,
                    Name             = row.Name
                };

                TeachingPeriods.Add(teachingPeriod);
            }
            return(TeachingPeriods);
        }