예제 #1
0
        public ActionResult Index()
        {
            //this view model get the data of news, center photos, and president word
            HomeDataViewModel Data = new HomeDataViewModel();

            Data.news           = db.Newss.ToList();
            Data.CenterPhotos   = db.CenterPhotos.ToList();
            Data.PresidentWords = db.PresidentWords.ToList();
            return(View(Data));
        }
예제 #2
0
        //学生详情页面
        public IActionResult Data(int id)
        {
            // throw new Exception("此异常发生在Data视图中");
            Student student = _studentRepository.GetStudent(id);

            //处理404报错信息
            if (student == null)
            {
                Response.StatusCode = 404;
                return(View("StudentNotFound", id));
            }
            //实例化 HomeDataViewModel并存储Student详细信息和PageTitle
            HomeDataViewModel homeDataViewModel = new HomeDataViewModel()
            {
                Student   = student,
                PageTitle = "学生信息"
            };

            return(View(homeDataViewModel));
        }