Пример #1
0
        public JsonResult ChangeYearMonth(string yearmonth)
        {
            MyPageTopViewModel myPageTop = new MyPageTopViewModel();
            Int64 memberID = GetMemberID();
            int iyear = Convert.ToInt16(yearmonth.Split('-')[0]);
            int imonth = Convert.ToInt16(yearmonth.Split('-')[1]);
            myPageTop.ReportInfo = GetMonthlyResults(memberID, iyear, imonth);

            return Json(myPageTop.ReportInfo, JsonRequestBehavior.AllowGet);
        }
Пример #2
0
        /// <summary>
        /// GET: /mypage/ 
        /// </summary>
        public ActionResult Index()
        {
            //Todo:認証処理 AOPでやりたい。 一旦Session変数を参照し判定
            if (Session["CurrentUser"] == null)
            {
                return RedirectToActionPermanent("Login", "Member", new { area = "" });
            }

            MyPageTopViewModel viewModel = new MyPageTopViewModel();

            //予想情報を取得する
            var today = DateTime.Today;
            int thisYear = today.Year;// 今年
            int thisMonth = today.Month;

            GetReportInfo(viewModel, thisYear, thisMonth);

            return View(viewModel);
        }
Пример #3
0
 private string GetTeamName(ref MyPageTopViewModel.TeamInfo orgti)
 {
     MyPageTopViewModel.TeamInfo ti = orgti;
     string result = null;
     switch (ti.SportsID)
     {
         case Constants.NPB_SPORT_ID:
             // NPB
             var nteam = (from tn in npb.TeamInfoMST
                          where tn.TeamCD == ti.TeamID
                          select tn).FirstOrDefault();
             if (nteam != null)
             {
                 ti.Url = "/npb/teams/" + ti.TeamID + "";
                 result = nteam.Team;
             }
             break;
         case Constants.JLG_SPORT_ID:
             // Jleague
             var jteam = (from tj in jlg.TeamInfoTE
                          where tj.TeamID == ti.TeamID
                          select tj).FirstOrDefault();
             if (jteam != null)
             {
                 ti.Url = "/jleague/j1/teams/" + ti.TeamID + "";
                 result = jteam.TeamName;
             }
             break;
         case Constants.MLB_SPORT_ID:
             // MLB
             var mteam = (from tm in mlb.TeamInfo
                          where tm.TeamID == ti.TeamID
                          select tm).FirstOrDefault();
             if (mteam != null)
             {
                 ti.Url = "/mlb/teams/" + ti.TeamID + "";
                 result = mteam.TeamName;
             }
             break;
         default:
             break;
     }
     orgti = ti;
     return result;
 }
Пример #4
0
        private void GetReportInfo(MyPageTopViewModel viewModel, int targetYear, int targetmonth)
        {
            Int64 memberId = GetMemberID();

            viewModel.MemberInfo = GetMemberInfo(memberId);

            DateTime today = DateTime.Today;
            int thisYear = today.Year;// 今年
            int thisMonth = today.Month;

            int totalPoints = 0;
            long monthlyRank = 0;
            long totalRank = 0;
            viewModel.PointInfo = GetPointInfo(memberId, thisYear, thisMonth, out totalRank, out totalPoints, out monthlyRank);
            viewModel.TotalRank = (int)totalRank;
            viewModel.TotalPoints = (int)totalPoints;

            #region 年月用変数の設定
            //ユーザー登録年から現在の年まで
            //データの存在チェックを行う

            DateTime? registTime = (from m in com.Member where m.MemberId == memberId select m.RegistTime).FirstOrDefault();
            int registYear = registTime.Value.Year;// 登録年

            viewModel.RegistratedYear = registYear;
            viewModel.ThisYear = thisYear.ToString();

            List<MyPageTopViewModel.ReportInfoModel> allYearMonth = GetAllYearMonthHasResults(memberId);

            int duration = thisYear - registYear;
            viewModel.YearStatuses = new int[duration + 1];

            for (int y = 0; y <= duration; y++)
            {
                int year = y + registYear;
                viewModel.YearStatuses[y] = 0; //データなし(初期値)

                if (year == targetYear) // target year
                {
                    viewModel.YearStatuses[y] = 1; //アクティブ

                    for (int m = 1; m <= 12; m++)
                    {
                        int month = m;
                        viewModel.MonthStatuses[m - 1] = 0; //データなし(初期値)

                        if (month == targetmonth)
                        {
                            viewModel.MonthStatuses[m - 1] = 1; // アクティブ月のとき'class="active"'、そうでないとき''
                        }
                        else
                        {
                            //データが存在するか確認
                            var d = (from a in allYearMonth where a.Year == (year) && a.Month == month select a);
                            if (d.Count() > 0)
                                viewModel.MonthStatuses[m - 1] = 2; //データ有
                        }
                    }
                }
                else
                {
                    //データが存在するか確認
                    var d = (from a in allYearMonth where a.Year == (year) select a);
                    if (d.Count() > 0)
                        viewModel.YearStatuses[y] = 2; //データ有

                }
            }
            #endregion

            //対象年月のデータを取得
            viewModel.ReportInfo = GetMonthlyResults(memberId, targetYear, targetmonth);
        }