public virtual MvcMailMessage EmailDailyWinner(string email, RankingInfoModel model, int spieltag) { ViewBag.Spieltag = spieltag; ViewData.Model = model; return(Populate(x => { x.Subject = "BuLi-Tagessieger Spieltag " + spieltag.ToString(); x.ViewName = "EmailDailyWinner"; x.To.Add(email); })); }
public ActionResult DailyReport(DateTime?Spieltag) { log.Debug("DailyReport begin"); var kickoff = Spieltag; // extract spieltage if (kickoff == null) { var match = _matchDataRepository.GetLastMatch(); if (match.MatchId == -1) { match = _matchDataRepository.GetNextMatch(); } kickoff = match.KickoffTimeUTC; } var matchFilter = (from m in _matchDataRepository.GetAllMatches() where m.KickoffTimeUTC.ToShortDateString() == kickoff.Value.ToShortDateString() && m.HasStarted == true select m); // build dropdown list data { var distinctByKickoff = (from m in _matchDataRepository.GetAllMatches() orderby m.KickoffTime select new { KickoffDate = m.KickoffTime.ToShortDateString(), KickoffDateUTC = m.KickoffTimeUTC.ToShortDateString() }) .DistinctBy(a => a.KickoffDateUTC); var ddlSpieltageRange = (from m in distinctByKickoff select new SelectListItem() { Value = m.KickoffDateUTC, Text = m.KickoffDate, Selected = (m.KickoffDateUTC == kickoff.Value.ToShortDateString()) }) .Distinct(); ViewBag.Spieltag = ddlSpieltageRange; } var viewModel = new DailyWinnerInfoModel(); { viewModel.MatchInfo = matchFilter.ToList(); } using (var ctxt = new TippSpielContext()) { var resultDict = new Dictionary <string, RankingInfoModel>(); using (var userCtxt = new UsersContext()) { // init result dict { foreach (var username in (from t in ctxt.TippMatchList select t.User).Distinct()) { var m = new RankingInfoModel(); m.User = username; m.DisplayName = (from u in userCtxt.UserProfiles where u.UserName == username select u.DisplayName) .FirstOrDefault(); resultDict.Add(username, m); viewModel.AllTippInfoDict.Add(username, new List <MatchInfoModel>()); } } } // 1. get all tipps for match with id foreach (var m in matchFilter) { var tippSet = (from t in ctxt.TippMatchList where t.MatchId == m.MatchId && t.MyTip.HasValue && t.MyAmount.HasValue && t.MyOdds.HasValue select t); foreach (var tip in tippSet) { var matchModelObj = new MatchInfoModel() { MatchId = m.MatchId, GroupId = m.GroupId, MatchNr = m.MatchNr, AwayTeam = m.AwayTeam, AwayTeamIcon = m.AwayTeamIcon, AwayTeamScore = m.AwayTeamScore, HomeTeam = m.HomeTeam, HomeTeamIcon = m.HomeTeamIcon, HomeTeamScore = m.HomeTeamScore, IsFinished = m.IsFinished, KickoffTime = m.KickoffTime }; matchModelObj.MyOdds = tip.MyOdds; matchModelObj.IsJoker = tip.IsJoker; if (tip.IsJoker == true) { matchModelObj.MyAmount = tip.MyAmount * TippspielConfigInfo.Current.JokerMultiplicator; } else { matchModelObj.MyAmount = tip.MyAmount; } matchModelObj.MyTip = tip.MyTip; if (matchModelObj.HasStarted == true) { resultDict[tip.User].TippCount++; resultDict[tip.User].TotalPoints += matchModelObj.MyPoints ?? 0.0; } if (matchModelObj.HasStarted == true) { viewModel.AllTippInfoDict[tip.User].Add(matchModelObj); } } } var resultList = (from kp in resultDict select kp.Value).ToList(); viewModel.Ranking = (from e in resultList orderby e.TotalPoints descending, e.PointAvg, e.TippCount descending select e) .ToList(); int counter = 1; viewModel.Ranking.ForEach(e => { e.Rang = counter++; }); } log.Debug("DailyReport end"); return(View(viewModel)); }
public ActionResult OverallStanding() { _matchDataRepository.GetCurrentGroup(); var groupModel = _matchDataRepository.GetCurrentGroup(); var maxSpieltag = groupModel.Id; using (var ctxt = new TippSpielContext()) { var resultDict = new Dictionary <string, RankingInfoModel>(); using (var userCtxt = new UsersContext()) { // init dict { foreach (var username in (from t in ctxt.TippMatchList select t.User).Distinct()) { var m = new RankingInfoModel(); m.User = username; m.DisplayName = (from u in userCtxt.UserProfiles where u.UserName == username select u.DisplayName) .FirstOrDefault(); resultDict.Add(username, m); } } } foreach (var tip in ctxt.TippMatchList.Where(t => t.MyTip.HasValue)) { var rankingObj = resultDict[tip.User]; var matchInfo = _matchDataRepository.GetMatchData(tip.MatchId); if (matchInfo.LeagueShortcut == SportsdataConfigInfo.Current.LeagueShortcut && tip.MyOdds.HasValue && tip.MyAmount.HasValue) { var matchModelObj = new MatchInfoModel() { MatchId = matchInfo.MatchId, MatchNr = matchInfo.MatchNr, AwayTeam = matchInfo.AwayTeam, AwayTeamIcon = matchInfo.AwayTeamIcon, AwayTeamScore = matchInfo.AwayTeamScore, HomeTeam = matchInfo.HomeTeam, HomeTeamIcon = matchInfo.HomeTeamIcon, HomeTeamScore = matchInfo.HomeTeamScore, IsFinished = matchInfo.IsFinished, KickoffTime = matchInfo.KickoffTime, GroupId = tip.GroupId, MyOdds = tip.MyOdds, MyAmount = tip.MyAmount, MyTip = tip.MyTip, IsJoker = tip.IsJoker, }; if (tip.IsJoker == true) { matchModelObj.MyAmount = tip.MyAmount * TippspielConfigInfo.Current.JokerMultiplicator; } else { matchModelObj.MyAmount = tip.MyAmount; } if (matchModelObj.HasStarted == true) { rankingObj.TippCount++; rankingObj.TotalPoints += matchModelObj.MyPoints ?? 0.0; rankingObj.TotalPointsClean += matchModelObj.MyPointsClean ?? 0.0; if (tip.IsJoker) { rankingObj.JokerUsed++; } } } } var resultList = (from kp in resultDict select kp.Value).ToList(); resultList = (from e in resultList orderby e.TotalPoints descending, e.PointAvg, e.TippCount descending select e) .ToList(); int counter = 1; resultList.ForEach(e => { e.Rang = counter++; }); return(View(resultList)); } }
private DailyWinnerInfoModel DailyWinnersInternal(int currSpieltag) { _log.Debug("Current spieltag=" + currSpieltag.ToString()); var viewModel = new DailyWinnerInfoModel(); using (var client = new SvcFussballDB.SportsdataSoapClient()) { var matchesDB = client.GetMatchdataByGroupLeagueSaison(currSpieltag, SportsdataConfigInfo.Current.LeagueShortcut, SportsdataConfigInfo.Current.LeagueSaison); foreach (var m in matchesDB) { viewModel.MatchInfo.Add(OpenDBHelper.Create(m)); } using (var ctxt = new TippSpielContext()) { var resultDict = new Dictionary <string, RankingInfoModel>(); using (var userCtxt = new UsersContext()) { // init result dict { foreach (var username in (from t in ctxt.TippMatchList select t.User).Distinct()) { var m = new RankingInfoModel(); m.User = username; m.DisplayName = (from u in userCtxt.UserProfiles where u.UserName == username select u.DisplayName) .FirstOrDefault(); resultDict.Add(username, m); viewModel.AllTippInfoDict.Add(username, new List <MatchInfoModel>()); } } } // 1. get all tipps for match with id foreach (var match in matchesDB) { var tippSet = (from t in ctxt.TippMatchList where t.MatchId == match.matchID && t.MyTip.HasValue && t.MyAmount.HasValue && t.MyOdds.HasValue select t); foreach (var tip in tippSet) { var matchModelObj = OpenDBHelper.Create(match); matchModelObj.MyOdds = tip.MyOdds; matchModelObj.MyAmount = tip.MyAmount; matchModelObj.MyTip = tip.MyTip; if (matchModelObj.HasStarted == true) { resultDict[tip.User].TippCount++; resultDict[tip.User].TotalPoints += (matchModelObj.MyPoints.HasValue) ? matchModelObj.MyPoints.Value : 0.0; } if (matchModelObj.HasStarted == true) { viewModel.AllTippInfoDict[tip.User].Add(matchModelObj); } } } var resultList = (from kp in resultDict select kp.Value).ToList(); viewModel.Ranking = (from e in resultList orderby e.TotalPoints descending, e.PointAvg, e.TippCount descending select e) .ToList(); int counter = 1; viewModel.Ranking.ForEach(e => { e.Rang = counter++; }); return(viewModel); } } }
public ActionResult OverallStanding() { using (var client = new SvcFussballDB.SportsdataSoapClient()) { int maxSpieltag = OpenDBHelper.GetSpieltagInfo(_matchDataRepository).CurrentSpieltag; using (var ctxt = new TippSpielContext()) { var resultDict = new Dictionary <string, RankingInfoModel>(); using (var userCtxt = new UsersContext()) { // init dict { foreach (var username in (from t in ctxt.TippMatchList select t.User).Distinct()) { var m = new RankingInfoModel(); m.User = username; m.DisplayName = (from u in userCtxt.UserProfiles where u.UserName == username select u.DisplayName) .FirstOrDefault(); resultDict.Add(username, m); } } } foreach (var tip in ctxt.TippMatchList.Where(t => t.MyTip.HasValue)) { var rankingObj = resultDict[tip.User]; var matchInfo = _matchDataRepository.GetMatchData(tip.MatchId); var matchModelObj = new MatchInfoModel() { MatchId = matchInfo.MatchId, AwayTeam = matchInfo.AwayTeam, AwayTeamIcon = matchInfo.AwayTeamIcon, AwayTeamScore = matchInfo.AwayTeamScore, HomeTeam = matchInfo.HomeTeam, HomeTeamIcon = matchInfo.HomeTeamIcon, HomeTeamScore = matchInfo.HomeTeamScore, IsFinished = matchInfo.IsFinished, KickoffTime = matchInfo.KickoffTime, MyOdds = tip.MyOdds, MyAmount = tip.MyAmount, MyTip = tip.MyTip }; if (tip.MyOdds.HasValue && tip.MyAmount.HasValue) { matchModelObj.MyOdds = tip.MyOdds; matchModelObj.MyAmount = tip.MyAmount; matchModelObj.MyTip = tip.MyTip; if (matchModelObj.HasStarted == true) { rankingObj.TippCount++; rankingObj.TotalPoints += (matchModelObj.MyPoints.HasValue) ? matchModelObj.MyPoints.Value : 0.0; } // count longshot and favorite { rankingObj.TippCountFavorite += (matchModelObj.FavoriteTippIndex == tip.MyTip.Value) ? 1 : 0; rankingObj.TippCountLongshot += (matchModelObj.LongshotTippIndex == tip.MyTip.Value) ? 1 : 0; } } } var resultList = (from kp in resultDict select kp.Value).ToList(); resultList = (from e in resultList orderby e.TotalPoints descending, e.PointAvg, e.TippCount descending select e) .ToList(); int counter = 1; resultList.ForEach(e => { e.Rang = counter++; }); return(View(resultList)); } } }