public LeagueMatchPage(Match match) { match.GameEvents.CollectionChanged += async(sender, e) => { await LocalStorage.Write(match); }; var orientationHandler = DependencyService.Get <IOrientationHandler>(); orientationHandler.ForceLandscape(); MatchVM = new LeagueMatchVM(match); var swipableFrame = new SwipeableFrame { Content = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { TopStack(), BottomStack(), } } }; Content = swipableFrame; swipableFrame.SwipedLeft += async(sender, e) => { if (MatchVM.ActivePlayer == MatchVM.Player2) { MatchVM.Miss(); await Notify("Miss"); } }; swipableFrame.SwipedRight += async(sender, e) => { if (MatchVM.ActivePlayer == MatchVM.Player1) { MatchVM.Miss(); await Notify("Miss"); } }; this.Appearing += (sender, e) => { orientationHandler.PreventLock(); }; this.Disappearing += (sender, e) => { orientationHandler.AllowLock(); }; }
public MatchVM[,] GetFixture(int rounds, int matches, List <PlayerVM> players, bool odd) { var fixture = new MatchVM[rounds, matches]; fixture = SetHomeMatches(rounds, matches, players, fixture); if (odd) { fixture = SetFirstRoundMatch(rounds, matches, players, fixture); } fixture = SetAwayGames(rounds, matches, players, fixture); return(fixture); }
// GET: Match/Details/5 public ActionResult Details(int id) { var match = _matchService.GetMatch(id); var matchVM = new MatchVM() { MatchDate = match.DateOfMatch }; var matchParticipants = match.MatchParticipations; if (matchParticipants.Count != 2) { throw new Exception($"Expected (2) participants but there is/are ({matchParticipants.Count})"); } var winnerSet = matchParticipants.Where(mp => mp.Winner); if (winnerSet.Count() != 1) { throw new Exception($"Expected (1) winner (and 1 loser) but there is/are ({winnerSet.Count()})"); } var winner = winnerSet.Single(); var loser = matchParticipants.Where(mp => !mp.Winner).Single(); matchVM.WinnerName = winner.Player.FullName; matchVM.LoserName = loser.Player.FullName; matchVM.AllTimeMatchResult = new EloMatchResultVM() { CompetitionID = winner.AllTimeCompetition.CompetitionID, CompetitionName = winner.AllTimeCompetition.Name, WinnerResults = GetEloPlayerMatchResultVM(winner.AllTimeCompetitionResult), LoserResults = GetEloPlayerMatchResultVM(loser.AllTimeCompetitionResult) }; matchVM.MonthlyMatchResult = new LadderMatchResultVM() { CompetitionID = winner.MonthlyCompetition.CompetitionID, CompetitionName = winner.MonthlyCompetition.Name, WinnerResults = GetLadderResultsFromCompResults(winner.MonthlyCompetitionResult), LoserResults = GetLadderResultsFromCompResults(loser.MonthlyCompetitionResult) }; return(View(matchVM)); }
public static MatchVM MapToVM(Match match) { MatchVM matchVM = new MatchVM() { AwayGoal = match.AwayGoal, AwayPlayerId = match.AwayPlayerId, AwayTeamId = match.AwayTeamId, HomeGoal = match.HomeGoal, HomePlayerId = match.HomePlayerId, HomeTeamId = match.HomeTeamId, MatchId = match.MatchId, WorkDayId = match.WorkDayId, Played = match.Played }; return(matchVM); }
public static Match MapFromVM(MatchVM matchVM) { Match match = new Match() { AwayGoal = matchVM.AwayGoal, AwayPlayerId = matchVM.AwayPlayerId, AwayTeamId = matchVM.AwayTeamId, HomeGoal = matchVM.HomeGoal, HomePlayerId = matchVM.HomePlayerId, HomeTeamId = matchVM.HomeTeamId, MatchId = matchVM.MatchId, WorkDayId = matchVM.WorkDayId, Played = matchVM.Played }; return(match); }
public MatchVM[,] SetHomeMatches(int rounds, int matches, List <PlayerVM> players, MatchVM[,] fixture) { for (int i = 0, k = 0; i < rounds; i++) { for (int j = 0; j < matches; j++) { fixture[i, j] = new MatchVM(); fixture[i, j].HomePlayerId = players[k].PlayerId; k++; if (k == rounds) { k = 0; } } } return(fixture); }
public QuickMatchPage(Match match) { match.GameEvents.CollectionChanged += async(sender, e) => { await LocalStorage.Write(match); }; var orientationHandler = DependencyService.Get <IOrientationHandler>(); orientationHandler.ForceLandscape(); MatchVM = new QuickMatchVM(match); var swipableFrame = new SwipeableFrame { Content = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { TopStack(), BottomStack(), } } }; Content = swipableFrame; this.Appearing += (sender, e) => { orientationHandler.PreventLock(); }; this.Disappearing += (sender, e) => { orientationHandler.AllowLock(); }; }
public bool Update(MatchVM match) { return(_match.Update(match)); }
public bool Insert(MatchVM match) { return(_match.Insert(match)); }
public ActionResult Index(string id) { id = BifSessionData.IsInRole("ADMIN") ? id ?? BifSessionData.Id : BifSessionData.Id; var match = DAL.Context.Exchanges.Where(x => x.Id == BifSessionData.ExchangeId) .Select(x => new { Exchange = x, Match = x.Matches.FirstOrDefault(m => m.SenderId == id), }).Select(x => new { Exchange = x.Exchange, Match = x.Match, Profile = x.Match.Recipient.Profile, SignUpComment = x.Match.Recipient.Profile.SignUps.FirstOrDefault().Comment, Email = x.Match.Recipient.Email }).FirstOrDefault(); //var match = DAL.Context.Matches.Where(x => x.SenderId == id && x.ExchangeId == BifSessionData.ExchangeId) // .Select(x => new { // Profile = x.Recipient.Profile, // Email = x.Recipient.Email, // Match = x, // Exchange = x.Exchange // } ).FirstOrDefault(); if (match?.Exchange.MatchDate != null && match.Exchange.MatchDate > DateTime.UtcNow.AddHours(-14)) // UTC -14 on a date is 9:00AM EST { ViewBag.MessageTitle = "No Matches Yet"; ViewBag.Message = $"Matches should be ready on {match.Exchange.MatchDate?.ToLongDateString()}. Don't worry, we'll let you know when they're posted. "; return(View("Message")); } if (match.Match == null) { ViewBag.MessageTitle = "No Matches Yet"; ViewBag.Message = $"Matches should be ready around {match.Exchange?.MatchDate?.ToLongDateString()}. Don't worry, we'll let you know when they're posted. "; return(View("Message")); } string phoneNumber = match.Profile.PhoneNumber?.PadLeft(10, ' '); DateTime hideDate = match.Exchange.ShipDate?.AddDays(14) ?? match.Exchange.MatchDate?.AddDays(28) ?? match.Exchange.CreateDate.AddDays(60); MatchVM vm = new MatchVM { Name = match.Profile.FullName, Address = hideDate >= DateTime.Now ? match.Profile.Address : "", City = hideDate >= DateTime.Now ? match.Profile.City : "", State = hideDate >= DateTime.Now ? match.Profile.State : "", Zip = hideDate >= DateTime.Now ? match.Profile.Zip : "", RedditUsername = match.Profile.RedditUsername, UntappdUsername = match.Profile.UntappdUsername, References = match.Profile.References, //Wishlist = match.Profile.Wishlist, Comments = match.Profile.Comments, Piney = match.Profile.Piney, Juicy = match.Profile.Juicy, Tart = match.Profile.Tart, Funky = match.Profile.Funky, Malty = match.Profile.Malty, Roasty = match.Profile.Roasty, Sweet = match.Profile.Sweet, Smokey = match.Profile.Smokey, Spicy = match.Profile.Spicy, Crisp = match.Profile.Crisp, Phone = hideDate >= DateTime.Now ? phoneNumber == null ? null : $"{phoneNumber.Substring(0, 3)}-{phoneNumber.Substring(3, 3)}-{phoneNumber.Substring(6, 4)}" : "", Email = hideDate >= DateTime.Now ? match.Email : "", SenderId = id, Carrier = match.Match.Carrier, TrackingNo = match.Match.TrackingNo, ExchangeName = match.Exchange.Name, ShipDate = match.Match.ShipDate, CloseDate = match.Exchange.CloseDate }; return(View("Index", vm)); }
public ContentResult GetMatches(DateTime dateTime) { UnitOfWork uow = new UnitOfWork(); Dictionary <string, List <MatchVM> > ChampionshipMatches = new Dictionary <string, List <MatchVM> >(); foreach (var match in uow.MatchRepository.GetMatches(dateTime)) { var matchVm = new MatchVM() { link = match.Id.ToString(), firstTeam = match.FirstTeamName, secondTeam = match.SecondTeamName, firstTeamGoals = match.FirstTeamName.ToString(), secondTeamGoals = match.SecondTeamGoals.ToString(), date = match.MatchDateTime.ToString(Common.DateFormat), isPlayed = match.IsPlayed }; if (match.ChampionshipId == null) { if (ChampionshipMatches.ContainsKey("")) { if (ChampionshipMatches[""].Count > 0) { ChampionshipMatches[""].Add(matchVm); } else { ChampionshipMatches[""] = new List <MatchVM>() { matchVm } }; } else { ChampionshipMatches.Add("", new List <MatchVM>() { matchVm }); } } else { if (ChampionshipMatches.ContainsKey(match.Championship.ChampName)) { if (ChampionshipMatches[match.Championship.ChampName].Count > 0) { ChampionshipMatches[match.Championship.ChampName].Add(matchVm); } else { ChampionshipMatches[match.Championship.ChampName] = new List <MatchVM>() { matchVm } }; } else { ChampionshipMatches.Add(match.Championship.ChampName, new List <MatchVM>() { matchVm }); } } } var output = new List <object>(); foreach (var item in ChampionshipMatches) { List <MatchVM> matches = new List <MatchVM>(); foreach (var match in item.Value) { matches.Add(match); } output.Add(new { Name = item.Key, matches = matches }); } var result = new { AllMatches = output, }; return(ToJson(new { result })); }
public bool Update(MatchVM matchVM) { var match = Mapper.MapFromVM(matchVM); return(Repository.Update(match)); }
public bool Insert(MatchVM matchVM) { var match = Mapper.MapFromVM(matchVM); return(Repository.Insert(match)); }