Beispiel #1
0
        public void ShouldMapCourseToIndexModel()
        {
            var courseIndexModel = new IndexModel();
            var courseEntity = new Web.Data.Entities.Course
            {
                CourseCode = "CSC101",
                CourseTitle = "Intro to Programming",
                NumberOfParts = 1,
                AcademicSubjectDescriptorId = (int)AcademicSubjectDescriptorEnum.EnglishLanguageArts,
                CourseDescription = "Learnin some Java",
                DateCourseAdopted = new DateTime(2014, 07, 03),
                HighSchoolCourseRequirement = false,
                CourseGPAApplicabilityTypeId = (int)CourseGPAApplicabilityTypeEnum.Applicable,
                CourseDefinedByTypeId = (int)CourseDefinedByTypeEnum.LEA,
                MinimumAvailableCreditTypeId = (int)CreditTypeEnum.Adulteducationcredit,
                MinimumAvailableCreditConversion = 3m,
                MinimumAvailableCredit = 3m,
                MaximumAvailableCreditTypeId = (int)CreditTypeEnum.CareerandTechnicalEducationcredit,
                MaximumAvailableCreditConversion = 3m,
                MaximumAvailableCredit = 3m,
                CareerPathwayTypeId = (int)CareerPathwayTypeEnum.AgricultureFoodandNaturalResources,
                TimeRequiredForCompletion = 10,
            };

            var courseToCreateModelMapper = new CourseToIndexModelMapper();
            courseToCreateModelMapper.Map(courseEntity, courseIndexModel);

            courseIndexModel.CourseCode.ShouldBe("CSC101");
            courseIndexModel.CourseTitle.ShouldBe("Intro to Programming");
            courseIndexModel.CourseDescription.ShouldBe("Learnin some Java");
        }
        public virtual ActionResult Index()
        {
            IEnumerable<Course> courses = _genericRepository.GetAll<Course>().ToList();
            var indexModels = new List<IndexModel>();

            foreach (var course in courses)
            {
                var indexModel = new IndexModel();
                _courseToIndexModelMapper.Map(course, indexModel);
                indexModels.Add(indexModel);
            }

            return View(indexModels);
        }