Exemple #1
0
 public IList <CourseDto> GetAll()
 {
     try
     {
         return(CourseDto.Map(new Repository <CourseModel>().GetAll().ToList()));
     }
     catch (Exception ex)
     {
         Logger.Error("Error : CourseService.GetAll - {0}", ex.Message);
         return(new List <CourseDto>());
     }
 }
Exemple #2
0
 public List <CourseDto> GetByProfileId(int profileId)
 {
     try
     {
         using (var session = DataAccess.OpenSession())
         {
             var courses = session.CreateCriteria(typeof(CourseModel)).List <CourseModel>().Where(c => c.Group.Users.Any(p => p.ID == profileId)).ToList();
             return(CourseDto.Map(courses));
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Error : CourseService.GetByProfileId - {0}", ex.Message);
         return(new List <CourseDto>());
     }
 }
Exemple #3
0
 public List <CourseDto> GetByName(string value)
 {
     try
     {
         List <CourseDto> returnedList;
         using (var session = DataAccess.OpenSession())
         {
             returnedList = CourseDto.Map((List <CourseModel>)session.CreateQuery(new QueryCourseByName(value).Query).List <CourseModel>());
         }
         return(returnedList);
     }
     catch (Exception ex)
     {
         Logger.Error("Error : CourseService.GetByName - {0}", ex.Message);
         return(new List <CourseDto>());
     }
 }
Exemple #4
0
 public CourseDto GetById(int id)
 {
     try
     {
         CourseDto course;
         using (var session = DataAccess.OpenSession())
         {
             course = CourseDto.Map(session.Get <CourseModel>(id));
         }
         return(course);
     }
     catch (Exception ex)
     {
         Logger.Error("Error : CourseService.GetById - {0}", ex.Message);
         return(null);
     }
 }