public List <CourseTypeModelDto> GetAllCourseTypes() { try { return(CourseTypeModelDto.Map(new Repository <CourseTypeModel>().GetAll().ToList())); } catch (Exception ex) { Logger.Error("Error : CourseService.GetAllCourseTypes - {0}", ex.Message); return(new List <CourseTypeModelDto>()); } }
public void Can_filter_courses_by_course_type() { #region Arrange #endregion #region Act List <CourseDto> filteredCourses = new CourseService().GetByCourseType(CourseTypeModelDto.Map(TestCourseType)); #endregion #region Assert Assert.That(filteredCourses.Count, Is.EqualTo(1)); #endregion }
public void Can_update_course_reference() { #region Arrange var course = new CourseService().GetById(1); course.CourseType = CourseTypeModelDto.Map(TestCourseType1); #endregion #region Act var updateOk = new CourseService().Update(course, false); course = new CourseService().GetById(1); #endregion #region Assert Assert.That(updateOk, Is.True); Assert.That(course.CourseType.TypeName, Is.EqualTo("Matematyka")); #endregion }
public List <CourseDto> GetByCourseType(CourseTypeModelDto testCourseType) { try { List <CourseDto> returnedList; using (var session = DataAccess.OpenSession()) { returnedList = CourseDto.Map((List <CourseModel>)session.CreateQuery(new QueryCourseByCourseType(CourseTypeModelDto.UnMap(testCourseType)).Query).List <CourseModel>()); } return(returnedList); } catch (Exception ex) { Logger.Error("Error : CourseService.GetByCourseType - {0}", ex.Message); return(new List <CourseDto>()); } }
public void Can_add_new_course() { new CourseService(); #region Arrange var newCourse = new CourseDto { CreationDate = DateTime.Now, CourseType = CourseTypeModelDto.Map(TestCourseType), Group = new GroupModelDto { GroupName = "added test", GroupType = GroupTypeModelDto.Map(TestGroupType) }, Logo = "test/jpg", Name = "test add", ShoutBox = new ShoutboxModelDto() }; #endregion #region Act int? id = new CourseService().AddCourse(newCourse); CourseDto testingAddedCourse = null; if (id.HasValue) { testingAddedCourse = new CourseService().GetById(id.Value); } #endregion #region Assert Assert.That(testingAddedCourse, Is.Not.Null); if (testingAddedCourse != null) { Assert.That(testingAddedCourse.Name, Is.EqualTo("test add")); Assert.That(testingAddedCourse.Group.GroupName, Is.EqualTo("added test")); } #endregion }
public List<CourseDto> GetByCourseType(CourseTypeModelDto testCourseType) { try { List<CourseDto> returnedList; using (var session = DataAccess.OpenSession()) { returnedList = CourseDto.Map((List<CourseModel>)session.CreateQuery(new QueryCourseByCourseType(CourseTypeModelDto.UnMap(testCourseType)).Query).List<CourseModel>()); } return returnedList; } catch (Exception ex) { Logger.Error("Error : CourseService.GetByCourseType - {0}", ex.Message); return new List<CourseDto>(); } }