public Response <List <UserInfo> > GetMatchPlayers([FromHeader] GeMatchByIdRequest request) { _logger.LogInfo("request for match players arrived"); var result = _matchManager.GetMatchPlayers(request); return(result); }
/// <summary> /// Method that returns the players for the match propagated from the GetMatchPlayers endpoint /// </summary> public Response <List <UserInfo> > GetMatchPlayers(GeMatchByIdRequest request) { var response = new Response <List <UserInfo> >(); var pagedResponse = new List <UserInfo>(); var getPlayers = _umRepository.GetAll <UserMatches>(includeProperties: $"{nameof(UserMatches.User)}").Where(x => x.MatchId == request.MatchId).ToList(); if (getPlayers == null) { _logger.LogError("no players found"); response.Messages.Add(new ResponseMessage { Type = Contracts.Enums.ResponseMessageEnum.Exception, Message = "the match does not exist", }); response.Status = System.Net.HttpStatusCode.NotFound; } getPlayers.ForEach(x => { var playerInfo = new UserInfo() { Email = x.User.Email, UserName = x.User.UserName, FirstName = x.User.FirstName, LastName = x.User.LastName, Id = x.User.Id }; pagedResponse.Add(playerInfo); }); _logger.LogInfo("player details returned"); response.Payload = pagedResponse; response.Status = System.Net.HttpStatusCode.OK; return(response); }
public Response <MatchDetails> GetMatch([FromHeader] GeMatchByIdRequest request) { _logger.LogInfo("request for match details arrived"); var result = _matchManager.GetMatch(request); return(result); }
/// <summary> /// Method that returns the match details propagated from the GetMatch endpoint /// </summary> public Response <MatchDetails> GetMatch(GeMatchByIdRequest request) { var response = new Response <MatchDetails>(); var getMatch = _repository.GetOne <Matches>(x => x.Id == request.MatchId, includeProperties: $"{nameof(Matches.UserMatches)},{nameof(Matches.Court)}"); if (getMatch == null) { _logger.LogError("no match found"); response.Messages.Add(new ResponseMessage { Type = Contracts.Enums.ResponseMessageEnum.Exception, Message = "the match does not exist", }); response.Status = System.Net.HttpStatusCode.NotFound; } var matchDetails = new MatchDetails() { MatchId = getMatch.Id, CourtName = getMatch.Court.Name, Lat = getMatch.Court.Lat, Lng = getMatch.Court.Lng, MaxPlayers = getMatch.MaxPlayers, CurrentPlayers = getMatch.CurrentPlayers, Type = getMatch.Type, StartTime = getMatch.StartTime, EndTime = getMatch.EndTime, }; _logger.LogInfo("match details returned"); response.Payload = matchDetails; response.Status = System.Net.HttpStatusCode.OK; return(response); }