Exemple #1
0
        public async Task <bool> UpdateMatch(MatchEntity match)
        {
            //get data
            List <MatchEntity> matches = await _matchRepository.GetMatchesEntities().ToListAsync();

            //validate match data
            if (!ValidateMatchValues(match))
            {
                return(false);
            }

            //Check if any score is negative
            if (match.TeamHomeScore < 0 || match.TeamAwayScore < 0)
            {
                return(false);
            }

            //check that record exists with same teams in same order
            MatchEntity entity = matches.Where(x => x.TeamHomeName == match.TeamHomeName && x.TeamAwayName == match.TeamAwayName).FirstOrDefault();

            if (entity == null)
            {
                return(false);
            }

            return(await _matchRepository.UpdateMatchEntity(entity));
        }
Exemple #2
0
        public async Task <bool> StartMatch(MatchEntity match)
        {
            //get data
            List <MatchEntity> matches = await _matchRepository.GetMatchesEntities().ToListAsync();

            //validate match data
            if (!ValidateMatchValues(match))
            {
                return(false);
            }

            //Check if any score
            if (match.TeamHomeScore != 0 || match.TeamAwayScore != 0)
            {
                return(false);
            }

            //Check repeated team
            if (matches != null && matches.Any(x => x.TeamHomeName.Contains(match.TeamHomeName) || x.TeamHomeName.Contains(match.TeamAwayName) ||
                                               x.TeamAwayName.Contains(match.TeamHomeName) || x.TeamAwayName.Contains(match.TeamAwayName)))
            {
                return(false);
            }

            matches.Add(match);

            return(true);
        }
Exemple #3
0
        public async Task <Guid> Create(Guid userId, MatchModel model)
        {
            CheckTeamExist(model.FirstTeamId);

            CheckTeamExist(model.SecondTeamId);

            CheckIsAdmin(userId);

            var matchEntity = new MatchEntity()
            {
                TimeMatch     = SystemHelper.UtcToSystemTime(model.TimeMatch),
                Stadium       = model.Stadium,
                PriceConfigId = model.PriceConfigId,
                MatchTeams    = new List <MatchTeamEntity>
                {
                    new MatchTeamEntity()
                    {
                        TeamId = model.FirstTeamId, Rate = model.FirstTeamRate
                    },
                    new MatchTeamEntity()
                    {
                        TeamId = model.SecondTeamId, Rate = model.SecondTeamRate
                    }
                }
            };

            _matchRepository.Add(matchEntity);
            await _unitOfWork.SaveChangesAsync();

            return(matchEntity.Id);
        }
        private Match MapMatchEntityToMatch(MatchEntity matchentity)
        {
            var umpireOneName = "";
            var umpireOne     = Access.UmpireService.GetUmpires().Where(u => u.MatchId == matchentity.Id && u.Primary == true);

            if (umpireOne.Any())
            {
                umpireOneName = umpireOne.First().Name;
            }

            var umpireTwoName = "";
            var umpireTwo     = Access.UmpireService.GetUmpires().Where(u => u.MatchId == matchentity.Id && u.Primary == false);

            if (umpireTwo.Any())
            {
                umpireTwoName = umpireTwo.First().Name;
            }

            return(new Match
            {
                Id = matchentity.Id,
                Name = $"{matchentity.HomeTeamName}_{matchentity.AwayTeamName}_{matchentity.Id}",
                TotalOvers = matchentity.TotalOvers,
                Location = matchentity.Location,
                Date = matchentity.MatchDate,
                Comments = matchentity.Comments,
                Complete = matchentity.MatchComplete,
                HomeTeam = new Team
                {
                    Id = matchentity.HomeTeamId,
                    Name = matchentity.HomeTeamName,
                    Runs = matchentity.HomeTeamRuns,
                    Balls = matchentity.HomeTeamBalls,
                    Wickets = matchentity.HomeTeamWickets,
                    NoBalls = matchentity.HomeTeamNoBalls,
                    Wides = matchentity.HomeTeamWides,
                    Byes = matchentity.HomeTeamByes,
                    LegByes = matchentity.HomeTeamLegByes,
                    InningsComplete = matchentity.HomeTeamInningsComplete,
                    Players = Access.PlayerService.GetPlayersPerTeamPerMatch(matchentity.HomeTeamId, matchentity.Id)
                },
                AwayTeam = new Team
                {
                    Id = matchentity.AwayTeamId,
                    Name = matchentity.AwayTeamName,
                    Runs = matchentity.AwayTeamRuns,
                    Balls = matchentity.AwayTeamBalls,
                    Wickets = matchentity.AwayTeamWickets,
                    NoBalls = matchentity.AwayTeamNoBalls,
                    Wides = matchentity.AwayTeamWides,
                    Byes = matchentity.AwayTeamByes,
                    LegByes = matchentity.AwayTeamLegByes,
                    InningsComplete = matchentity.AwayTeamInningsComplete,
                    Players = Access.PlayerService.GetPlayersPerTeamPerMatch(matchentity.AwayTeamId, matchentity.Id)
                },
                WinningTeamName = matchentity.WinningTeamName,
                UmpireOne = umpireOneName,
                UmpireTwo = umpireTwoName
            });
        }
Exemple #5
0
        public async Task Current_Date_Is_Before_Result_Correction_Deadline(DateTime changeDate, int maxDaysForCorrection, bool failureExpected)
        {
            var data = (new TenantContext()
            {
                TournamentContext = new TournamentContext {
                    MaxDaysForResultCorrection = maxDaysForCorrection
                }
            },
                        (TournamentInPlanMode : false, RoundIsCompleted : false,
                         CurrentDateUtc : changeDate));
            var match = new MatchEntity {
                RealStart = new DateTime(2020, 07, 01, 20, 00, 00)
            };
            var mpv = new MatchResultPermissionValidator(match, data);
            await mpv.CheckAsync(MatchResultPermissionValidator.FactId.CurrentDateIsBeforeResultCorrectionDeadline,
                                 CancellationToken.None);

            var factResults = mpv.GetFailedFacts();

            Assert.Multiple(() =>
            {
                Assert.AreEqual(failureExpected, factResults.Count == 1);
                Assert.AreEqual(failureExpected, factResults.FirstOrDefault()?.Id == MatchResultPermissionValidator.FactId.CurrentDateIsBeforeResultCorrectionDeadline);
                Assert.IsTrue(factResults.All(fr => fr.Exception == null));
            });
        }
        public MatchResult GetResult(MatchEntity match = null)
        {
            if (match == null)
            {
                var matchesService = DependencyResolver.Current.GetService <IMatchesService>() as IMatchesService;
                match = matchesService.GetMatch(this.Id);
            }

            if (this.HomeGoals > this.AwayGoals)
            {
                return(MatchResult.HomeVictory);
            }
            else if (this.HomeGoals < this.AwayGoals)
            {
                return(MatchResult.AwayVictory);
            }
            else if (match.Stage.SupportPenalties())
            {
                return(this.HomePenalties > this.AwayPenalties ? MatchResult.HomeVictory : MatchResult.AwayVictory);
            }
            else
            {
                return(MatchResult.Draw);
            }
        }
Exemple #7
0
        public void Update(MatchEntity match)
        {
            match.MatchUpdated = DateTimeOffset.Now;
            TableOperation updateOperation = TableOperation.InsertOrReplace(match);

            table.Execute(updateOperation);
        }
Exemple #8
0
        public IActionResult Post(MatchEntity match)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var occurrences = match.FindOccurrences();

                var result = new MatchResult(match);
                result.Occurrences.AddRange(occurrences.Select(occurence => new MatchOccurrence()
                {
                    Index  = occurence.Index,
                    Length = occurence.Length,
                    Value  = occurence.Value
                }));

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemple #9
0
        private void Start()
        {
            if (board == null)
            {
                throw new ArgumentNullException(nameof(board));
            }

            if (myTimeText == null)
            {
                throw new ArgumentNullException(nameof(myTimeText));
            }

            if (opponentTimeText == null)
            {
                throw new ArgumentNullException(nameof(opponentTimeText));
            }

            if (matchToStart == null)
            {
                StartDebug();
            }
            else
            {
                var match = matchToStart;
                matchToStart = null;
                StartRegular(match);
            }
        }
Exemple #10
0
        public static MatchEntity CalculateMatchPoints(this MatchEntity match, MatchRuleEntity matchRule)
        {
            if (!match.Sets.Any())
            {
                return(match);
            }

            match.IsOverruled = match.Sets.Any(s => s.IsOverruled);

            var setPoints = match.Sets.GetSetPoints();

            if (setPoints.Home < setPoints.Guest)
            {
                match.HomePoints  = matchRule.PointsMatchLost;
                match.GuestPoints = matchRule.PointsMatchWon;
            }
            else if (setPoints.Home > setPoints.Guest)
            {
                match.HomePoints  = matchRule.PointsMatchWon;
                match.GuestPoints = matchRule.PointsMatchLost;
            }
            else
            {
                match.HomePoints = match.GuestPoints = matchRule.PointsMatchTie;
            }

            match.IsComplete = true;

            return(match);
        }
        public virtual RoundLegEntity GetLeg(MatchEntity match)
        {
            // if leg does not exist or no match.SequenceNo: result will be NULL!

            if (!match.LegSequenceNo.HasValue)
            {
                return(null);
            }

            if (match.Round != null && match.Round.RoundLegs != null)
            {
                return(match.Round.RoundLegs.First(l => l.SequenceNo == match.LegSequenceNo));
            }

            using (var da = _dbContext.GetNewAdapter())
            {
                var metaData = new LinqMetaData(da);
                IQueryable <RoundLegEntity> q = from l in metaData.RoundLeg
                                                where l.RoundId == match.RoundId && l.SequenceNo == match.LegSequenceNo
                                                select l;

                var result = q.First <RoundLegEntity>();
                da.CloseConnection();
                return(result);
            }
        }
Exemple #12
0
        public MatchEntity Get(string srcMatchID)
        {
            MatchEntity me = null;

            matchDic.TryGetValue(srcMatchID, out me);
            return(me);
        }
        public MatchEntity Execute(MatchEntity matchToCheck)
        {
            MatchEntity match = matchToCheck;

            try
            {
                _logger.LogMessage(string.Format("{0} execution started - {1}", this.GetType().Name, DateTime.Now));
                _logger.LogMessage(string.Format("Calling API to get match full time score for *[{0}]* vs *[{1}]* - {2}",
                                                 match.HomeTeam,
                                                 match.AwayTeam,
                                                 DateTime.Now));

                var stats = _api.GetMatch(match.MatchId);

                if (stats != null && stats.status.ToUpper() == "FT" && stats.ft_score != null)
                {
                    match.Score = stats.ft_score;
                }

                _logger.LogMessage(string.Format("{0} finished successfully - {1}", this.GetType().Name, DateTime.Now));
            }
            catch (Exception ex)
            {
                _logger.LogMessage(string.Format("{0} error occurred - {1}", this.GetType().Name, ex.Message), true);
            }

            return(match);
        }
Exemple #14
0
        /// <summary>
        /// 得到区域
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="lng"></param>
        /// <param name="lat"></param>
        /// <param name="city"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        protected virtual MatchEntity GetMatch(string city, string type, string tag, double lng, double lat)
        {
            var match = new MatchEntity
            {
                Areas = new List <AreaEntity>(),
                Lat   = lat,
                Lng   = lng
            };
            var infos = GetEntities();

            if (infos != null)
            {
                foreach (var info in infos)
                {
                    if ((string.IsNullOrEmpty(tag) || info.Tag == tag) &&
                        (string.IsNullOrEmpty(type) || info.Type == type) &&
                        (string.IsNullOrEmpty(city) || info.City == city) &&
                        (lng == 0 || lat == 0 || info.CheckPoint(lng, lat)))
                    {
                        match.Areas.Add(info);
                    }
                }
            }
            return(match);
        }
Exemple #15
0
        public MatchEntity GetOrAdd(string srcMatchID, string srcLeague, string srcHome, string srcAway, DateTime srcMatchDate, int sportID, bool isSelfCreate = false)
        {
            srcLeague = srcLeague.Trim().ToUpper();
            srcHome   = srcHome.Trim();
            srcAway   = srcAway.Trim();
            if (string.IsNullOrEmpty(srcLeague) || string.IsNullOrEmpty(srcHome) || string.IsNullOrEmpty(srcAway))
            {
                return(null);
            }

            MatchEntity dto = matchDic.GetOrAdd(srcMatchID, new MatchEntity()
            {
                SrcMatchID = srcMatchID, SportID = sportID, Communicator = communicator, IsSelfCreate = isSelfCreate
            });
            bool isMatchDateChanged;
            bool isNewMatch = CheckMatch(srcMatchID, srcLeague, srcHome, srcAway, srcMatchDate, dto, out isMatchDateChanged);

            if (isNewMatch)
            {
                SendSrcMatchInfo(dto);
            }
            else if (isMatchDateChanged)
            {
                SendSrcMatchDate(dto);
            }

            //  测试
            //if (srcMatchID == "24747505") dto.MatchID = 1234;

            return(dto);
        }
 public string BuildTweet(InterestLevel matchInterestLevel, MatchEntity match)
 {
     return(string.Format("Match between {0} (home) and {1} (away) was {2}",
                          match.HomeTeam,
                          match.AwayTeam,
                          matchInterestLevel));
 }
Exemple #17
0
        public static MatchViewModel ToMatchViewModel(MatchEntity match, IEnumerable <BaseMatchResult> results, IEnumerable <CountryEntity> countries)
        {
            var result   = results.FirstOrDefault(x => match.Id.Equals(x.MatchId));
            var homeTeam = countries.FirstOrDefault(x => match.HomeTeam.Equals(x.Id));
            var awayTeam = countries.FirstOrDefault(x => match.AwayTeam.Equals(x.Id));

            return(new MatchViewModel
            {
                Id = match.Id,
                HomeTeamId = match.HomeTeam,
                HomeTeam = homeTeam.Name,
                HomeTeamCode = homeTeam.Code,
                HomeTeamGoals = result?.HomeGoals,
                HomeTeamPenalties = result?.HomePenalties,
                AwayTeamId = match.AwayTeam,
                AwayTeam = awayTeam.Name,
                AwayTeamCode = awayTeam.Code,
                AwayTeamGoals = result?.AwayGoals,
                AwayTeamPenalties = result?.AwayPenalties,
                PlayedOn = match.PlayedOn.Value,
                Stage = match.Stage,
                Completed = match.PlayedOn <= DateTime.UtcNow,
                PenaltiesDefinition = result != null && match.Stage.SupportPenalties() && result.HomeGoals == result.AwayGoals
            });
        }
        public void GameModesTable_Create()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("AzureStorageConnectionString"));

            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            CloudTable table = tableClient.GetTableReference("Matches");

            table.CreateIfNotExists();

            // insert
            var         matchGuid = Guid.NewGuid();
            MatchEntity entity    = new MatchEntity(matchGuid, "ROMA", "RORO");

            TableOperation insertOperation = TableOperation.Insert(entity);

            table.Execute(insertOperation);

            // get
            TableQuery <MatchEntity> query = new TableQuery <MatchEntity>().Where(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, matchGuid.ToString()));

            var ent = table.ExecuteQuery(query).First();

            // delete
            TableOperation deleteOperation = TableOperation.Delete(ent);

            table.Execute(deleteOperation);
        }
Exemple #19
0
        public DatabaseParserUpdater()
        {
            parser  = new ParserWorker <Match[]>(new MatchParser(), new MatchSettings());
            list    = new List <MatchEntity>();
            leagues = Available.Leagues.ToArray();
            coeffs  = new List <CoeffEntity>();


            parser.OnNewData += (matches, league) =>
            {
                foreach (var match in matches)
                {
                    MatchEntity row = new MatchEntity();

                    row.StartTime = match.StartTime;
                    row.Teams     = match.Teams;
                    row.League    = league;

                    foreach (var coeff in match.Coeffs)
                    {
                        CoeffEntity item = new CoeffEntity();

                        item.Coefficient = coeff.Value;
                        item.Formula     = coeff.Formula;
                        item.Holder      = row;
                        coeffs.Add(item);
                    }

                    list.Add(row);
                }
            };
        }
Exemple #20
0
        public void DAL_MatchesTable_GetAll()
        {
            Matches matches = new Matches();

            var         matchGuid = Guid.NewGuid();
            MatchEntity entity    = new MatchEntity(matchGuid, "ROMA", "RORO");

            matches.RegisterMatch(entity);

            var matchGuid2 = Guid.NewGuid();

            entity = new MatchEntity(matchGuid2, "RORO", "ROMA");
            matches.RegisterMatch(entity);

            var matchGuid3 = Guid.NewGuid();

            entity = new MatchEntity(matchGuid3, "RORO", "ERAN");
            matches.RegisterMatch(entity);

            var playedMatches = matches.GetAll();

            Assert.AreEqual(3, playedMatches.Count);

            matches.Delete(matches.GetMatchById(matchGuid));
            matches.Delete(matches.GetMatchById(matchGuid2));
            matches.Delete(matches.GetMatchById(matchGuid3));
        }
        async void Start()
        {
            if (!matchmakerClient)
            {
                throw new ArgumentNullException(nameof(matchmakerClient));
            }

            if (!photonClient)
            {
                throw new ArgumentNullException(nameof(photonClient));
            }

            // try to connect to photon
            Debug.Log("Connecting to photon...");
            bool photonConnectionOk = await photonClient.ConnectToPhoton();

            Debug.Log("Photon result: " + photonConnectionOk);

            // perform matchmaking
            // TODO: catch network exceptions
            Debug.Log("Matchmaking...");
            MatchEntity match = await matchmakerClient.PerformMatchmaking(
                usePhoton : photonConnectionOk
                );

            Debug.Log("Match: " + match.EntityId);

            // join the match
            PlaygroundController.matchToStart = match;
            PhotonNetwork.LoadLevel("Playground");
        }
Exemple #22
0
        public async Task <IActionResult> CloseMatch(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MatchEntity matchEntity = await _context.Matches
                                      .Include(m => m.Group)
                                      .Include(m => m.Local)
                                      .Include(m => m.Visitor)
                                      .FirstOrDefaultAsync(m => m.Id == id);

            if (matchEntity == null)
            {
                return(NotFound());
            }

            CloseMatchViewModel model = new CloseMatchViewModel
            {
                Group     = matchEntity.Group,
                GroupId   = matchEntity.Group.Id,
                Local     = matchEntity.Local,
                LocalId   = matchEntity.Local.Id,
                MatchId   = matchEntity.Id,
                Visitor   = matchEntity.Visitor,
                VisitorId = matchEntity.Visitor.Id
            };

            return(View(model));
        }
        public async Task <MatchEntity> SaveMatch(MatchEntity entity)
        {
            MatchEntity existingEntity = null;

            if (entity.Id != null && !Guid.Empty.Equals(entity.Id))
            {
                existingEntity = await this.matchesRepository.GetAsync(entity.Id);
            }

            if (existingEntity != null)
            {
                existingEntity.AwayTeam = entity.AwayTeam;
                existingEntity.HomeTeam = entity.HomeTeam;
                existingEntity.PlayedOn = entity.PlayedOn;
                existingEntity.Stage    = entity.Stage;
            }
            else
            {
                existingEntity    = entity;
                existingEntity.Id = Guid.NewGuid();
            }

            await this.matchesRepository.SaveAsync(existingEntity);

            return(existingEntity);
        }
        public async Task <IActionResult> PostPrediction([FromBody] PredictionRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            MatchEntity matchEntity = await _context.Matches.FindAsync(request.MatchId);

            if (matchEntity == null)
            {
                return(BadRequest("Este partido no existe."));
            }

            if (matchEntity.IsClosed)
            {
                return(BadRequest("Este partido está cerrado."));
            }

            UserEntity userEntity = await _userHelper.GetUserAsync(request.UserId);

            if (userEntity == null)
            {
                return(BadRequest("Este usuario no existe."));
            }

            if (matchEntity.Date <= DateTime.UtcNow)
            {
                return(BadRequest("Este partido ya empezó."));
            }

            PredictionEntity predictionEntity = await _context.Predictions
                                                .FirstOrDefaultAsync(p => p.User.Id == request.UserId.ToString() && p.Match.Id == request.MatchId);

            if (predictionEntity == null)
            {
                predictionEntity = new PredictionEntity
                {
                    GoalsLocal   = request.GoalsLocal,
                    GoalsVisitor = request.GoalsVisitor,
                    Match        = matchEntity,
                    User         = userEntity
                };

                _context.Predictions.Add(predictionEntity);
            }
            else
            {
                predictionEntity.GoalsLocal   = request.GoalsLocal;
                predictionEntity.GoalsVisitor = request.GoalsVisitor;
                _context.Predictions.Update(predictionEntity);
            }

            await _context.SaveChangesAsync();

            return(NoContent());
        }
Exemple #25
0
        public async Task <MatchEntity> AddAsync(MatchEntity entity)
        {
            var response = await dbContext.Match.AddAsync(entity);

            await dbContext.SaveChangesAsync();

            return(response.Entity);
        }
Exemple #26
0
 public TeamMatchExcelModel(MatchEntity match, ClubEntity[] clubs)
 {
     Match            = match;
     Home             = GetTeamDesc(match.HomeClubId, match.HomeTeamCode, clubs);
     Out              = GetTeamDesc(match.AwayClubId, match.AwayTeamCode, clubs);
     PlayerDecisions  = new Dictionary <string, string>();
     CaptainDecisions = new List <string>();
 }
Exemple #27
0
        public async Task <IActionResult> PostPrediction([FromBody] PredictionRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            CultureInfo cultureInfo = new CultureInfo(request.CultureInfo);

            Resource.Culture = cultureInfo;

            MatchEntity matchEntity = await _dataContext.Matches.FindAsync(request.MatchId);

            if (matchEntity == null)
            {
                return(BadRequest(Resource.MatchDoesntExists));
            }
            if (matchEntity.IsClosed)
            {
                return(BadRequest(Resource.MatchAlreadyClosed));
            }

            UserEntity userEntity = await _userHelper.GetUserAsync(request.UserId);

            if (userEntity == null)
            {
                return(BadRequest(Resource.UserDoesntExists));
            }
            if (matchEntity.Date <= DateTime.UtcNow)
            {
                return(BadRequest(Resource.MatchAlreadyStarts));
            }

            PredictionEntity predictionEntity = await _dataContext.Predictions
                                                .FirstOrDefaultAsync(p => p.User.Id == request.UserId.ToString() && p.Match.Id == request.MatchId);

            if (predictionEntity == null)
            {
                predictionEntity = new PredictionEntity
                {
                    GoalsLocal   = request.GoalsLocal,
                    GoalsVisitor = request.GoalsVisitor,
                    Match        = matchEntity,
                    User         = userEntity
                };

                _dataContext.Predictions.Add(predictionEntity);
            }
            else
            {
                predictionEntity.GoalsLocal   = request.GoalsLocal;
                predictionEntity.GoalsVisitor = request.GoalsVisitor;
                _dataContext.Predictions.Update(predictionEntity);
            }

            await _dataContext.SaveChangesAsync();

            return(NoContent());
        }
        //Open Matched Item Detail View with all Parameter pass with serialization form and set next and prevue data to manage next and prevue functionality.
        public ActionResult cShowMatchedItesDetailsView(string Parameters)
        {
            string id = string.Empty, childButtonId = string.Empty, dataNext = string.Empty, dataPrev = string.Empty, count = string.Empty; bool IsPartialView = false;

            // Get Query string in Encrypted mode and decrypt Query string and set Parameters
            if (!string.IsNullOrEmpty(Parameters))
            {
                Parameters               = StringCipher.Decrypt(Parameters.Replace(Utility.Utility.urlseparator, "+"), General.passPhrase);
                id                       = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 0, 1);
                childButtonId            = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 1, 1);
                dataNext                 = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 2, 1);
                dataPrev                 = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 3, 1);
                count                    = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 4, 1);
                ViewBag.AdditionalFields = Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 5, 1);
                IsPartialView            = Convert.ToBoolean(Utility.Utility.SplitParameters(Parameters, Utility.Utility.Colonseparator, 6, 1));
            }
            MatchEntity Match = new MatchEntity();

            ViewBag.dataNext   = dataNext;
            ViewBag.dataPrev   = dataPrev;
            ViewBag.SelectData = "SearchData";
            List <MatchEntity> matches = new List <MatchEntity>();

            if (!string.IsNullOrEmpty(SessionHelper.SearchMatch))
            {
                matches = JsonConvert.DeserializeObject <List <MatchEntity> >(SessionHelper.SearchMatch);
            }
            Match = matches.Where(x => x.DnBDUNSNumber == childButtonId).FirstOrDefault();
            try
            {
                ViewBag.NextToNextDUNS = dataNext != "" ? matches.SkipWhile(p => p.DnBDUNSNumber != dataNext).ElementAt(1).DnBDUNSNumber : matches.SkipWhile(p => p.DnBDUNSNumber != childButtonId).ElementAt(1).DnBDUNSNumber;
            }
            catch
            {
                ViewBag.NextToNextDUNS = "";
            }
            try
            {
                ViewBag.PrevToPrevDUNS = dataPrev != "" ? matches.TakeWhile(p => p.DnBDUNSNumber != dataPrev).LastOrDefault().DnBDUNSNumber : matches.TakeWhile(p => p.DnBDUNSNumber != childButtonId).LastOrDefault().DnBDUNSNumber;
            }
            catch
            {
                ViewBag.PrevToPrevDUNS = "";
            }
            ViewBag.childButtonId = id;
            CompanyEntity company = new CompanyEntity();
            Tuple <MatchEntity, CompanyEntity> tuple = new Tuple <MatchEntity, CompanyEntity>(Match, company);

            //when Popup is already open and click on next previous at that time we reload just partial view
            if (!IsPartialView)
            {
                return(PartialView("~/Views/StewardshipPortal/_MatchedItemDetailView.cshtml", tuple));
            }
            else
            {
                return(PartialView("~/Views/StewardshipPortal/_MatchDetails.cshtml", tuple));
            }
        }
        private async Task AddMatchPlayers(TeamMatchPlayerEntryType[] players, MatchEntity match, bool thuisSpeler)
        {
            if (players == null)
            {
                return;
            }

            foreach (var frenoyVerslagSpeler in players)
            {
                if (string.IsNullOrWhiteSpace(frenoyVerslagSpeler.UniqueIndex))
                {
                    // Even more forfeited stuff
                    continue;
                }

                MatchPlayerEntity matchPlayerEntity = new MatchPlayerEntity
                {
                    MatchId     = match.Id,
                    Ranking     = frenoyVerslagSpeler.Ranking,
                    Home        = thuisSpeler,
                    Name        = GetSpelerNaam(frenoyVerslagSpeler),
                    Position    = int.Parse(frenoyVerslagSpeler.Position),
                    UniqueIndex = int.Parse(frenoyVerslagSpeler.UniqueIndex),
                    Status      = PlayerMatchStatus.Major
                };
                if (frenoyVerslagSpeler.VictoryCount != null)
                {
                    matchPlayerEntity.Won = int.Parse(frenoyVerslagSpeler.VictoryCount);
                }
                else
                {
                    Debug.Assert(frenoyVerslagSpeler.IsForfeited, "Either a VictoryCount or IsForfeited");
                }

                PlayerEntity dbPlayer = null;
                if (match.IsHomeMatch.HasValue && ((match.IsHomeMatch.Value && thuisSpeler) || (!match.IsHomeMatch.Value && !thuisSpeler)))
                {
                    if (_isVttl)
                    {
                        dbPlayer = await _db.Players.SingleOrDefaultAsync(x => x.ComputerNummerVttl.HasValue && x.ComputerNummerVttl.Value.ToString() == frenoyVerslagSpeler.UniqueIndex);
                    }
                    else
                    {
                        dbPlayer = await _db.Players.SingleOrDefaultAsync(x => x.LidNummerSporta.HasValue && x.LidNummerSporta.Value.ToString() == frenoyVerslagSpeler.UniqueIndex);
                    }
                }
                if (dbPlayer != null)
                {
                    matchPlayerEntity.PlayerId = dbPlayer.Id;
                    if (!string.IsNullOrWhiteSpace(dbPlayer.NaamKort))
                    {
                        matchPlayerEntity.Name = dbPlayer.NaamKort;
                    }
                }

                match.Players.Add(matchPlayerEntity);
            }
        }
        public virtual IEnumerable <T> GetAll()
        {
            var client = _neo4jService.Client;

            var searchedItems = client.Cypher.Match(MatchEntityQuery)
                                .Return <T>(MatchEntity.ToLower())
                                .Results;

            return(searchedItems);
        }