/// <summary>
        /// 取得APP的GetAllMyCourse的資訊
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public IEnumerable <Infrastructure.ViewModel.CourseManage.GetAllMyCourseResponse> APPGetAllMyCourse(string token)
        {
            var memberService = new MemberService();
            var checkToken    = memberService.TokenToMember(token).Result;

            if (checkToken == null)
            {
                return(null);
            }

            var sectionService = new SectionService();
            var sectionData    = sectionService.GetOrgNowSeme(checkToken.OrgId);


            var learningCircleList = GetLearningCircleListByToken(token, null, null);

            if (learningCircleList == null || learningCircleList.Count() <= 0)
            {
                return(new List <Infrastructure.ViewModel.CourseManage.GetAllMyCourseResponse>());
            }
            var response    = new List <Infrastructure.ViewModel.CourseManage.GetAllMyCourseResponse>();
            var sectionYear = learningCircleList.Where(t => t.StartDate.HasValue).GroupBy(t => t.StartDate.Value.Year);

            //上過多少學年度
            foreach (var year in sectionYear)
            {
                var data       = new Infrastructure.ViewModel.CourseManage.GetAllMyCourseResponse();
                var courseData = new List <Infrastructure.ViewModel.CourseManage.DataCourseDataModel>();
                data.Year     = year.Key;
                data.YearSeme = year.Key.ToString();
                if (year.Key == sectionData.Year)
                {
                    data.IsNowSeme = true;
                }
                //查詢課程
                foreach (var learningcircle in learningCircleList.Where(t => t.StartDate.HasValue && ((t.StartDate >= sectionData.StartDate && t.StartDate <= sectionData.EndDate) || (t.EndDate >= sectionData.StartDate && t.EndDate <= sectionData.EndDate))))
                {
                    var learningCircleData = new Infrastructure.ViewModel.CourseManage.DataCourseDataModel();

                    learningCircleData.ClassId          = learningcircle.LearningOuterKey.ToLower();
                    learningCircleData.ClassName        = learningcircle.Name;
                    learningCircleData.ClassSubjectName = learningcircle.Name;
                    //查詢課程老師們
                    var teachers        = memberService.GetTeacherList(learningcircle.LearningOuterKey);
                    var teacherListData = new List <Infrastructure.ViewModel.MemberManage.TeacherPhotoInfo>();
                    var teacherNames    = string.Empty;
                    //設定上課老師們資料
                    foreach (var teacher in teachers)
                    {
                        var teacherData = new Infrastructure.ViewModel.MemberManage.TeacherPhotoInfo();
                        teacherData.Email   = teacher.Email;
                        teacherData.ManName = teacher.Name;
                        teacherData.Url     = teacher.Photo;
                        teacherListData.Add(teacherData);
                        teacherNames += teacher.Name + ",";
                    }
                    teacherNames = teacherNames != string.Empty ? teacherNames.Substring(0, teacherNames.Length - 1) : teacherNames;
                    learningCircleData.TeacherPhoto = teacherListData.ToArray();
                    learningCircleData.ClassTeacher = teacherNames;
                    learningCircleData.StartDate    = learningcircle.StartDate.HasValue ? learningcircle.StartDate.Value.ToLocalTime() : DateTime.MinValue;
                    learningCircleData.EndDate      = learningcircle.EndDate.HasValue ? learningcircle.EndDate.Value.ToLocalTime() : DateTime.MinValue;
                    var memberCount = memberService.GetLearningCircleMembers(learningcircle.LearningOuterKey).Count();
                    learningCircleData.MemberCount = memberCount;
                    var weekTableService = new WeekTableService();
                    var weekDatas        = weekTableService.GetAllMyCourseWeekTableData(learningcircle.Id);
                    if (weekDatas != null)
                    {
                        learningCircleData.WeekTable = weekDatas.ToList();
                    }
                    courseData.Add(learningCircleData);
                }
                data.Course = courseData.ToArray();
                response.Add(data);
            }
            return(response);
        }
        /// <summary>
        /// 取得APP的GetCourseDetail的資訊
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public Infrastructure.ViewModel.CourseManage.GetCourseDetailResponse APPGetCourseDetail(string token, string circleKey)
        {
            var response      = new Infrastructure.ViewModel.CourseManage.GetCourseDetailResponse();
            var memberService = new MemberService();
            var tokenService  = new TokenService();
            var checkToken    = tokenService.GetTokenInfo(token);

            if (checkToken == null)
            {
                return(response);
            }

            var members = memberService.GetLearningCircleMembers(circleKey);

            if (members == null)
            {
                return(response);
            }

            response.MemberCount    = members.Count();
            response.Edit           = false;
            response.EditImpression = false;
            response.CollInfo       = null;

            var learningCircleInfo = GetDetailByOuterKey(circleKey);

            if (learningCircleInfo == null)
            {
                return(response);
            }

            //處理老師名單
            var teachers = memberService.GetTeacherList(circleKey);

            if (teachers.FirstOrDefault() != null)
            {
                var teachersName = teachers.Select(t => t.Name).ToList();
                foreach (var teacher in teachersName)
                {
                    response.ClassTeachers += teacher + "、";
                }
                response.ClassTeachers = response.ClassTeachers.Substring(0, response.ClassTeachers.Length - 1);
            }
            if (learningCircleInfo.StartDate.HasValue && learningCircleInfo.EndDate.HasValue)
            {
                response.ClassPeriod = string.Format("{0} ~ {1}", learningCircleInfo.StartDate.Value.ToLocalTime().ToString("yyyy/MM/dd"), learningCircleInfo.EndDate.Value.ToLocalTime().ToString("yyyy/MM/dd"));
                response.StartDate   = learningCircleInfo.StartDate.Value.ToLocalTime();
                response.EndDate     = learningCircleInfo.EndDate.Value.ToLocalTime();
            }

            var weekTableService    = new WeekTableService();
            var ClassWeekTableDatas = weekTableService.GetByCirclekey(circleKey);

            response.WeekTable = new List <Infrastructure.ViewModel.CourseManage.GetAllMyCourseWeekTable>();
            if (ClassWeekTableDatas.WeekTable.FirstOrDefault() != null)
            {
                foreach (var weekTableData in ClassWeekTableDatas.WeekTable)
                {
                    var data = new Infrastructure.ViewModel.CourseManage.GetAllMyCourseWeekTable()
                    {
                        Week        = weekTableData.Week,
                        Place       = weekTableData.Place,
                        StartPeriod = weekTableData.StartPeriod.Value,
                        EndPeriod   = weekTableData.EndPeriod.Value,
                        StartTime   = string.Format("{0:HH}:{0:mm}", weekTableData.StartTime.ToLocalTime()),
                        EndTime     = string.Format("{0:HH}:{0:mm}", weekTableData.EndTime.ToLocalTime())
                    };
                    response.WeekTable.Add(data);
                }
            }

            response.ClassSubjectName = learningCircleInfo.Name;
            response.ClassId          = learningCircleInfo.LearningOuterKey;
            response.Introduction     = learningCircleInfo.Description;
            response.ClassName        = learningCircleInfo.Name;
            response.ClassDomainId    = null;
            response.ClassDomainName  = null;
            response.Note             = learningCircleInfo.ReMark;
            response.ClassTarget      = learningCircleInfo.Objective;
            return(response);
        }