コード例 #1
0
        public GetTermByUserResponse GetTermByUser(GetTermByUserRequest request)
        {
            GetTermByUserResponse response = new GetTermByUserResponse();
            var termList = new List <TermDto>();

            if (request.RoleName.Equals("student"))
            {
                termList = _context.Schedules.Where(s => s.Student.StudentId == request.UserId)
                           .Select(s => new { s.Term.TermId, s.Term.TermName })
                           .GroupBy(g => g.TermId)
                           .Select(s => new TermDto()
                {
                    TermId   = s.FirstOrDefault().TermId,
                    TermName = s.FirstOrDefault().TermName
                }).ToList();
            }
            else if (request.RoleName.Equals("teacher"))
            {
                termList = _context.Schedules.Where(s => s.Teacher.TeacherId == request.UserId)
                           .Select(s => new { s.Term.TermId, s.Term.TermName })
                           .GroupBy(g => g.TermId)
                           .Select(s => new TermDto()
                {
                    TermId   = s.FirstOrDefault().TermId,
                    TermName = s.FirstOrDefault().TermName
                }).ToList();
            }
            response.Terms = termList;

            return(response);
        }
コード例 #2
0
        public GetTermByUserResponse GetTermByUser(GetTermByUserRequest request)
        {
            var response = _businessLogic.GetTermByUser(request);

            return(response);
        }