示例#1
0
        public IEnumerable <Exams> GetAllExams()
        {
            IExamsRepository             repo           = new ExamsRepository(getEntities());
            IEnumerable <Entities.Exams> returnedValue  = repo.GetAll();
            IEnumerable <Exams>          returnedValue2 = Mapper.Map <IEnumerable <Entities.Exams>, IEnumerable <Exams> >(returnedValue);

            return(returnedValue2);
        }
        // GET: Exams
        public ActionResult Index(int?page, string sortOrder, string searchString)
        {
            ViewBag.SearchString = (string.IsNullOrEmpty(searchString)) ? "" : searchString;
            sortOrder            = examsRepo.GetOrder(sortOrder, ref lastOrderField);
            var exams = examsRepo.GetAll(sortOrder, searchString);

            var examsVM = ExamMap.ExamsToExamsVM(exams);



            int pageSize   = 10;
            int pageNumber = (page ?? 1);
            int noOfPage   = (examsVM.Count() / pageSize) + ((examsVM.Count() % pageSize) == 0 ? 0 : 1);

            if (pageNumber > noOfPage)
            {
                pageNumber = 1;
            }
            return(View(examsVM.ToPagedList(pageNumber, pageSize)));
        }