public JsonResult ChangeYearMonth(long memberId, string yearmonth) { UserTopViewModel userTop = new UserTopViewModel(); int iyear = Convert.ToInt16(yearmonth.Split('-')[0]); int imonth = Convert.ToInt16(yearmonth.Split('-')[1]); userTop.ReportInfo = GetMonthlyResults(memberId, iyear, imonth); return Json(userTop.ReportInfo, JsonRequestBehavior.AllowGet); }
// // GET: /User/UserTop/ public ActionResult Index(long memberId) { UserTopViewModel userTop = new UserTopViewModel(); Member member = Utils.GetMember(memberId); userTop.MemberId = memberId; userTop.Nickname = member.Nickname; ViewBag.OtherMemberID = memberId; ViewBag.OtherMemberNickName = member.Nickname; userTop.MemberInfo = GetMemberInfo(memberId); //予想情報を取得する DateTime today = DateTime.Today; int thisYear = today.Year;// 今年 int thisMonth = today.Month; GetReportInfo(memberId, userTop, thisYear, thisMonth); return View(userTop); }
private string GetTeamName(ref UserTopViewModel.TeamInfo orgti) { UserTopViewModel.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; }
/// <summary> /// /// </summary> /// <param name="viewModel"></param> /// <param name="targetYear"></param> /// <param name="targetmonth"></param> private void GetReportInfo(Int64 memberId, UserTopViewModel viewModel, int targetYear, int targetmonth) { 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.TotalPoints = totalPoints; viewModel.TotalRank = (int)totalRank; #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<UserTopViewModel.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); }