コード例 #1
0
        public SubjectResponse GetSubjectsForUser(string userId)
        {
            var response = new SubjectResponse();

            try
            {
                var user            = _userRepository.Get(new Guid(userId));
                var userPermissions = _userPermissionRepository.GetList().Where(x => x.UserId == user.Id).ToList();
                var subjects        = _subjectRepository.GetList().Where(x => userPermissions.Any(p => p.CourseId == x.CourseId && p.TypeId == x.TypeId)).ToList();
                response.Subjects = Mapper.MapSubjects(subjects);
            }
            catch (Exception e)
            {
                response.Errors = e.Message;
            }
            return(response);
        }