コード例 #1
0
 public Result <List <StudentResultDTO> > GetStudents(StudentSearchDTO model)
 {
     try
     {
         return(studentService.GetStudents(model));
     }
     catch (Exception e)
     {
         return(new Result <List <StudentResultDTO> >(true, e.Message, null));
     }
 }
コード例 #2
0
ファイル: StudentService.cs プロジェクト: yt17/interview
        public Result <List <StudentResultDTO> > GetStudents(StudentSearchDTO filter)
        {
            IQueryable <Student> students = (IQueryable <Student>)studentDAL.GetList(null);
            var result = students.WhereIf(filter.ClassID != 0, s => s.Class_ID == filter.ClassID)
                         .WhereIf(filter.Name != null, s => s.User.Name == filter.Name)
                         .WhereIf(filter.Surname != null, s => s.User.Surname == filter.Surname)
                         .WhereIf(filter.Classname != null, s => s.Class_.Name == filter.Classname)
                         .WhereIf(filter.UserID != null, s => s.UserID == filter.UserID)
                         .Select(x => new StudentResultDTO {
                Name      = x.User.Name,
                Surname   = x.User.Surname,
                ClassID   = x.Class_ID,
                UserID    = x.UserID,
                Classname = x.Class_.Name
            }).ToList();

            return(new Result <List <StudentResultDTO> >(false, "islem basarili", result));
        }