示例#1
0
        private IEnumerable<MyPageSettingViewModel.SportsInfoModel> GetSportsInfo()
        {
            List<MyPageSettingViewModel.SportsInfoModel> result = new List<MyPageSettingViewModel.SportsInfoModel> { };

            var Sport = (from p in com.SportsMaster
                         orderby p.SportsID
                         select p);
            if (Sport != null)
            {
                foreach (var pi in Sport)
                {
                    MyPageSettingViewModel.SportsInfoModel pfi = new MyPageSettingViewModel.SportsInfoModel();
                    pfi.SportsID = pi.SportsID;
                    pfi.SportsName = pi.SportsName;
                    pfi.Teams = new List<MyPageSettingViewModel.TeamInfoModel> { };
                    switch (pfi.SportsID)
                    {
                        case Constants.NPB_SPORT_ID:
                            // NPB
                            var nteam = (from tn in npb.TeamInfoMST
                                         where tn.LeagueID != 0
                                         orderby tn.TeamCD
                                         select tn);
                            foreach (var nt in nteam)
                            {
                                MyPageSettingViewModel.TeamInfoModel tim = new MyPageSettingViewModel.TeamInfoModel();
                                tim.SportsID = pfi.SportsID;
                                tim.TeamID = nt.TeamCD;
                                tim.TeamName = nt.Team;
                                pfi.Teams.Add(tim);
                            }
                            break;
                        case Constants.JLG_SPORT_ID:
                            // Jleague
                            var jteam = (from tj in jlg.TeamInfoGT
                                         join ct in jlg.CategoryGT
                                         on tj.CategoryGTId equals ct.CategoryGTId
                                         where
                                         (ct.GameKindID == 2 && ct.SeasonID == 2)   // J1
                                         ||
                                         (ct.GameKindID == 6)   // J2
                                         //||
                                         //(ct.GameKindID == 68)  // J3
                                         orderby ct.CategoryGTId, tj.TeamID
                                         select tj);
                            foreach (var nt in jteam)
                            {
                                MyPageSettingViewModel.TeamInfoModel tim = new MyPageSettingViewModel.TeamInfoModel();
                                tim.SportsID = pfi.SportsID;
                                tim.TeamID = nt.TeamID;
                                tim.TeamName = nt.TeamName;
                                pfi.Teams.Add(tim);
                            }
                            break;
                        case Constants.MLB_SPORT_ID:
                            // MLB
                            var mteam = (from tm in mlb.TeamInfo
                                         orderby tm.TeamID
                                         select tm);
                            foreach (var nt in mteam)
                            {
                                MyPageSettingViewModel.TeamInfoModel tim = new MyPageSettingViewModel.TeamInfoModel();
                                tim.SportsID = pfi.SportsID;
                                tim.TeamID = nt.TeamID;
                                tim.TeamName = nt.TeamName;
                                pfi.Teams.Add(tim);
                            }
                            break;
                        default:
                            break;
                    }
                    result.Add(pfi);
                }
            }

            return result;
        }
示例#2
0
        private IEnumerable<MyPageSettingViewModel.MemberSettingInfoModel> GetMemberSettingInfo(Int64 memberId)
        {
            List<MyPageSettingViewModel.MemberSettingInfoModel> result = new List<MyPageSettingViewModel.MemberSettingInfoModel> { };

            if (memberId > 0)
            {

                MyPageSettingViewModel.MemberSettingInfoModel mbi = new MyPageSettingViewModel.MemberSettingInfoModel();
                List<MyPageSettingViewModel.PrefecturesInfoModel> pfis = new List<MyPageSettingViewModel.PrefecturesInfoModel> { };

                #region メンバー情報

                var member = (from m in com.Member
                              where m.MemberId == memberId
                              select m).FirstOrDefault();
                if (member != null)
                {
                    mbi.MemberID = Convert.ToInt64(member.MemberId);
                    mbi.Nickname = member.Nickname;
                    mbi.ProfileImg = member.ProfileImg;
                    mbi.Gender = Convert.ToInt16(member.Gender); // 1:男性、2:女性、3:その他
                    if (mbi.Gender == 1) mbi.GenderCheckedMale = "checked";
                    if (mbi.Gender == 2) mbi.GenderCheckedFeMale = "checked";
                    mbi.BirthdayYear = (short)Convert.ToInt16(member.BirthdayYear);
                    mbi.BirthdayMonth = (short)Convert.ToInt16(member.BirthdayMonth);
                    mbi.BirthdayDay = (short)Convert.ToInt16(member.BirthdayDay);
                    mbi.PrefecturesID = (short)Convert.ToInt16(member.PrefecturesId);
                    mbi.Mail = member.Mail;

                }
                #endregion

                #region 好きなスポーツ
                mbi.LikeSportsID = new List<int>();

                var sports = (from s in com.LikeSports
                              join sm in com.SportsMaster
                              on s.SportsID equals sm.SportsID
                              where s.MemberID == member.MemberId
                              select sm);
                foreach (var sp in sports)
                {
                    mbi.LikeSportsID.Add(sp.SportsID);
                }
                #endregion

                #region 好きなチーム
                mbi.LikeTeam = new List<MyPageSettingViewModel.TeamInfoModel> { };
                var teams = (from t in com.LikeTeam
                             where t.MemberID == member.MemberId
                             select t);
                foreach (var tid in teams)
                {
                    MyPageSettingViewModel.TeamInfoModel ti = new MyPageSettingViewModel.TeamInfoModel();
                    ti.SportsID = tid.SportsID;
                    ti.TeamID = tid.TeamID;
                    ti.TeamName = GetTeamName(ti.SportsID, ti.TeamID);
                    mbi.LikeTeam.Add(ti);
                }
                #endregion

                result.Add(mbi);
            }

            return result;
        }