コード例 #1
0
        public ActionResult Index()
        {
            var fvm = new FacultyViewModel();

            fvm.Faculties = _fr.GetAll().OrderBy(x => x.FacultyName);
            if (fvm.Faculties == null && fvm.Faculties.Count() < 0)
            {
                throw new HttpException(404, "The resource you are looking could have been removed, had its name changed, or is temporarily unavailable.");
            }
            return(View(fvm));
        }
コード例 #2
0
        public ActionResult AssignFaculty()
        {
            FacultyRepository     facRepo = new FacultyRepository();
            CourseRepository      crsRepo = new CourseRepository();
            List <SelectListItem> facList = new List <SelectListItem>();
            List <SelectListItem> secList = new List <SelectListItem>();// a list of selectable items

            foreach (Faculty fac in facRepo.GetAll())
            {
                SelectListItem option = new SelectListItem();
                option.Text  = fac.Name;
                option.Value = fac.Id.ToString();

                facList.Add(option);
            }

            // sending the list to view through ViewBag
            ViewBag.faculties = facList;

            foreach (Course crs in crsRepo.GetAll())
            {
                SelectListItem option = new SelectListItem();
                option.Text  = crs.CourseName;
                option.Value = crs.Id.ToString();

                secList.Add(option);
            }

            // sending the list to view through ViewBag
            ViewBag.courses = secList;

            return(View());
        }
コード例 #3
0
        public JsonResult Index()
        {
            var allFaculties = new List <FacultyViewModel>();

            foreach (var faculty in _facultyRepository.GetAll())
            {
                var facultyToView = Mapper.Map <FacultyViewModel>(faculty);
                allFaculties.Add(facultyToView);
            }
            return(Json(new { result = allFaculties }, JsonRequestBehavior.AllowGet));
        }