Ejemplo n.º 1
0
        /// <summary>
        /// ポイント情報の取得
        /// </summary>
        private UserTopViewModel.PointInfoModel GetPointInfo(Int64 memberId, int target_year, int target_month, out long targetRanking, out int targetPossesionPoint, out long monthlyRank)
        {
            UserTopViewModel.PointInfoModel pim = new UserTopViewModel.PointInfoModel();

            PointInfoService pointInfoService = new PointInfoService(com);

            targetRanking = 0;
            targetPossesionPoint = 0;
            monthlyRank = 0;

            if (memberId > 0)
            {
                var m = pointInfoService.GetMemberWithOnlinePoints(memberId, target_year, target_month);

                pim = new UserTopViewModel.PointInfoModel
                      {
                          PossesionPoint = m.PossesionPoint,
                          FundsPoint = m.FundsPoint,
                          PayOffPoints = m.PayOffPoints
                      };

                //所持ポイントランキングから総合ランキングと懸賞応募可能ポイントを取得する
                var targetDate = DateTime.Now.Date.AddDays(-1);
                var possesionPointRanking = (from ppr in com.PossesionPointRanking
                               where ppr.MemberID == memberId && ppr.TargetDate == targetDate
                               select ppr).FirstOrDefault();

                if (possesionPointRanking != null)
                {
                    targetRanking = possesionPointRanking.TargetRanking;
                    targetPossesionPoint = possesionPointRanking.TargetPossesionPoint;
                }

            }

            return pim;
        }
Ejemplo n.º 2
0
        private IEnumerable<UserTopViewModel.MemberInfoModel> GetMemberInfo(Int64 memberId)
        {
            List<UserTopViewModel.MemberInfoModel> result = new List<UserTopViewModel.MemberInfoModel> { };

            if (memberId > 0)
            {

                UserTopViewModel.MemberInfoModel mbi = new UserTopViewModel.MemberInfoModel();
                UserTopViewModel.PointInfoModel pim = new UserTopViewModel.PointInfoModel();

                #region メンバー情報

                mbi.MemberId = 0;
                mbi.Nickname = "";
                mbi.ProfileImg = "";
                mbi.Gender = "その他";
                mbi.BirthdayYear = 0;
                mbi.BirthdayMonth = 0;
                mbi.BirthdayDay = 0;
                mbi.PrefecturesName = "";
                mbi.LikeSports = "";

                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;
                    switch (Convert.ToInt16(member.Gender)) // 1:男性、2:女性、3:その他
                    {
                        case 1: mbi.Gender = "男性"; break;
                        case 2: mbi.Gender = "女性"; break;
                        default: break;
                    }
                    mbi.BirthdayYear = Convert.ToInt32(member.BirthdayYear);
                    mbi.BirthdayMonth = Convert.ToInt32(member.BirthdayMonth);
                    mbi.BirthdayDay = Convert.ToInt32(member.BirthdayDay);

                    // 出身県
                    var prefecture = (from p in com.PrefectureMaster
                                      where p.PrefecturesID == member.PrefecturesId
                                      select p).FirstOrDefault();
                    if (prefecture != null)
                    {
                        mbi.PrefecturesName = prefecture.PrefecturesName;
                    }

                    // 好きなスポーツ
                    var sports = (from s in com.LikeSports
                                  join sm in com.SportsMaster
                                  on s.SportsID equals sm.SportsID
                                  where s.MemberID == member.MemberId
                                  orderby s.CreatedDate
                                  select sm);
                    foreach (var sp in sports)
                    {
                        mbi.LikeSports += sp.SportsName + " ";
                    }

                    // 好きなチーム
                    List<UserTopViewModel.TeamInfo> team_info = new List<UserTopViewModel.TeamInfo> { };
                    UserTopViewModel.TeamInfo ti;
                    var teams = (from t in com.LikeTeam
                                 where t.MemberID == member.MemberId
                                 orderby t.CreatedDate
                                 select t);
                    foreach (var tid in teams)
                    {
                        ti.TeamID = tid.TeamID;
                        ti.SportsID = tid.SportsID;
                        ti.TeamName = "";
                        ti.Url = "";
                        ti.TeamName = GetTeamName(ref ti);
                        team_info.Add(ti);
                    }
                    mbi.Team = team_info;

                }
                #endregion

                #region 予想数
                var seasontotal = (from s in com.SeasonTotalResults
                                   where
                                      s.MemberID == memberId
                                   // &&
                                   // s.StartYear == year   // 年度は見ない
                                   group s by s.MemberID into g
                                   select new
                                   {
                                       ExpectNumber = g.Sum(s => s.ExpectNumber)
                                   }
                                   ).FirstOrDefault();
                if (seasontotal != null)
                {
                    mbi.ExpectNumber = Convert.ToInt32(seasontotal.ExpectNumber);
                }
                else
                {
                    mbi.ExpectNumber = 0;
                }
                #endregion

                //フォロー数
                int followingCount = (from f in com.FollowList
                                      join m in com.Member on f.MemberID equals m.MemberId
                                      where f.FollowerMemberID == memberId
                                      && m.Status == 1
                                      select f).Count();
                mbi.FollowingNumber = followingCount;

                //フォロワー数
                int followerCount = (from f in com.FollowList
                                     join m in com.Member on f.FollowerMemberID equals m.MemberId
                                     where f.MemberID == memberId
                                     && m.Status == 1
                                     select f).Count();

                mbi.FollowerNumber = followerCount;

                result.Add(mbi);
            }

            return result;
        }