Exemplo n.º 1
0
        // GET: Exam

        public IActionResult Index(string searchString, string currentFilter, int?pageNumber, string message)
        {
            ViewBag.Message = message;
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;
            List <ExamViewModel> examViewModels = new List <ExamViewModel>();
            IEnumerable <Exam>   exams;

            if (!string.IsNullOrEmpty(searchString))
            {
                exams = _examManager.Search(searchString);
            }
            else
            {
                exams = _examManager.GetAll();
            }

            foreach (Exam e in exams)
            {
                examViewModels.Add(MapToExamViewModel(e));
            }

            int pageSize = 8;

            return(View(PaginatedList <ExamViewModel> .Create(examViewModels, pageNumber ?? 1, pageSize)));
        }
Exemplo n.º 2
0
        public void AddExam_Test()
        {
            _manager.Add(EXAM);

            IList <Exam> exams = _manager.GetAll().ToList();

            Assert.Equal(1, exams.Count);
            Exam exam = exams.First();

            Assert.Equal("ASP .NET", exam.Course.CourseName);
        }
Exemplo n.º 3
0
        public List <ExamModel> GetAll()
        {
            var exams = ExamManager.GetAll();

            return(exams.Select(s => Mapper.Map(s)).ToList());
        }