示例#1
0
 public MatchDto clearLeaf(MatchDto match)
 {
     if (match.Second == null && match.PrevA == null && match.PrevB == null)
     {
         return(null);
     }
     return(match);
 }
示例#2
0
 public MatchDto UpdateMatch(MatchDto updatedMatch)
 {
     lock (_lockObj)
     {
         var matchId = updatedMatch.PlayFabMatchId;
         _cache[matchId] = updatedMatch;
         return(updatedMatch);
     }
 }
示例#3
0
        //Get match by match ID
        public async Task <MatchDto> GetMatchByIdAsync(long matchID)
        {
            MatchDto match    = null;
            string   request  = "/lol/match/" + M_VERSION + "/matches/" + matchID;
            string   response = await GET(request);

            match = JsonConvert.DeserializeObject <MatchDto>(response);
            return(match);
        }
示例#4
0
        //Get match by match ID and tournament code
        public async Task <MatchDto> GetTournamentMatchAsync(string tournamentCode, long matchID)
        {
            MatchDto tournament = null;
            string   request    = "/lol/match/" + M_VERSION + "/matches/" + matchID + "/by-tournament-code/" + tournamentCode;
            string   response   = await GET(request);

            tournament = JsonConvert.DeserializeObject <MatchDto>(response);
            return(tournament);
        }
 public async Task Update(int id, [FromBody] MatchDto match)
 {
     match.Id = id;
     var request = new UpdateMatchRequest
     {
         Match = match
     };
     await _mediator.ExecuteAsync(request).ConfigureAwait(false);
 }
示例#6
0
        private async void Match_Click(object sender, RoutedEventArgs e)
        {
            GeneralButton.Foreground  = Brushes.MediumPurple;
            ChampionButton.Foreground = Brushes.MediumPurple;
            MatchButton.Foreground    = Brushes.Purple;
            LiveButton.Foreground     = Brushes.MediumPurple;
            Show_Notification("Loading...", false);

            matchlist_handler = new MatchlistHandler(viewProfile.Region);
            MatchlistDto matchlist_entry = await matchlist_handler.GetMatchlist(viewProfile.SummonerEntry.AccountId);

            List <MatchDto> matchData = new List <MatchDto>();

            if (matchlist_entry.Matches.Count >= 7)
            {
                for (int i = 0; i < 7; i++)
                {
                    long     gameId      = matchlist_entry.Matches[i].GameId;
                    MatchDto match_entry = await matchlist_handler.GetMatch(gameId.ToString());

                    matchData.Add(match_entry);
                }
            }
            else if (matchlist_entry.Matches.Count > 0)
            {
                for (int i = 0; i < matchlist_entry.Matches.Count; i++)
                {
                    long     gameId      = matchlist_entry.Matches[i].GameId;
                    MatchDto match_entry = await matchlist_handler.GetMatch(gameId.ToString());

                    matchData.Add(match_entry);
                }
            }

            List <Queues> queueData = await matchlist_handler.GetQueues();


            if (matchlist_handler.ErrorMsg != "")
            {
                Show_Notification(matchlist_handler.ErrorMsg);
                return;
            }

            viewProfile.MatchlistEntry = matchlist_entry;
            viewProfile.MatchEntries   = matchData;
            viewProfile.AllQueuesList  = queueData;

            if (viewProfile.MatchEntries.Count > 0)
            {
                Main.Content = new MatchHistory(viewProfile);
            }
            else
            {
                Show_Notification("No match history to display", false);
            }
        }
示例#7
0
        public async Task <int> CreateAsync(MatchDto dto)
        {
            var model = dto.AsModel(this._context);

            await this._context.Matches.AddAsync(model);

            await this._context.SaveChangesAsync();

            return(model.Id);
        }
示例#8
0
        // 猜比分
        // GET: /Casino/MatchResult/id

        public ActionResult MatchResult(Guid id)
        {
            var model = new MatchResultDto
            {
                Match     = MatchDto.Single(id),
                MatchGuid = id
            };

            return(View(model));
        }
示例#9
0
 public static List <MatchEntity> DtoEntity(this MatchDto disco)
 {
     if (disco == null)
     {
         return(null);
     }
     return(new List <MatchEntity>()
     {
     });
 }
示例#10
0
        public async Task <ActionResult> MatchList()
        {
            MatchListDto matchList = await _matchService.GetRecentMatchListAsync(RegionDto.euw, "Bommerhond");

            MatchDto matchDto = await _matchService.GetMatchAsync(RegionDto.euw, matchList.Matches.First().GameId);

            await _matchService.Test();

            return(View("Index"));
        }
示例#11
0
        public bool Match([CanBeNull] MatchDto match)
        {
            var active = _context.Value;

            if (active == null)
            {
                return(false);
            }
            return(match?.IsMatch(active.Class, active.Exe) == true);
        }
示例#12
0
        public async Task <HttpResponseMessage> Create([FromBody] MatchDto userAccount)
        {
            var request = new CreateMatchRequest
            {
                Match = userAccount
            };
            await _mediator.ExecuteAsync(request).ConfigureAwait(false);

            return(Request.CreateResponse(HttpStatusCode.Created));
        }
示例#13
0
 public static Match ConvertToEntity(this MatchDto match)
 {
     return(new Match
     {
         Id = match.Id,
         HomeTeam = match.HomeTeam.ConvertToEntity(),
         AwayTeam = match.AwayTeam.ConvertToEntity(),
         IsCompleted = match.IsCompleted,
         TournamentId = match.TournamentId
     });
 }
示例#14
0
        public void Should_FollowAllNonNullCondition_WhileMatching()
        {
            // Arrange
            var match = new MatchDto("class", "exe");

            // Act
            var result = match.IsMatch("class", "wrong");

            // Assert
            result.Should().BeFalse();
        }
示例#15
0
        public void Should_IgnoreAnyOfNullConditions_WhileMatching()
        {
            // Arrange
            var match = new MatchDto(null, "exe");

            // Act
            var result = match.IsMatch("class", "exe");

            // Assert
            result.Should().BeTrue();
        }
示例#16
0
        public IActionResult Create([FromBody] MatchDto dto)
        {
            if (string.IsNullOrWhiteSpace(dto.Player1) || string.IsNullOrWhiteSpace(dto.Player2))
            {
                return(this.BadRequest());
            }

            var match = AddMatch(dto.Player1, dto.Player2, dto.StartTime);

            return(this.Ok(match));
        }
        public IActionResult Put(int id, [FromBody] MatchDto match)
        {
            var model = _mapper.Map <MatchDto, Match>(match);

            if (match == null || match.Id != id)
            {
                return(BadRequest());
            }
            _repository.Update(model);
            return(new NoContentResult());
        }
        public void AddMatch_NewMatch_SaveMatch()
        {
            string tournamentId = "2a6a362c-cda6-45fe-b83b-da249fe1287f";
            var    match        = new MatchDto
            {
                HomeTeam = tournamentRepository.GetTeamByName("White"),
                AwayTeam = tournamentRepository.GetTeamByName("Blue")
            };

            tournamentRepository.AddMatch(tournamentId, match);
        }
        public IActionResult Create([FromBody] MatchDto item)
        {
            var model = _mapper.Map <MatchDto, Match>(item);

            if (model == null)
            {
                return(BadRequest());
            }

            _repository.Insert(model);
            return(CreatedAtRoute("GetMatch", new { id = item.Id }, item));
        }
示例#20
0
        public void Should_AbleTo_HandleNullString()
        {
            // Arrange
            var match = new MatchDto(null, null);

            // Act


            // Assert
            match.Class.Should().BeNull();
            match.Exe.Should().BeNull();
        }
示例#21
0
        private async Task RemoveMatch(MatchDto match)
        {
            var oldMatch = _db.Matches.Single(x =>
                                              x.LeagueTitle == match.LeagueTitle &&
                                              x.HomeTeam == match.HomeTeam &&
                                              x.AwayTeam == match.AwayTeam);

            _db.Matches.Remove(oldMatch);
            _tableService.RemoveOrUpdateTable(Mapper.Map <MatchDto>(oldMatch));

            await _db.SaveChangesAsync();
        }
        //todo drawing
        private void DrawFirstRound()
        {
            CurrentRound = 1;
            int sizeDraw            = TournamentDto.DrawSize;
            List <UserReadDto> draw = new List <UserReadDto>();

            for (int i = 0; i < sizeDraw; i++)
            {
                draw.Add(new UserReadDto(-1));
            }

            for (int i = UsersDto.Count; i < sizeDraw; i++)
            {
                UsersDto.Add(new UserReadDto(-1));
            }

            List <MatchDto> matchesTmp = new List <MatchDto>();

            for (int i = 0; i < sizeDraw / 2; i++)
            {
                matchesTmp.Add(new MatchDto(TournamentDto, UsersDto[i], UsersDto[UsersDto.Count - 1 - i], CurrentRound));
            }


            var upperHalf  = 0;
            var bottomHalf = sizeDraw - 1;

            for (int i = 0; i < sizeDraw / 2; i++)
            {
                MatchDto match = matchesTmp[i];
                if (i % 2 == 0)
                {
                    draw[upperHalf]     = match.Player1;
                    draw[upperHalf + 1] = match.Player2;
                    upperHalf          += 2;
                }
                else
                {
                    draw[bottomHalf]     = match.Player1;
                    draw[bottomHalf - 1] = match.Player2;
                    bottomHalf          -= 2;
                }
            }


            Matches = new List <MatchDto>();
            for (int i = 0; i < draw.Count; i += 2)
            {
                UserReadDto p1 = draw[i].Id == -1 ? _byeUser : draw[i];
                UserReadDto p2 = draw[i + 1].Id == -1 ? _byeUser : draw[i + 1];
                Matches.Add(new MatchDto(TournamentDto, p1, p2, CurrentRound));
            }
        }
        private PtsAndGoalsDto GetPtsAndGoals(MatchDto match)
        {
            var homeTeamPts = MatchHelper.GetNumberOfHomeTeamPoints(match.Score);

            return(new PtsAndGoalsDto
            {
                HomeTeamPts = homeTeamPts,
                AwayTeamPts = homeTeamPts == 3 ? 0 : homeTeamPts == 1 ? 1 : 3,
                HomeTeamGoals = MatchHelper.GetNumberOfGoals(match.Score, homeTeam: true),
                AwayTeamGoals = MatchHelper.GetNumberOfGoals(match.Score, homeTeam: false)
            });
        }
示例#24
0
        private bool GetWinLossByMatchId(long gameId, string accountId)
        {
            MatchDto match = riotAdapter.GetMatchById(gameId.ToString()).Result;

            if (match != null)
            {
                long participantId = 0;

                // 100 for blue side; 200 for red side
                long teamId = 0;

                // "fail" for loss; "Win" for win
                string winStatus = string.Empty;

                foreach (ParticipantIdentity participant in match.ParticipantIdentities)
                {
                    if (participant.Player.AccountId.Equals(accountId))
                    {
                        participantId = participant.ParticipantId;
                        break;
                    }
                }

                foreach (Participant participant in match.Participants)
                {
                    if (participant.ParticipantId == participantId)
                    {
                        teamId = participant.TeamId;
                        break;
                    }
                }

                foreach (Team team in match.Teams)
                {
                    if (team.TeamId == teamId)
                    {
                        winStatus = team.Win;
                        break;
                    }
                }

                switch (winStatus)
                {
                case "Win":
                    return(true);

                default:
                    return(false);
                }
            }
            throw new Exception("match was null: problem with API");
        }
示例#25
0
        private Match CreateMatch(MatchDto matchDto)
        {
            Match match = new Match();

            match.Id               = matchDto.Id;
            match.IdLocalTeam      = matchDto.IdLocalTeam;
            match.IdVisitorTeam    = matchDto.IdVisitorTeam;
            match.LocalTeamScore   = matchDto.LocalTeamScore;
            match.VisitorTeamScore = matchDto.VisitorTeamScore;
            match.PlayingDay       = matchDto.PlayingDay;
            match.Played           = matchDto.Played;
            return(match);
        }
示例#26
0
        public void UpdateMatch(MatchDto dto)
        {
            var entity = matchRepository.Find(x => x.Id == dto.Id).FirstOrDefault();

            entity.TeamA       = dto.TeamA;
            entity.TeamB       = dto.TeamB;
            entity.MatchTime   = Convert.ToDateTime(dto.MatchTime);
            entity.Dish        = dto.Dish;
            entity.Venue       = dto.Venue;
            entity.MatchResult = dto.MatchResult;
            entity.MatchState  = EnumHelper.Parse <MatchStateEnum>(dto.MatchState);
            matchRepository.Save(entity);
        }
示例#27
0
        public void CreateMatch(MatchDto input)
        {
            DateTime date  = DateTime.Now;
            var      match = new Match
            {
                FirstPlayerId  = input.FirstPlayerId,
                SecondPlayerId = input.SecondPlayerId,
                StartTime      = date
            };

            _context.Matches.Add(match);
            _context.SaveChanges();
        }
示例#28
0
        public async Task <IActionResult> GetById(int id)
        {
            var match = await _matchRepository.GetByIdAsync(id);

            if (match == null)
            {
                return(BadRequest($"Invalid match id : { id }"));
            }

            var dto = MatchDto.FromEntity(match);

            return(Ok(dto));
        }
示例#29
0
 public IActionResult Post([FromBody] MatchDto matchDto)
 {
     try
     {
         var match = _matchBusinessLogic.CreateMatch(matchDto);
         _hub.Clients.All.SendAsync(MatchHub.MESSAGE);
         return(Created(new Uri($"http://localhost:5001/api/matches/{match.MatchId.Value}"), match));
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
         return(StatusCode(500, e));
     }
 }
示例#30
0
 public JsonResult UpSetMatch(MatchDto match)
 {
     return(ExceptionCatch.Invoke(() =>
     {
         if (match.Id > 0)
         {
             MatchService.Instance.UpdateMatch(match);
         }
         else
         {
             MatchService.Instance.AddMatch(match);
         }
     }));
 }