Пример #1
0
        public MatchAppearance(Player player, Team teamOfPlayer, MatchDetails match, Lineup.LineupRole role, double?ratingStars = null)
        {
            if (player == null || teamOfPlayer == null || match == null)
            {
                throw new ArgumentNullException("player, team or match");
            }

            Player       = player;
            TeamOfPlayer = teamOfPlayer;
            Match        = match;
            Role         = role;
            RatingStars  = ratingStars;
            Goals        = new List <Goal>();
        }
        // GET: Details/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MatchDetails matchDetails = db.MatchDetails.Find(id);

            if (matchDetails == null)
            {
                return(HttpNotFound());
            }
            return(View(matchDetails));
        }
Пример #3
0
            public static MatchDetails FromBytes(byte[] buffer)
            {
                MatchDetails retVal = new MatchDetails();

                Debug.Log("Received stuff");
                using (MemoryStream ms = new MemoryStream(buffer))
                {
                    BinaryReader br       = new BinaryReader(ms);
                    string       jsonData = br.ReadString();
                    Debug.Log(jsonData);
                }

                return(retVal);
            }
Пример #4
0
        private async Task <Player> GetOrCreatePlayer(MatchDetails matchDetails)
        {
            var player = await _statsDbContext.Players.FirstOrDefaultAsync(x => x.SteamId == matchDetails.SteamId);

            if (player == null)
            {
                player = new Player {
                    Name = matchDetails.PlayerName, SteamId = matchDetails.SteamId
                };
                await GetPlayerSteamData(player);
            }

            return(player);
        }
 private static void deserializePlayers(JObject matchResultJson, MatchDetails matchDetails)
 {
     foreach (var playerJson in matchResultJson?["data"]?["allPlayers"])
     {
         Player player = new Player();
         player.uno         = playerJson?["player"]?["uno"]?.ToString();
         player.username    = playerJson?["player"]?["username"]?.ToString();
         player.clantag     = playerJson?["player"]?["clantag"]?.ToString();
         player.kills       = (int)playerJson?["playerStats"]?["kills"];
         player.death       = (int)playerJson?["playerStats"]?["deaths"];
         player.damageDone  = (int)playerJson?["playerStats"]?["damageDone"];
         player.damageTaken = (int)playerJson?["playerStats"]?["damageTaken"];
         matchDetails.players.Add(player);
     }
 }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MatchDetails matchDetails = db.MatchDetails.Find(id);

            if (matchDetails == null)
            {
                return(HttpNotFound());
            }
            // ViewBag.MatchId = new SelectList(db.matches, "MatchId", "MatchId", matchDetails.MatchId);
            return(View(matchDetails));
        }
Пример #7
0
        public async Task <MatchDetails> GetMatchDetailsAsync(string matchID)
        {
            MatchDetails matchDetails = new MatchDetails();
            HttpClient   client       = new HttpClient();

            client.Timeout = new TimeSpan(0, 0, 10);
            HttpResponseMessage responseMatchDetails = await client.GetAsync(Url + "MatchDetails/" + matchID);

            if (responseMatchDetails.IsSuccessStatusCode)
            {
                var resultMatchDetails = await responseMatchDetails.Content.ReadAsStringAsync();

                matchDetails = JsonConvert.DeserializeObject <MatchDetails>(resultMatchDetails);
            }
            return(await Task.FromResult(matchDetails));
        }
Пример #8
0
 public ActionResult Index()
 {
     try
     {
         MatchDetails lstmatchdetails = new MatchDetails();
         lstmatchdetails.lstFixtures   = objMatchBL.GetListOfFixturedMatches(CommonClass.Fixtures);
         lstmatchdetails.lstInProgress = objMatchBL.GetListOfInProgressMatches(CommonClass.InProgress);
         lstmatchdetails.lstCompleted  = objMatchBL.GetListOfCompletedMatches(CommonClass.Completed);
         return(View(lstmatchdetails));
     }
     catch (Exception ex)
     {
         ExceptionLogger.LogException(Convert.ToString(Session["UserId"]), Convert.ToString(ex.InnerException), Convert.ToString(ex.Message), Convert.ToString(ex.Source), Convert.ToString(ex.StackTrace), DateTime.Now);
         return(View("error"));
     }
 }
Пример #9
0
        public IEnumerable <MatchDetails> Filter(IEnumerable <MatchDetails> input)
        {
            if (_filters == null || _filters.Count() == 0)
            {
                return(input);
            }

            IEnumerable <MatchDetails> resultSet = new MatchDetails[0];

            foreach (IMatchFilter filter in _filters.SafeEnum())
            {
                resultSet = resultSet.Union(filter.Filter(input));
            }

            return(resultSet);
        }
Пример #10
0
        private void RefreshMatchData(string action, MatchDetails matchDetails)
        {
            try
            {
                Match match = matchDetails?.Match;
                if (match != null)
                {
                    Match findMatch = _viewModel.AllMatches?.FirstOrDefault(x => x.MatchID == match.MatchID);
                    if (findMatch != null)
                    {
                        int findMatchIndex = _viewModel.AllMatches.IndexOf(findMatch);
                        _viewModel.AllMatches?.Insert(findMatchIndex, match);
                        _viewModel.AllMatches?.Remove(findMatch);
                    }
                    else
                    {
                        _viewModel.AllMatches?.Add(match);
                    }

                    //if (match.StatusID != findMatch?.StatusID)
                    //{
                    //    await _viewModel.GetStandingsAsync();
                    //}
                    bool isSelectedMatch = _viewModel.SelectedLiveMatch.MatchID == match.MatchID;
                    if (isSelectedMatch)
                    {
                        Match selectedMatch = matchDetails.Match;
                        selectedMatch.PlayersOfMatch          = new ObservableCollection <PlayerOfMatch>(matchDetails.PlayersOfMatch);
                        selectedMatch.EventsOfMatch           = new ObservableCollection <EventOfMatch>(matchDetails.EventsOfMatch);
                        _viewModel.SelectedLiveMatch          = selectedMatch;
                        _viewModel.SelectedLiveMatch.LiveTime = selectedMatch.LiveTime;
                        _viewModel.TimeCounter.MatchesTime(_viewModel, new ObservableCollection <Match>());
                        _viewModel.SetMatchAdditionalDetails();
                        _viewModel.SelectedLiveMatch.IsLoadingSelectedMatch = false;
                    }

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        PopulatePageView(false);
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
Пример #11
0
        public IActionResult SubmitEmailBet(string token)
        {
            EmailBet emailBet = Database.GetEmailBetByToken(token);

            bool         success      = false;
            MatchDetails matchDetails = null;

            if (emailBet != null)
            {
                matchDetails = Database.GetMatchDetails(emailBet.IdmatchAPI);
                success      = Database.InsertBets(emailBet.Username, Convert.ToInt32(emailBet.IdmatchAPI), matchDetails.UtcDate, emailBet.Result);
            }

            ViewBag.output = success ? "Aposta [" + emailBet.Result + "]" + " submetida para " + matchDetails.HomeTeam + "-" + matchDetails.AwayTeam + " com sucesso! Podes fechar esta janela." : "ERRO! APOSTA NÃO SUBMETIDA!";

            return(View());
        }
        // GET: Details/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MatchDetails matchDetails = db.MatchDetails.Find(id);

            if (matchDetails == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MatchId     = new SelectList(db.matches, "MatchId", "MatchId", matchDetails.MatchId);
            ViewBag.ID          = new SelectList(db.player, "ID", "Ime", matchDetails.ID);
            ViewBag.StatisticId = new SelectList(db.statistic, "StatisticId", "Picture", matchDetails.StatisticId);
            return(View(matchDetails));
        }
        public IActionResult FantasyPoints(int tourId, int matchId, string site)
        {
            //tourId = 946;
            //matchId = 12792;
            //site = "cricket";
            PlayerRequest req = new PlayerRequest()
            {
                MatchId   = matchId,
                TourId    = tourId,
                SportName = site
            };
            FantasyScoreDetails fantasyLst = _fantasyService.GetFantasyScoresList(req);
            MatchDetails        match      = new MatchDetails();

            match.FantasyDetailsLst = fantasyLst;
            return(View(match));
        }
Пример #14
0
        public static Lineups ToLineup(MatchDetails details)
        {
            var homeTeam = details.Teams.First().Team;
            var awayTeam = details.Teams.Last().Team;

            var homeTeamLineup = details.TeamLists.First(l => l.TeamId == homeTeam.Id);
            var awayTeamLineup = details.TeamLists.First(l => l.TeamId == awayTeam.Id);

            return(new Lineups
            {
                FixturePulseId = details.Id,
                HomeTeamNameAbbr = homeTeam.Club.Abbr,
                AwayTeamNameAbbr = awayTeam.Club.Abbr,
                HomeTeamLineup = OrderByFormation(homeTeamLineup),
                AwayTeamLineup = OrderByFormation(awayTeamLineup)
            });
        }
Пример #15
0
        public void Fetch(WebAPISDKEngine engine, long account_id, List <LobbyType> types, int num_matches)
        {
            MatchHistory hist;
            int          total_matches = 0;
            long         last_match_id = 0;
            /* this value is used as a "timeout" if no more matches can be found */
            int num_tries = (num_matches) * 4;

            while ((total_matches < num_matches) && (num_tries > 0))
            {
                hist = engine.GetMatchHistory(account_id, last_match_id, (ushort)(total_matches - num_matches), 0);

                if (hist != null)
                {
                    foreach (Match m in hist.Matches)
                    {
                        MatchDetails currentMatch = engine.GetMatchDetails(m.MatchID);

                        MatchDetailsPlayer p = currentMatch.Players.Where(player => player.AccountID == account_id).FirstOrDefault();

                        if ((p != null) && (types.Contains(currentMatch.LobbyType)))
                        {
                            PlayerGameDiscoveredEvent(this, new PlayerGameStats(currentMatch, p));
                            total_matches++;
                            /* we found a match, there might be more.  Give us some more tries! */
                            num_tries = num_tries + 5;
                        }
                        else
                        {
                            /* match was not found.  Decrement number of tries */
                            num_tries--;
                        }
                    }
                    last_match_id = hist.Matches.OrderByDescending(match => match.MatchID).LastOrDefault().MatchID - 1;
                }

                if (last_match_id == 0)
                {
                    break;
                }
            }


            StatsCompleteEvent(this);
        }
Пример #16
0
        public PlayerGameStats(MatchDetails m, MatchDetailsPlayer p)
            : base(m, p)
        {
            this.matchDetails       = m;
            this.matchDetailsPlayer = p;

            /* decode player slot */
            this.onRadiant = ((p.PlayerSlot & (0X80)) == 0);

            /* fetch the hero list and match the hero id */
            this.Hero = Utils.DotaUtils.HeroList.HeroesList.Where(hero => hero.ID == p.HeroID).First().LocalizedName;

            this.Kills   = p.Kills;
            this.Deaths  = p.Deaths;
            this.Assists = p.Assists;
            this.GPM     = p.GoldPerMinute;
            this.XPM     = p.XPPerMinute;
        }
        public MatchDetails Get(int id)
        {
            Matches      match          = (new MatchesController(null, dbContext).GetMatches(id) as OkObjectResult).Value as Matches;
            var          eventsOfMatch  = new EventsOfMatchesController(null, dbContext).GetEventsOfMatchesByMatchId(id);
            var          playersOfMatch = new PlayersOfMatchesController(null, dbContext).GetPlayersOfMatchesByMatchID(id);
            MatchDetails matchDetails   = new MatchDetails()
            {
                Match         = match,
                EventsOfMatch = eventsOfMatch?
                                .OrderBy(x => x.EventPeriodId ?? 0)
                                .ThenBy(x => x.EventTotalTime)
                                .ThenBy(x => x.EventMinute)
                                .ThenBy(x => x.EventOfMatchId).ToList(),
                PlayersOfMatch = playersOfMatch.Where(x => x.PlayingStatus != 3).ToList()
            };

            return(matchDetails);
        }
Пример #18
0
        public MatchDetails Get(int id)
        {
            Matches      match          = _dystirDBContext.Matches.Find(id);
            var          eventsOfMatch  = new EventsOfMatchesController(null, _dystirDBContext).GetEventsOfMatchesByMatchId(id);
            var          playersOfMatch = new PlayersOfMatchesController(null, _dystirDBContext).GetPlayersOfMatchesByMatchID(id);
            MatchDetails matchDetails   = new MatchDetails()
            {
                Match         = match,
                EventsOfMatch = eventsOfMatch?
                                .OrderBy(x => x.EventPeriodId ?? 0)
                                .ThenBy(x => x.EventTotalTime)
                                .ThenBy(x => x.EventMinute)
                                .ThenBy(x => x.EventOfMatchId).ToList(),
                PlayersOfMatch = playersOfMatch.Where(x => x.PlayingStatus != 3).ToList()
            };

            return(matchDetails);
        }
Пример #19
0
        internal async void SeeMatchDetailsAsync(Match selectedMatch, bool refreshMatchesBySelectedDate)
        {
            _viewModel.SelectedMatch = selectedMatch;
            if (refreshMatchesBySelectedDate)
            {
                ShowSelectedPage(5);
                ShowMainTab(false);
            }
            else
            {
                _viewModel.SelectedMatchDetails = new MatchDetails();
            }
            _viewModel.SelectedMatchDetails.Match = selectedMatch;

            await Task.Run(() =>
            {
                _viewModel.AllMatchesWithDetails.ToList().ForEach(x => x.IsSelected = false);
                MatchDetails matchDetails       = _viewModel.AllMatchesWithDetails?.FirstOrDefault(x => x.Match?.MatchID == selectedMatch?.MatchID);
                matchDetails.IsSelected         = true;
                _viewModel.SelectedMatchDetails = matchDetails;
                if (refreshMatchesBySelectedDate)
                {
                    _viewModel.SetMatchesBySelectedDate();
                }
            });

            Device.BeginInvokeOnMainThread(() =>
            {
                MenuMatchesScrollView.BackgroundColor = Color.Transparent;
                int matchDetailsIndex = _viewModel.MatchesBySelectedDate.IndexOf(_viewModel.MatchesBySelectedDate.FirstOrDefault(x => x.Match.MatchID == selectedMatch?.MatchID));
                if (matchDetailsIndex > -1)
                {
                    MenuMatchesScrollView.ScrollTo(matchDetailsIndex, -1, ScrollToPosition.Center, true);
                }
            });

            if (_viewModel.SelectedMatchDetails != null && !_viewModel.SelectedMatchDetails.IsDataLoaded)
            {
                _viewModel.IsLoadingSelectedMatch = true;
                _ = (Application.Current as App).ReloadAsync(LoadDataType.MatchDataOnly);
            }

            AnalyticsMatchDetails(selectedMatch);
        }
        public IActionResult Index(string sportName)
        {
            MatchDetails matchDetails = new MatchDetails();

            try
            {
                List <Squad> leagueResponse = _matchService.GetLeagueDetails(sportName);
                string       webroot        = _env.WebRootPath;
                matchDetails.SquadList = leagueResponse;
                matchDetails.SportName = sportName;
                var filePath = System.IO.Path.Combine(webroot, "FantasyCard.json");
                var jsonData = System.IO.File.ReadAllText(filePath);
                List <MatchHistory> persons  = JsonConvert.DeserializeObject <List <MatchHistory> >(jsonData);
                List <MatchHistory> matchLst = new List <MatchHistory>();
                if (persons == null)
                {
                    persons = new List <MatchHistory>();
                }
                foreach (var items in matchDetails.SquadList)
                {
                    MatchHistory matchHistory = new MatchHistory();
                    matchHistory.matchId   = items.id;
                    matchHistory.name      = items.name;
                    matchHistory.tourId    = items.tourId;
                    matchHistory.site      = sportName;
                    matchHistory.startdate = items.startDate;
                    persons.Add(matchHistory);
                }

                string newJson = JsonConvert.SerializeObject(persons);
                System.IO.File.WriteAllText(filePath, newJson);
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string webroot = _env.WebRootPath;
                var    file    = System.IO.Path.Combine(webroot, "error.txt");
                using (StreamWriter writer = new StreamWriter(file, true))
                {
                    writer.WriteLine(DateTime.Now + ":---> " + error);
                }
            }
            return(View(matchDetails));
        }
Пример #21
0
    //Method that runs AFTER the DataParser is done parsing. If it wasn't delayed, it would throw a null reference error.
    void DelayedStart()
    {
        if (!player2)
        {
            Debug.Log("player2 is: " + player2);
            wordToUse = DataParser.Instance.GetRandomWordNoVowels(Random.Range(minimumWordLengthToGet, 10));
        }
        else
        {
            matchDetails = Database.Instance.GetMatchDetailsFromDatabase(id);
            Debug.Log("player2 is: " + player2);
            wordToUse = matchDetails.ConsUsed;
        }

        InstaConsonants();
        InstaVowelsStart();

        DataParser.OnFInish -= DelayedStart;
    }
        public ActionResult Add(MatchDetails matchdetails)
        {
            List <SelectListItem> matcheslist = new List <SelectListItem>();
            MatchesRepository     matchrep    = new MatchesRepository();
            var mymatches = matchrep.GetAllMatches();

            foreach (Match m in mymatches)
            {
                if (m.Date == DateTime.Now.Date)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = m.MatchId.ToString();
                    sli.Text  = m.HomeTeam.Name + "(" + m.HomeGoals + "-" + m.AwayGoals + ")" + m.GuestTeam.Name;
                    matcheslist.Add(sli);
                }
            }
            db.MatchDetails.Add(matchdetails);
            db.SaveChanges();
            ViewData["Matches"] = matcheslist;
            return(View());
        }
Пример #23
0
        public async Task <MatchDetails> UpdateAsync(MatchDetails matchDetails)
        {
            List <MatchDetails> matchDetailss = await GetMatchDetailssAsync();

            var matchIndex = matchDetailss.FindIndex(m => m.Id == matchDetails.Id);

            if (matchIndex == -1)
            {
                throw new ApplicationException("Missing tennis game entry for id " + matchDetails.Id);
            }

            matchDetailss[matchIndex] = matchDetails;

            using (StreamWriter writer = new StreamWriter(_resourceName))
            {
                var matchesJsonToWrite = JsonSerializer.Serialize(matchDetailss);
                await writer.WriteAsync(matchesJsonToWrite);
            }

            return(matchDetails);
        }
        public async Task <IHttpActionResult> QueueReplay(HttpRequestMessage request)
        {
            string jsonString = await request.Content.ReadAsStringAsync();

            JArray matches = JArray.Parse(jsonString);

            List <DotaMatch> newMatches = new List <DotaMatch>();

            /*
             * Add each match sent.
             */
            foreach (JToken matchToken in matches)
            {
                MatchReplayProgress match = matchToken.ToObject <MatchReplayProgress>();
                //Get the duration so we can monitor replay progress
                MatchDetails md = await MatchesController.GetDetailsFromMatch(match.MatchId);

                match.Duration = md.Duration;
                ReplayCreator.Instance.addMatch(match);
            }
            return(Ok());
        }
            public override void Setup()
            {
                base.Setup();
                _eventobj = new Event
                {
                    Type        = "game.tennis.changeserver",
                    ContentJson = JsonSerializer.Serialize(new TennisEventObject
                    {
                        GameId = "gameId"
                    })
                };

                _tennisMatchDetails = new MatchDetails
                {
                    Id            = "gameId",
                    ServingPlayer = 1
                };
                _tennisGameGateway.Setup(m => m.GetAsync(_tennisMatchDetails.Id)).ReturnsAsync(_tennisMatchDetails);
                _tennisGameGateway.Setup(m => m.UpdateAsync(It.IsAny <MatchDetails>()))
                .Callback <MatchDetails>(input => _tennisMatchDetails = input)
                .ReturnsAsync(_tennisMatchDetails);
            }
Пример #26
0
        private FullMatchDetailsModelView GetMatchDetailsFromJson(string matchDetailsJson, string matchesListJson)
        {
            FullMatchDetailsModelView fullMatchDetailsModelView = new FullMatchDetailsModelView();

            try
            {
                List <Matches> allMatches   = JsonConvert.DeserializeObject <List <Matches> >(matchesListJson);
                MatchDetails   matchDetails = JsonConvert.DeserializeObject <MatchDetails>(matchDetailsJson);
                Matches        match        = matchDetails.Match;
                DateTime       date         = match.Time.Value.Date;
                fullMatchDetailsModelView.MatchesListSelection = GetMatchesFromJson(allMatches);
                fullMatchDetailsModelView.MatchDetails         = matchDetails;
                fullMatchDetailsModelView.Summary       = GetSummary(fullMatchDetailsModelView.MatchDetails);
                fullMatchDetailsModelView.Commentary    = GetCommentary(fullMatchDetailsModelView.MatchDetails);
                fullMatchDetailsModelView.Statistics    = GetStatistics(fullMatchDetailsModelView.MatchDetails.EventsOfMatch, fullMatchDetailsModelView.MatchDetails.Match);
                fullMatchDetailsModelView.MatchesGroups = fullMatchDetailsModelView.MatchesListSelection?.GroupBy(x => x.MatchTypeName);
            }
            catch (Exception)
            {
            }
            return(fullMatchDetailsModelView);
        }
        private FullMatchDetailsModelView GetMatchDetailsFromJson(string matchDetailsJson, string matchesListJson)
        {
            FullMatchDetailsModelView fullMatchDetailsModelView = new FullMatchDetailsModelView();

            try
            {
                List <Matches> allMatches   = JsonConvert.DeserializeObject <List <Matches> >(matchesListJson);
                MatchDetails   matchDetails = JsonConvert.DeserializeObject <MatchDetails>(matchDetailsJson);
                Matches        match        = matchDetails.Match;
                DateTime       date         = match.Time.Value.Date;
                fullMatchDetailsModelView.MatchesListSelection = allMatches?.Where(x => x.Time.Value.Date == date && x.MatchId != match.MatchId && x.StatusId < 13)
                                                                 .OrderBy(x => x.MatchTypeId).ThenBy(x => x.Time).ToList();
                fullMatchDetailsModelView.MatchDetails = matchDetails;
                fullMatchDetailsModelView.Summary      = GetSummary(fullMatchDetailsModelView.MatchDetails);
                fullMatchDetailsModelView.Commentary   = GetCommentary(fullMatchDetailsModelView.MatchDetails);
                fullMatchDetailsModelView.Statistics   = GetStatistics(fullMatchDetailsModelView.MatchDetails.EventsOfMatch, fullMatchDetailsModelView.MatchDetails.Match);
            }
            catch (Exception ex)
            {
            }
            return(fullMatchDetailsModelView);
        }
        public ActionResult Create([Bind(Include = "MatchDetailsId,Content,MatchId,ID,Name,LastName,StatisticId,HomeTeamId,Min")] MatchDetails matchDetails, int ID)
        {
            List <SelectListItem> matcheslist = new List <SelectListItem>();
            List <SelectListItem> tlist       = new List <SelectListItem>();
            MatchesRepository     matchrep    = new MatchesRepository();
            var mymatches = matchrep.GetAllMatches();

            if (ModelState.IsValid)
            {
                foreach (Match m in mymatches.Where(i => i.HomeTeamId == ID))
                {
                    SelectListItem sli1 = new SelectListItem();

                    SelectListItem sli = new SelectListItem();
                    sli.Value  = m.MatchId.ToString();
                    sli.Text   = m.HomeTeam.Name + " " + m.HomeGoals + "-" + m.AwayGoals + " " + m.GuestTeam.Name;
                    sli1.Value = m.HomeTeamId.ToString();
                    sli1.Text  = m.HomeTeam.Name;

                    matcheslist.Add(sli);
                    tlist.Add(sli1);
                }

                ViewData["Matches"] = matcheslist;
                ViewData["Teams"]   = tlist;
                // ViewData["GuestTeams"] = tlist;
                db.MatchDetails.Add(matchDetails);
                db.SaveChanges();
                return(RedirectToAction("Index", "Match"));
            }

            ViewBag.MatchId     = new SelectList(db.matches, "MatchId", "MatchId", matchDetails.MatchId);
            ViewBag.ID          = new SelectList(db.player.Where(i => i.TeamId == ID), "ID", "Name", "LastName", matchDetails.ID);
            ViewBag.StatisticId = new SelectList(db.statistic, "StatisticId", "PName", matchDetails.StatisticId);
            ViewBag.HomeTeamId  = new SelectList(db.team.Where(i => i.TeamId == ID), "TeamId", "Name", matchDetails.HomeTeamId);
            // ViewBag.GuestTeamId = new SelectList(db.team.Where(i => i.TeamId == ID), "TeamId", "Name", matchDetails.GuestTeamId);
            return(View());
        }
Пример #29
0
        private List <SummaryEventOfMatch> GetCommentary(MatchDetails matchDetails)
        {
            List <SummaryEventOfMatch> summaryEventOfMatchesList = new List <SummaryEventOfMatch>();
            var eventsList = matchDetails.EventsOfMatch?.Where(x => x != null).ToList();
            int homeScore  = 0;
            int awayScore  = 0;

            foreach (var eventOfMatch in eventsList ?? new List <EventsOfMatches>())
            {
                SummaryEventOfMatch summaryEventOfMatch = new SummaryEventOfMatch()
                {
                    EventOfMatch  = eventOfMatch,
                    HomeTeam      = eventOfMatch.EventTeam == matchDetails.Match.HomeTeam ? eventOfMatch.EventTeam : null,
                    AwayTeam      = eventOfMatch.EventTeam == matchDetails.Match.AwayTeam ? eventOfMatch.EventTeam : null,
                    EventMinute   = eventOfMatch.EventMinute,
                    EventName     = eventOfMatch.EventName,
                    HomeTeamScore = 0,
                    AwayTeamScore = 0
                };
                if (IsGoal(eventOfMatch))
                {
                    if (eventOfMatch.EventTeam.ToUpper().Trim() == matchDetails.Match.HomeTeam.ToUpper().Trim())
                    {
                        homeScore += 1;
                    }
                    if (eventOfMatch.EventTeam.ToUpper().Trim() == matchDetails.Match.AwayTeam.ToUpper().Trim())
                    {
                        awayScore += 1;
                    }
                }
                summaryEventOfMatch.HomeTeamScore = homeScore;
                summaryEventOfMatch.AwayTeamScore = awayScore;
                summaryEventOfMatchesList.Add(summaryEventOfMatch);
            }
            summaryEventOfMatchesList.Reverse();
            return(summaryEventOfMatchesList);
        }
Пример #30
0
        // ALL MATCHES WITH DETAILS
        public void SetAllMatchesWithDetails()
        {
            var allMatchesWithDetails = new ObservableCollection <MatchDetails>();

            foreach (Match match in AllMatches)
            {
                MatchDetails matchDetails = AllMatchesWithDetails.FirstOrDefault(x => x.Match?.MatchID == match.MatchID);
                if (matchDetails != null)
                {
                    matchDetails.Match = match;
                }
                else
                {
                    matchDetails = new MatchDetails()
                    {
                        Match          = match,
                        PlayersOfMatch = new ObservableCollection <PlayerOfMatch>(),
                        EventsOfMatch  = new ObservableCollection <EventOfMatch>()
                    };
                }
                allMatchesWithDetails.Add(matchDetails);
            }
            AllMatchesWithDetails = new ObservableCollection <MatchDetails>(allMatchesWithDetails);
        }