public IList <GroupTypeModelDto> GetGroupTypes()
 {
     try
     {
         return(GroupTypeModelDto.Map(new Repository <GroupTypeModel>().GetAll().ToList()));
     }
     catch (Exception ex)
     {
         Logger.Error("Error : CourseService.GetGroupTypes - {0}", ex.Message);
         return(new List <GroupTypeModelDto>());
     }
 }
 public IList <GroupTypeModelDto> GetGroupTypeByName(string typeName)
 {
     try
     {
         List <GroupTypeModelDto> types;
         using (var session = DataAccess.OpenSession())
         {
             types = GroupTypeModelDto.Map((List <GroupTypeModel>)session.CreateQuery(new QueryGroupTypesByName(typeName).Query).List <GroupTypeModel>());
         }
         return(types);
     }
     catch (Exception ex)
     {
         Logger.Error("Error : CourseService.GetGroupTypeByName - {0}", ex.Message);
         return(new List <GroupTypeModelDto>());
     }
 }
Exemple #3
0
        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
        }