Beispiel #1
0
        public async Task <IHttpActionResult> GetRequestedMatches(string userID = null)
        {
            string appUserID = (userID == null) ? User.Identity.GetUserId() : userID;

            try
            {
                var requestedMatches = await _matchesService.GetRequestedMatchesForId(appUserID);

                var matchesModels = _mapperToMatchModel.Map <List <MatchViewModel> >(requestedMatches);

                foreach (var match in matchesModels.Where(x => x.OpponentId == appUserID))
                {
                    match.IsMatchReceived = true;
                }

                return(Ok <List <MatchViewModel> >(matchesModels));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }